Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ValueList as a 6.e feature in core #5510

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

lizmat
Copy link
Contributor

@lizmat lizmat commented Jan 4, 2024

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.

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.
@lizmat lizmat added consensus needed Needs a well-versed decision with justification, possibly from a core developer detrap Improving warnings, tweaking the language, etc. (anything to prevent WATs) 6.e Related to the next 6.e language release labels Jan 4, 2024
@lizmat
Copy link
Contributor Author

lizmat commented Jan 4, 2024

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).

@vrurg
Copy link
Member

vrurg commented Jan 4, 2024

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.

@lizmat
Copy link
Contributor Author

lizmat commented Jan 4, 2024

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)))

@TimToady
Copy link
Contributor

TimToady commented Jan 6, 2024 via email

@lizmat
Copy link
Contributor Author

lizmat commented Jan 8, 2024

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.

@vrurg
Copy link
Member

vrurg commented Jan 8, 2024

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.

@lizmat lizmat marked this pull request as draft February 19, 2024 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.e Related to the next 6.e language release consensus needed Needs a well-versed decision with justification, possibly from a core developer detrap Improving warnings, tweaking the language, etc. (anything to prevent WATs)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants