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

Do we really need begin and end in the expression? #17

Closed
pdeffebach opened this issue Feb 11, 2021 · 4 comments
Closed

Do we really need begin and end in the expression? #17

pdeffebach opened this issue Feb 11, 2021 · 4 comments

Comments

@pdeffebach
Copy link
Contributor

In Lazy's @> you can do

@> rand(2, 3) DataFrame(:auto)

But in Chain you need

julia> @chain rand(2, 3) DataFrame(:auto)
ERROR: LoadError: Second argument of @chain must be a begin / end block
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] rewrite_chain_block(::Expr, ::Expr) at /home/peterwd/.julia/packages/Chain/HuSPl/src/Chain.jl:66
 [3] @chain(::LineNumberNode, ::Module, ::Any, ::Expr) at /home/peterwd/.julia/packages/Chain/HuSPl/src/Chain.jl:113
in expression starting at REPL[22]:1

Is there a technical reason for this? Maybe it's not necessary?

@jkrumbiegel
Copy link
Owner

It's not "technical" as much as I just didn't implement that syntax because I assumed data wrangling would never happen on a single line, if a chaining macro is used already to reduce the complexity. But maybe I'm wrong :) we could easily add this, someone else already made an issue about this earlier

@adkabo
Copy link

adkabo commented Feb 20, 2021

@chain begin
    1
    -
end

and

@chain 1 begin
    -
end

Seems like the begin might not be doing much here. Is there a case where the begin can't just be inferred automatically?

@jkrumbiegel
Copy link
Owner

Those two syntax alternatives are both explicitly implemented. The begin block is necessary to bundle the expressions on different lines. You can't do that with parentheses alone, that doesn't parse.

@pdeffebach
Copy link
Contributor Author

Closed in #24

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

Successfully merging a pull request may close this issue.

3 participants