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

Anonymous Struct literal `${a:1, b:2}` #3259

wants to merge 8 commits into
base: master


Copy link

ko1 commented Jun 25, 2020

Try to introduce anonymous Struct literal.

${a:1, b:2} is almost equal to where kw is {a:1, b:2}.
Anonymous class is prepared at compile time.

@ko1 ko1 marked this pull request as draft Jun 25, 2020
compile.c Outdated Show resolved Hide resolved
Copy link

ioquatix commented Jun 26, 2020

It's a fun idea.

I can see many usage.

ko1 added 7 commits Jun 25, 2020
Try to introduce anonymous Struct literal.
${a:1, b:2} is equal to where
kw is {a:1, b:2}.
If members of literal struct are same and same order, they share
same class.

Also fix ISeq#to_binary, .load_from_binary.
@ko1 ko1 force-pushed the ko1:struct_literal branch from 49dcd6f to 1193ce6 Jun 26, 2020
@ko1 ko1 marked this pull request as ready for review Jun 26, 2020
Copy link

ys commented Jun 26, 2020

I always wanted something short like this, but do you think we could have something more explicit and verbose like struct(a:1, b:2). Single symbols always end up with people googling around weirdly to find which one it is!

$$ = new_struct(p, $3, &@$);
$$->nd_brace = TRUE;

This comment has been minimized.

Copy link

nobu Jun 26, 2020


This seems unnecessary, because it is not a NODE_HASH.

Copy link
Contributor Author

ko1 commented Jun 27, 2020

Please DO NOT discuss spec here. Please write a comment on redmine ticket.

Copy link

pynixwang commented Jul 6, 2020

just delegate method_missing to [], then you can use . syntax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.