[Oberon] How to mimic an associative array

Jan Verhoeven jan at verhoeven272.nl
Sat Dec 4 20:12:34 CET 2010


> I followed the discussion for a while, and up to now saw
> TWO different solutions to your original question:

Neither of which even comes close to the associative array.

In PiO (Reiser/Wirth) page 112 the definition of an array is given. The 
index is numeric and positive integer. A Cardinal in Modula-2 speak. 
Not even an enumerated type.

On page 34 of the same book is a nice text on type mixing. The fact that 
types CAN be mixed does not imply that they should be mixed.

In a Wirthian language a textmode array index is neither allowed nor 
possible. Unless you use systemwide constants.

And let's be glad things are the way Niklaus made them. What would be 
next? Arrays whose indexes were floating point numbers?

An 'associative array' is just against the nature of Pascal, Modula, 
Oberon, C, assembler, Forth, Basic, whatever. In fact it is against the 
nature of programming in general.
Only some scripting tools allow it. Probably because scripters cannot 
understand why the first element of an array has index 0.

Probaby I'm old fashioned.

-- 
Met vriendelijke groeten,

Jan Verhoeven
http://www.verhoeven272.nl



More information about the Oberon mailing list