> The `with` block is not that complicated, we could even think about
adding support for left arrow notation, the `with` block beeing just a
specific case

It's not complicated for those of us who have the benefit of already
knowing the language inside and out, but it is absolutely a complicated
construct for new users of the language - it combines several new and old
concepts, a unique arrow notation (like `for`, but different), pattern
matching in the else block (like `try`, but new to anyone coming from other
languages or unaware that they can use else there), the semantics of how it
handles failed matches is also unique (and of course the reason why it
exists at all), you have to know that expressions are comma separated, not
broken up by newlines, and there are other small details one has to learn.
It's one of the most powerful constructs in the language, and important to
learn, but adding yet another layer to it makes it feel overloaded to me,
it will be confusing to beginners trying to read code using it (and they'll
likely already be confused when they see it initially). Once you are
familiar with it, it's no problem, but it's very important to consider that
aspect. Constructs should compose so that as you learn the basics, more
complex constructs can be seen as building on what you've learned to
provide more expressive power - they slowly reveal themselves as you learn
the basics so that by the time you get to it, you already have a grasp of
what it probably does and what problem it solves (or at least that's the
ideal in my mind)

My main beef with this is that the tags concept would only be used here - I
can't see any other place where it could be applied, and everything else
about `with` is present in at least one other area of the language. In my
opinion that's what makes this proposal seem out of place. Additionally the
syntax is used in typespecs to represent alternations. That alone isn't a
huge deal, but will lend to confusion around what the syntax is trying to
express. If anything I'd think `pattern :: tag` would be a better fit for
the syntax, since it's annotating something, much like we do with the bit
syntax and in typespecs. Even with that change though, I don't think it
really fixes the issues I've raised.

I agree that tagged tuples are not as succinct,  but they are easy to
understand, and they aren't *that* verbose. Is it really worth making an
already complex construct even more so for relatively little gain?

I think it's an interesting idea anyway, and at the very least made me
wonder how I'd want to solve it, and that's always a fun exercise :)

Paul

On Mon, Jul 24, 2017 at 3:09 AM niahoo osef <[email protected]>
wrote:

> "Why not just wrap the expressions in a tuple ?" Well because you have to
> wrap both sides and mess with those commas, which is annoying for editing
> code and adds noise for the reader. Tags, on the other side, are clearly
> identified as tags, a branching mechanism that is separated from the
> expressions you want to match.
>
> The `with` block is not that complicated, we could even think about adding
> support for left arrow notation, the `with` block beeing just a specific
> case
>
> "I feel like adding a new macro this similar to *with *would just bloat
> the Elixir spec." Well I was more thinking about extending with (allowing
> this syntax when used in the do block) instead of adding a new block.
>
> Using keyword notation wraps everything in lists, I think it's way less
> clear.
>
> Thank you both for comments :)
>
> --
> You received this message because you are subscribed to the Google Groups
> "elixir-lang-core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elixir-lang-core/cc528045-5c18-44fc-99cc-71f787db0632%40googlegroups.com
> <https://groups.google.com/d/msgid/elixir-lang-core/cc528045-5c18-44fc-99cc-71f787db0632%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CAK%3D%2B-TuBvyjLTn1eZatx3OLT4Vs4rKqh3VWjcbGn%3DpHEgaAQFA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to