Add ValueList as a 6.e feature in core
Raku needs a value-type object for lists. This copies the ValueList ecosystem module https://raku.land/zef:lizmat/ValueList verbatim and makes it part of 6.e. It does NOT provide any additional syntactic sugar to easily create ValueLists, so ValueList.new(...) is the way to go now.
As syntactic sugar for ValueLists, I would suggest β
β, basically:
sub circumfix:<β
β>(\a) { ValueList.new(a) }
Allowing β
1,2,3β as a value type.
I would propose to implement this in RakuAST only: this would allow it to be properly handled at compile time and produce WVals if all elements in a ValueList are constants (aka: can be literalized).
I don't think discussing a new operator here would be a good idea. And I anticipate a dispute because β
β pair has two major drawbacks.
First, it's a Unicode which is barely easy to use. A no good thing for something that is likely to be used on a very regular basis.
Second, the pair resembles array operator which is, apparently, has quite the opposite semantics.
I don't think discussing a new operator here would be a good idea
I see it as brain-storming at this point, as any real discussion will be moot without this PR (or a functional equivalent thereof) being merged.
anticipate a dispute because β β pair has two major drawbacks
Perhaps ((...)) would be good syntactic sugar. With βΈ¨...βΈ© as the Unicode equivalents.
use ValueList;
sub circumfix:<(( ))>(\a) { ValueList.new(a) };
dd ((1,2,3)).WHICH; # ValueObjAt.new("ValueList|C97F62DE1BA14379F6F017F3DFCBF16FB199D041")
dd Map.new(("a",42)); # Map.new((:a(42)))
((1 + 2) * 3)
On Thu, Jan 4, 2024 at 8:14β―AM Elizabeth Mattijsen @.***> wrote:
I don't think discussing a new operator here would be a good idea
I see it as brain-storming at this point, as any real discussion will be moot without this PR (or a functional equivalent thereof) being merged.
anticipate a dispute because β β pair has two major drawbacks
Perhaps ((...)) would be good syntactic sugar. With βΈ¨...βΈ© as the Unicode equivalents.
use ValueList;sub circumfix:<(( ))>(\a) { ValueList.new(a) };dd ((1,2,3)).WHICH; # ValueObjAt.new("ValueList|C97F62DE1BA14379F6F017F3DFCBF16FB199D041") dd Map.new(("a",42)); # Map.new((:a(42)))
β Reply to this email directly, view it on GitHub https://github.com/rakudo/rakudo/pull/5510#issuecomment-1877367694, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABHSYXB2TIKMR3SCBUGTMLYM3IOFAVCNFSM6AAAAABBMZ3ECCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZXGM3DONRZGQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>
use ValueList;
sub circumfix:<(( ))>(\a) { ValueList.new(a) };
say ((1 + 2) * 3);
Unable to parse expression in circumfix:sym<(( ))>; couldn't find final '))' (corresponding starter was at line 6)
at ...:3
------> say ((1+2β) * 3);
meh :-) So ((...)) it won't be.
I can't concentrate on this matter deep enough to come out with a worthwhile proposal, but what I currently see is that the entire field of de-/containerization is not covered by unified Raku syntax. Basically, all we currently have are ops for itemizing with $ and deconting with <>, but both are targeting individual objects and do not propagate to collection types. Besides, I remember some complains about the weirdness of <> operator as its semantics has nothing in common with <key> hash access form.
The direction I'm looking at is based on <> (until a better replacement is found). What we can do is to use the decont operator (whatever it is) to mark the existing collection creation circumfixes in order to produce value counterparts of hashes and lists. Something like:
- ValueList:
(<> $a, $b, $c), unicode:β¦ $a, $b, $c β¦ - ValueMap:
{<> :$a, :$b, :$c },%(<> :$a, :$b, :$c ), unicode:β¦ :$a, :$b, :$c β¦
Apparently, %(<> is gross, but if decont operator is considered as a modifier then things are looking less horrible.