Is there a reason for the LCHF approach to syntactic sugar?

This topic is about syntactic sugar that I find missing. I know that these tasks are not hard to accomplish in other ways.

I often find that my assumptions about what functions extend to what types, are wrong.

I wonder if there is a special reason for what I naïvely think of as lacunae in julia, or is it just that nobody got around to it?

Here’s an example. I knew I could iterate over a Flux.chain (e.g. for layer ∈ myfluxchain) so I tried the same with Flux.parallel and discovered that that doesn’t work.

I sometimes find myself patching such holes, but perhaps there are reasons I haven’t thought of why I shouldn’t.

For completeness, here is the (admittedly trivial) “patch”:

function Base.iterate(p::Flux.Parallel, s = nothing)
    ks = keys(p)
    if isnothing(s)
        rv = iterate(ks)
        rv = iterate(ks, s)
    if isnothing(rv)
        return nothing
    k, s = rv
    return (p[k], s)

Do you mean isempty? (Which is already defined). Empty creates an empty collection.


Sometimes the explanation is that easy. Thanks for pointing it out!

The question still stands (I should try to remember some better examples), but the title is completely misleading so I should bring it up in a new and better researched topic. Regard this topic as closed!

1 Like