problem-solving icon indicating copy to clipboard operation
problem-solving copied to clipboard

&-sigiled terms an possibly other emergent "features"

Open gfldex opened this issue 4 years ago • 1 comments

The following example works in HEAD and likely did so for quite some time.

class __px {}
multi postcircumfix:<{ }>(__px, @a) { "interpolation of @a[]" }

constant term:<&px> = __px;

say "&px<1 2 3>"

Here, an &-sigiled term mimics a subroutine call where there is no subroutine to be called. I can't find any mentioning of &-sigiled terms in Roast. In fact, term: seems to be underspecced in general. This leaves the quetion, how we deal with such emergent "features". As I understand it, Roast was meant as a starting point and common ground for alternate/competing compiler implementations. One could argue that we already got one with new-disp/RakuAST. Should we just spec this and expect other implementations to follow?

I'm asking, because I just showed this example in #raku-beginner and am not sure if unspecced constructs belong there. It somehow feels wrong to do so.

If this is specced, we need to solve the ENODOC as well.

gfldex avatar Sep 06 '21 20:09 gfldex

Aiui we want to avoid nailing anything down in roast unless we are very confident we want to do that for any given "feature" / test.


As for the particular example you've provided....

First, simplifying a hair:

multi postcircumfix:<{ }>(Nil, @a) { "interpolation of @a[]" }

constant term:<&px> = Nil;

say "&px<1 2>"

Aiui, in strings being interpolated with :f set to True (eg per default double quoted rules), a valid identifier string starting with a & is treated as being possibly a function call, and Raku then parses from the & onwards until code no longer validly parses as a Raku expression. Then it tries to compile it; if it turns out there's no symbol matching the putative identifier, then the expression is treated as literal text, not as Raku code. If there is a matching symbol, but it turns out not to be a routine, it's replaced by whatever it is bound to and then the expression is evaluated.

Imo this is adequately documented on the Q Lang page and there's no need to update roast.

raiph avatar Sep 07 '21 17:09 raiph