Skip to content
This repository has been archived by the owner on Jun 4, 2019. It is now read-only.

Infer name #13

Open
davidanthoff opened this issue Aug 21, 2016 · 4 comments
Open

Infer name #13

davidanthoff opened this issue Aug 21, 2016 · 4 comments

Comments

@davidanthoff
Copy link
Collaborator

It would be great if the following syntax

a = 3
b = "something"
x = @NT(a,b)

would be equivalent to

x = @NT(a=>a,b=>b)

Ideally this would also work with immutables in the following way:

a = @NT(somename => 34)
x = @NT(a.somename)

and then x would have one member with name somename. In cases where no name can be inferred it could assign automatic names:

x = @NT(x^2)

would assign an automatic name to its one member.

This syntax would obviously break the current syntax for defining NamedTuples... But maybe that could just get its own macro, e.g. @DNT or something like that?

@mdcfrancis
Copy link
Contributor

I kind of like that, so take the variable names from the macro and 'close' in the current values to the named tuple?

@davidanthoff
Copy link
Collaborator Author

Yep, essentially just the way C# handles this for their anonymous types.

If you are ok with this, I can prep a PR. I have implemented something like this already in Query.jl, so it would just be a matter of taking my code from there and moving it into the package here, I believe.

@mdcfrancis
Copy link
Contributor

Makes sense to me.

@axsk
Copy link

axsk commented Jul 3, 2018

I was just looking for this as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants