Comments (4)
One question is what to do with macros, it seems that this should work, since it doesn't look like a function call:
@_ data |> @view map(_.re, __)[1:3]
but as you mentioned in #8, sometimes you will need brackets:
a |> @m b |> c # parsed as a |> @m(b |> c)
Would it be crazy for @_
to re-organise such things to a |> (@m b) |> c
?
from underscores.jl.
Would it be crazy for
@_
to re-organise such things toa |> (@m b) |> c
?
I think it's a bit dangerous to second guess the language parsing rules, I think it will lead to irregularities and surprises in the longer term.
For example, the user could write this as a |> @m(b |> c)
and they'll be quite surprised when we rearrange the whole thing :-)
from underscores.jl.
An interesting case from #18 (comment) which I agree should work.
julia> any(>(3), 1:4) ? "yes" : "no"
"yes"
julia> @_ any(_>3, 1:4) ? "yes" : "no"
ERROR: TypeError: non-boolean (var"#13#14") used in boolean context
from underscores.jl.
Note that such examples won't work very well in pipelines -- I'm unsurprised by (0 |> string)
here but was a little surprised by (data |> cond)
:
julia> :(data |> if any(_,__) 1 else 0 end |> string) |> Meta.show_sexpr
(:call, :|>, (:call, :|>, :data, (:if, (:call, :any, :_, :__), (:block,
:(#= REPL[14]:1 =#),
1
), (:block,
:(#= REPL[14]:1 =#),
0
))), :string)
julia> :(data |> any(_,__) ? 1 : 0 |> string) |> Meta.show_sexpr
(:if, (:call, :|>, :data, (:call, :any, :_, :__)), 1, (:call, :|>, 0, :string))
from underscores.jl.
Related Issues (15)
- A way to allow for `filter`, `map` piping... HOT 3
- Consider capturing bindings by value (FastClosures.jl) HOT 5
- Assignment gets read as a keyword HOT 3
- @_ within the selector Fun part of DataFrames.select HOT 6
- Feature Request: if no `__` is specified then insert into first argument HOT 9
- Doesn't with ternary operators HOT 3
- Redesign _ -> identity transforms HOT 2
- Broadcasted piping .|> HOT 2
- Release a new version to make new bugfixes avaiable HOT 4
- TagBot trigger issue HOT 1
- Switch to more local `@_` HOT 5
- Behavior of `_` is confusing with infix operators HOT 15
- Underscore replacement should recurse into quasiquote
- Interaction with indexing brackets HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from underscores.jl.