-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Nested . syntax #20502
Comments
I would support something like this to make working with arrays of nullables easier. |
We indeed need a way to perform 2-level nested If the goal is to find a notation with two dots, we could use a pun like |
I also suggested two dots for fusing with non- Why can't |
See Jeff's reaction linked to in the issue description. |
If this worked, then presumably
could also work? P.S. I have a new package out called LazyCall.jl which enables doing things like this:
|
At the point where you'd need this syntax, I think you're better of just calling broadcast explicitly. |
@StefanKarpinski I'm not following you here. Surely lifted operations on the elements of |
I'm still pretty skeptical about broadcasting being the right way to express lifting nullable operations. |
Well, that works well for |
@StefanKarpinski But isn't that the sanctioned, official approach in base now? Merged, reviewed and accepted on master? |
Maybe. Though it should be theoretically possible to define a
or
|
While powerful, how many consecutive dots can we realistically aim to support while having readable code? While I have felt the lack of a nested broadcasting option for working with vectors of vectors, there are other options for nullables. One thing being Swift-like syntax for lifting to make an explicit but non-verbose approach (perhaps involving |
You would still need a way to indicate that you want lifting, i.e. |
Perhaps, if |
Another idea is to allow dots in addition to the @. Nullable{Int}[1, 2, 3] .+ Nullable{Int}[4, 5, 6] is considered to make the .+ behave like a second order broadcast. There is a nice parallel between @. Int[1, 2, 3] + Int[4, 5, 6] and @. Nullable{Int}[1, 2, 3] .+ Nullable{Int}[4, 5, 6] |
I'm more and more convinced that the only workable approach would be to define a new This can be done by replacing |
I happen to agree with @nalimilan - this seems the natural thing to do in a dynamic language like Julia, and if it happens to become fast, then that seems like the most logical choice all around. Not that (There is a discussion of |
I just ran into something like this, and see there's a few similar open issues. Not sure where to comment, but here it goes. I was working with multidimensional arrays, but felt the need to have non-uniform dimensions. The data can be simply stored as a "list of lists" instead of a structured uniform array but now what were simple map or broadcast operations require a "recursive map". In my opinion, the good approach to solve this looking from a FP perspective as well, is to have a data-structure where map and broadcasting will reach the leaves. A tree, for instance. So we might even have a "tree view" of an array-of-arrays, and then when you Is there already any standard or popular library that offers something like this? |
Would it make sense to allow "nested" application of the
.
syntax for broadcasting? For exampleWould translate to
and then
I imagine this would be especially useful with
Nullable
s, and arrays ofNullable
s. For example, this would work:The first dot would apply
log.
to each array element. And because we have now usedlog.
on the array elements, we get the nice new lifting for these values.Even crazy things like this would work:
Here the first dot would lift, the second dot would apply to the elements of the array, and the third dot would lift again.
I think that also relates to the issue that @JeffBezanson had here.
I have to admit that I didn't follow the whole
Nullable
discussion lately, in which case I'm sorry to bring this up again.@nalimilan, @davidagold, @johnmyleswhite Not sure who else might be interested.
The text was updated successfully, but these errors were encountered: