With do(:)?

(if pref left right)

It may be worth providing some additional context when re-starting the conversation.

1 Like

My goal here was not exactly to restart the conversation. I was just making a low effort joke about Lisp being the perfect language and all that. Writing more than I did risked explaining the joke :slight_smile:

If you feel this is not an apropriate post for this topic, feel free to delete it (as this one lol, which does little more than explaining the joke).

1 Like

You know…

defmacro if(pred, left, right) do
  quote do
    Kernel.if(unquote(pred), do: unquote(left), else: unquote(right))
  end
end

and then:

if(pred, left, right)

:slight_smile:

4 Likes

Sure :slight_smile: I’m aware you can do anything you want in elixir that you could do in Lisp, except read macros, and even for read macros you always have sigils, so yeah, pretty much everything. And Lisp macros support variable numbers of arguments.

Elixir’s macro system is great (and very hygienic), so I don’t really have many complaints.

For someone with some experience with macros, elixir macros are very simple to use, because the concrete syntax mals in a very simple way into the AST. It’s very counterintuitive, though, and it might hurt beginners. But once you understand the AST representation, writing macros is a breeze.

You know that would be an awesome addition to Kernel! An if/3, it would make ternery operations easier (it is amazing the number of times I keep doing if(pred, left, right) in my view’s, forgetting the do:/else:). :slight_smile:

So can Elixir’s via lists or so, or via blocks (which is why it bugs me that for/with are so inconsistent, they should have used one of those methods). :wink:

It is, they are so blissful to use, they easily make me overlook the language syntax (^.^;). :slight_smile:

Though I came from Erlang’s Parse Transforms… yeah not as easy… >.>