Not that I’ve ran across, but it would be fairly simple to build a let
macro though, I could imagine this syntax for it:
let add a b = a+b
The in
is a keyword in elixir so it would not work at the end of the context there, but ‘end-of-line’ would work well, just could not do multiple let
s on a single line, plus the function call syntax would not be quite functional (ML’ish), I.E. you could not do this with macros:
let blah a = vwoop 42 a
But instead you’d have to do this weirdness:
let blah a = vwoop 42, a
And nowadays that will puke warnings (rightfully so considering uniformity with the rest of the language), so instead you would have to do this algol-looking ugliness:
let blah a = vwoop(42, a)
You’d also have to use a different call for in-function definitions as well, maybe letl
or let local
or so:
def blah(a), do
letl min l r = if l < r, do: l, else: r
min.(42, a)
end
Although ‘maybe’ you could get away with the macro detecting the details of the environment it is called in and adjusting accordingly to return either a def
declaration or a variable and anonymous function declaration? Or force any local let
s to be within an outer let
?
This does however give me an idea for an entire ML’ish syntax macro library for elixir, though unsure if it should actually be used, probably just be an interesting fun project. ^.^
/me has tried very hard not to go off on Elixir’s syntax again, not a fan of the syntax and lack of types, but loves the macro system… ^.^