Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Array access and paths

From: joel:neely:fedex at: 18-May-2001 12:44

Hi, Gisle, Gisle Dankel wrote:
> I think there are a few problems with paths... > > Here is an example: > > list: [A 0 B 5 C 0 D 0] >
...
> >> idx: 'B > == B > >> list/:idx > == 5 >
Another land mine not to step on if you take that last approach is this: the type of the value in IDX actually makes a difference in what the / means. If, as in your example, IDX is set to a word, then list/:idx is (almost) equivalent to select list idx but if IDX is set to an integer, then list/:idx is equivalent to pick list idx instead. (This also means that using integers as "symbolic keys" is problematic -- a pain in the neck.) I said "(almost) equivalent" above because of this situation
>> idx: 'E
== E
>> list/:idx
** Script Error: Invalid path value: E ** Where: halt-view ** Near: list/:idx
>> select list idx
== none in which throwing an error and returning NONE are *not* IMHO equivalent behavior. -jn-