I'm not clear on the benefit here, why not just wrap the with expressions in a tuple for tagging? It's basically the same amount of code, doesn't require any new syntax, and accomplishes the same goal.
In my opinion with is already the most complex syntactic construct in the language, adding even more complexity for basically no additional benefit is something to avoid as much as possible. Paul On Sun, Jul 23, 2017 at 5:51 PM Burdock <[email protected]> wrote: > I feel like adding a new macro this similar to *with *would just bloat > the Elixir spec. That being said, adding shorthand for tagged matches would > be nice as long as it doesn't pollute the spec. > Personally, I don't like the idea of adding new syntax to describe this. > > That being said, if in Elixir 2.0's *with *used newlines instead of > commas to delineate sections, unwrapped keyword list syntax would be > usable. > > with all: {:ok, users} <- all: cashed_users() > best: {:ok, user} <- best: get_best_user(users) > do state > else all: {:error, msg} -> dostuff > best: {:error, msg} -> dostuff > > > This is existing syntax and is instantly recognizable by someone familiar > with Elixir. > > Personally, I think this is the best option. But as far as I am aware > there is no way to avoid the commas without moving everything after the > *do*. > > On Sunday, July 23, 2017 at 1:06:04 PM UTC-7, niahoo osef wrote: > >> Hi, >> >> I would like yo know your opinion about cunstructs like this one. I guess >> this is not a priority for Elixir, and I know I can add it to Hex.pm. I'm >> just unhappy with the `with` block and I want to know what you think. >> >> I made a simple implementation here : https://github.com/niahoo/ctrl >> with detailed information of the annotation feature. >> >> Basically it's a `with` block but with standard block syntax and match >> selection with tags : >> >> >> ctrl do >> {:ok, state} <- init() # Classic `with` >> clause >> %{id: id, opts: opts} = state # Any expression >> :ok <- register(id) >> :f_repo | {:ok, repo} <- Keyword.fetch(opts, :repo) # Tagged match >> :f_user | {:ok, user} <- Keyword.fetch(opts, :user) # Different tagged >> match >> {:ok, do_something(id, repo, user)} >> else >> {:error, _} = err -> err # Errors with info >> :f_repo | :error -> {:error, :no_repo_option} # Errors on :repo >> only >> :f_user | :error -> {:error, :user_not_set} # Errors on :user >> only >> end >> >> >> >> Thanks for reading :) >> > -- > 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/3c8eca18-fc6c-4317-a81b-5b83f4978279%40googlegroups.com > <https://groups.google.com/d/msgid/elixir-lang-core/3c8eca18-fc6c-4317-a81b-5b83f4978279%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-TtOjKozHKFbrmFr%2BcqqFq38PoNGyEihHk5LrKQ52Y8RsQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
