[Nickle]Array comprehension syntax

Keith Packard nickle@nickle.org
Mon, 05 Aug 2002 19:18:59 -0700


Around 23 o'clock on Aug 4, Bart Massey wrote:

>   int[11] a = { =(i) triangle(11, i) ... };
> although in all these examples it is troubling that changing
> the size of a will not automatically work, so maybe
>   int[11] a = { =(i) triangle(dim(a), i) ... };
> works, although I don't think a is scoped in yet in the
> initializer :-) so probably not.  Sigh.

The variable 'a' is scoped in, but it hasn't been initialized yet.
That follows the L-to-R rule for evaluation; the declaration is to the 
left of the initializer so the variable is in scope, but the initializer 
is the RHS of the assignment operator which hasn't been evaluated yet so
a is uninitialized.  I'm wondering if we'd like a syntax that permitted 
reflexive comprehensions; I could scope in some magic name which referred 
to the array itself within the context of the anonymous lambda.

> The other classic approach is to not let the user name the
> formals, but instead pre-supply names: something like
>   int[11] a = { = triangle($#, $1) ... };
> or perhaps something less ugly.

Yuck.  Positional arguments deemed harmful.

Keith Packard        XFree86 Core Team        HP Cambridge Research Lab