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

**URL:** <https://discourse.julialang.org/t/is-there-a-reason-for-the-lchf-approach-to-syntactic-sugar/99607>\
**Category:** General Usage\
**Tags:** question, syntax, flux\
**Created:** [May 30, 2023, 2:06pm UTC](https://discourse.julialang.org/t/is-there-a-reason-for-the-lchf-approach-to-syntactic-sugar/99607 "2023-05-30T14:06:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Euhan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/euhan/32/36548_2.png) [@Euhan](https://discourse.julialang.org/u/Euhan)\
**Post date:** [May 30, 2023, 2:06pm UTC](https://discourse.julialang.org/t/is-there-a-reason-for-the-lchf-approach-to-syntactic-sugar/99607/1 "2023-05-30T14:06:24Z")

</div>

**Preamble/Disclaimer** :  
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 naï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”:

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

```

---

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [May 30, 2023, 2:13pm UTC](https://discourse.julialang.org/t/is-there-a-reason-for-the-lchf-approach-to-syntactic-sugar/99607/2 "2023-05-30T14:13:40Z")

</div>

> [@Euhan](#):
>
> ```julia
> Base.empty(s::AbstractString) = length(s) == 0
> 
> ```

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

---

<div class="post-metadata">

**Author:** ![Euhan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/euhan/32/36548_2.png) [@Euhan](https://discourse.julialang.org/u/Euhan)\
**Post date:** [May 30, 2023, 2:20pm UTC](https://discourse.julialang.org/t/is-there-a-reason-for-the-lchf-approach-to-syntactic-sugar/99607/3 "2023-05-30T14:20:40Z")

</div>

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!
