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

Chain as pipe argument #38

Open
knuesel opened this issue Nov 15, 2021 · 3 comments
Open

Chain as pipe argument #38

knuesel opened this issue Nov 15, 2021 · 3 comments

Comments

@knuesel
Copy link

knuesel commented Nov 15, 2021

Parentheses are necessary to put a chain in a pipe. For example the following

@chain DataFrame(a=1:3) begin select(:a) end |> display

fails with

ERROR: MethodError: no method matching select(::Symbol)
Closest candidates are:
  select(::AbstractDataFrame, ::Any...; copycols, renamecols) at ~/.julia/packages/DataFrames/vuMM8/src/abstractdataframe/selection.jl:940
  select(::Union{Function, Type}, ::AbstractDataFrame; renamecols) at ~/.julia/packages/DataFrames/vuMM8/src/abstractdataframe/selection.jl:943
  select(::Union{Function, Type}, ::GroupedDataFrame; copycols, keepkeys, ungroup, renamecols) at ~/.julia/packages/DataFrames/vuMM8/src/groupeddataframe/splitapplycombine.jl:711

Would it be possible to make this work without parentheses? Intuitively it seems that it should be possible since the chained code is already delimited by the begin ... end block.

@jkrumbiegel
Copy link
Owner

This seems a bit problematic because of the other @chain mode where you can do @chain x y z, then I'd have to separate normal |> calls from those after begin end and this sounds edge-casey to me..

@jkrumbiegel
Copy link
Owner

In your example you can of course put display after select

@knuesel
Copy link
Author

knuesel commented Dec 12, 2021

Agreed, though I still think it would be nice if @chain blocks were composable with other pipeline code (mainly because for me a @chain block is often a logical unit, like in the example where putting display inside would work but is less clear I think than a processing block followed by some "unrelated" action).

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