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

pass variable as initial symbol instead of underscore #49

Open
akdienes opened this issue Jun 7, 2022 · 2 comments
Open

pass variable as initial symbol instead of underscore #49

akdienes opened this issue Jun 7, 2022 · 2 comments

Comments

@akdienes
Copy link

akdienes commented Jun 7, 2022

Hello,

I apologize if this has been addressed before. I like the syntax of Chain.jl but I was thinking it would be nice to be able to use the original variable name rather than only underscores. The front-page example

@chain df begin
  dropmissing
  filter(:id => >(6), _)
  groupby(:group)
  combine(:age => sum)
end

Could be something like

@chain df begin
  dropmissing
  filter(:id => >(6), df)
  groupby(:group)
  combine(:age => sum)
end

Let me know what you think.

@jkrumbiegel
Copy link
Owner

The df symbol stays valid throughout the expression so I can think it would be a bit confusing to update it with the line by line results. Also, in your case the result stays a dataframe but that isn't necessarily so, in that case it would be even more confusing, don't you think?

@akdienes
Copy link
Author

akdienes commented Jul 18, 2022

good point. I think maybe the impetus for that idea was simply that I find the underscore to be very visually low-profile and sometimes hard to locate in an expression. Maybe what could be a better idea than my original is to allow custom-defined symbols as an alias for _ ? Something like

@chain df begin as _tmp_
  dropmissing
  filter(:id => >(6), _tmp_)
  groupby(:group)
  combine(:age => sum)
end

Where here as would be a special keyword creating the alias. Obviously the exact semantics are not really important for the concept.

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

No branches or pull requests

2 participants