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

Make default begin ... end rather than let #30

Open
pdeffebach opened this issue Jun 16, 2021 · 4 comments
Open

Make default begin ... end rather than let #30

pdeffebach opened this issue Jun 16, 2021 · 4 comments

Comments

@pdeffebach
Copy link
Contributor

pdeffebach commented Jun 16, 2021

I think it's not uncommon to want things created in @aside blocks to be visible in the outer scope of a @chain block.

If we make the default "block" for @chain to be just a begin ... end block without introducing a new scope, the user can make the same behavior with

@chain df let
    ...
end

This is something I considered in AddToField.jl and settled on begin ... end.

@pdeffebach
Copy link
Contributor Author

Well, what I really would like is some way to send variables to the outer scope easily, with something like @assign intermediate = _. And I don't think this is really feasible with everything in a let block.

@jkrumbiegel
Copy link
Owner

yeah I guess I could actually do that. I thought I wouldn't because of all the intermediary variables, but I guess they won't interfere much? I'm not sure if there's a speed difference at global scope because the intermediary variables would be non-const. I guess one could make them const as well though

@pdeffebach
Copy link
Contributor Author

I was wrong about AddToField.jl working with let though. I will fix AddToField and then apply the same strategy to a PR here.

Aren't all the intermediate variables in @chain anonymous variables? Does that make things better?

@jkrumbiegel
Copy link
Owner

yes they are, I just chose let in the beginning to have no trace at all of these variables. But I do think exporting a variable once in a while or saving an intermediate step can be useful

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