Re: subscripts (Long Post)
- Posted by Robert Craig <rds at ATTCANADA.NET> May 12, 2000
- 458 views
Lewis Townsend writes: >>sequence a: >> >>subscript value >> >>1 0 >>2 {0,0,{9},1} >>3 {} >>"Lewis" 99 >>"Townsend" {1, 2, 3} > a ["First"] = 5 > ? a[1] -- is this equal to > ? a["First"] -- this? No, 1 and "First" are two different Euphoria objects, so they would each have their own associated value. A sequence could be implemented internally as a list of object-value pairs. a[10] might have a value, while a[4] has never been assigned a value, so a[4] would not exist and would give you an error or something if you tried to read it. You'd probably want some special "undefined" value to be returned, rather than just getting a fatal subscript error. Subscripting a sequence would cause the interpreter to search a list for an object. This could get very expensive, so internally the interpreter would use a fast hash table lookup, or some other trickery. If you never used anything but small integers for subscripts, the implementation might revert to the fast random access method that we have today. I suppose length() would return the number of object-value pairs. Anyway this is all moot, as I have no plans to go ahead with this. Your idea could also be quite useful, but I want to keep things simple. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com