coco icon indicating copy to clipboard operation
coco copied to clipboard

Idea: nested &

Open akx opened this issue 10 years ago • 3 comments

thing1
  &thing2
    &doStuffWithThing2()
    &&doStuffWithThing1(&somethingFromThing2)

currently compiles to

var x0$, x1$;
x0$ = thing1;
x1$ = x0$.thing2;
x1$.doStuffWithThing2() && doStuffWithThing1(x1$.somethingFromThing2);

though it might be a nice feature to have N+1 ampersands refer to upper & scopes, ie

var x0$, x1$;
x0$ = thing1;
x1$ = x0$.thing2;
x0$.doStuffWithThing1(x1$.somethingFromThing2);

EDIT: (and &&&, &&&& etc. of course)

akx avatar Jul 23 '13 12:07 akx

syntactically conflitcts with &&, no ?

vendethiel avatar Jul 23 '13 12:07 vendethiel

&& isn't unary though, so maybe something could be done to allow it in a prefix/standalone context. Either way making this change would break some programs that currently rely on space/newline elision before && (like what happens in the "currently compiled" result there).

&^, &^^ etc. would also be a (weird?) alternate syntax if &&, &&&, etc. aren't a Good Idea.

akx avatar Jul 23 '13 13:07 akx

Well, & isn't unary either (and shows some problems, sometimes).

vendethiel avatar Aug 08 '13 20:08 vendethiel