<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi<div><br></div><div>I followed the discussion for a while, and up to now saw</div><div>TWO different solutions to your original question:</div><div><br></div><div>1) proposed by Sven</div><div> TYPE<br> AssociativeArray = OBJECT<br><span class="Apple-tab-span" style="white-space: pre; ">        </span>PROCEDURE get(key : String) : String;<br><span class="Apple-tab-span" style="white-space: pre; ">        </span>PROCEDURE put(key, value : String);<br><span class="Apple-tab-span" style="white-space: pre; ">        </span>PROCEDURE remove(key : String);<br> END AssociativeArray;</div><div><br></div><div>2) proposed by Aubrey</div><div> TYPE<br> myHashPtr = POINTER TO myHash;<br><br> PROCEDURE Init* (VAR t : myHash); <br> PROCEDURE Enter* (VAR t: myHash, key: keyType, value: valueType); <br> PROCEDURE This* (t : myHash, key: keyType, VAR valueType);<br> PROCEDURE Remove* (VAR t: myHash, key : keyType);<br> PROCEDURE Enumerate* (t : myHash, handler : someProcType);<br><div><div><br></div><div>Aubrey took more the "classical" procedural approach à la Pascal or Modula.</div><div>Sven proposed the object approach possible in Oberon.</div><div><br></div><div>Personally, I like Sven's approach more. (In Sven's mail you even find</div><div>a complete Oberon implementation for his OBJECT). But you can see that</div><div>there are different approaches to model and implement a given problem</div><div>or data structure.</div><div><br></div><div>In other languages you write</div><div> capital['england'] = 'london'</div><div> location = capital['england']</div><div><br></div><div>With Sven's approach you would write</div><div> VAR capital: AssociativeArray;</div><div> capital.put('england', 'london');</div><div><div> location := capital.get('england');</div></div><div><br></div><div><span class="Apple-style-span" style="font-family: sans-serif; font-size: 13px; line-height: 19px; "></span><div><br></div><div>Associative Arrays are called differently in different programming languages</div></div><div>- "dictionary" in e.g. Python and Objective-C</div><div>- "hash" in e.g. Perl and Ruby</div><div>- "map" in e.g. C++ and Java</div><div><br></div><div>I guess the wording "hash" used by Perl generated some confusion, as in computer</div><div>science a "hash" normally describes a mapping function to a countable set of values.</div><div>Others already pointed out that an associative array can be implemented using a</div><div>hash function. BTW Sven used (a very simple) hash function in his proposed</div><div>implementation. Have a look at his mail, it gives quite some good insight in how to</div><div>program in Oberon.</div><div><br></div><div>Merry xmas!</div><div>Joerg</div><div><br></div></div></div></body></html>