extending array macro language: array[] = expr
Aaron Hsu
arcfide at sacrideo.us
Thu Apr 10 07:09:16 CEST 2008
On Thursday, April 10, 2008 @ 6:23 AM Tony Balinski wrote:
> Quoting Bert Wesarg <bert.wesarg at googlemail.com>:
>
> > this is a small change to the macro language, to accept syntax like
> this:
> >
> > arr[] = "zero"
> > arr[] = "one"
> > :
> >
> > Currently this is just an error. Now the key will be chosen as the
> > currently max numeric key in arr + 1. So holes in the numeric key
> > range are not filled.
>
> A bit misleading this: if you have the array
> arr[0] = 0
> arr[1] = 1
> arr["key0"] = 2
> arr["key1"] = 3
> adding arr[] = 999 will provide arr[2], not arr[4] as I would expect
> from the
> right-hand-side behaviour of arr[] (it's not the same as arr[arr[]] =
> 999). I
> find this counter-intuitive. However, a quick way of getting the last
> numeric
> index of an array is a good idea - it maybe more verbose, but I would
> prefer
> arr[lastindex(arr)+1] = 999
I agree that I find the arr[] = "xyz" misleading and ambiguous. I like the lastindex idea more.
--
Aaron Hsu <arcfide at sacrideo.us> | Jabber: arcfide at jabber.org
``Government is the great fiction through which everybody endeavors to
live at the expense of everybody else.'' - Frederic Bastiat
More information about the Develop
mailing list