On 22 Feb 2014 12:43, "Anthony Ramine" <n.o...@gmail.com> wrote:
>
> Erlang is made to be boring. Boring means that it needs to be brain dead easy to comprehend. Brain dead easy means no macros.
Sorry, but -define () macros can be just as confusing as lispy ones... I would gladly trade them away.
/Vlad
On 22 Feb 2014 13:14, "Anthony Ramine" <n.o...@gmail.com> wrote:
>
> Sorry but no. I know I am reading a macro call with epp macros. I don’t know that in a language using s-expressions.
There's nothing to stop the syntax to require special names for macros, it doesn't have to be lisp.
> And people use preprocessor macros rarely.
You'd be surprised :-)
/vlad
Miles Fidelman
Vlad Dumitrescu wrote:
>
>
> On 22 Feb 2014 13:14, "Anthony Ramine" <n.o...@gmail.com
> <mailto:n.o...@gmail.com>> wrote:
> >
> > Sorry but no. I know I am reading a macro call with epp macros. I
> don’t know that in a language using s-expressions.
>
> There's nothing to stop the syntax to require special names for
> macros, it doesn't have to be lisp.
>
> > And people use preprocessor macros rarely.
>
> You'd be surprised :-)
>
> /vlad
>
> > --
> > Anthony Ramine
> >
> > Le 22 févr. 2014 à 12:58, Vlad Dumitrescu <vlad...@gmail.com
> <mailto:vlad...@gmail.com>> a écrit :
> >
> > > Sorry, but -define () macros can be just as confusing as lispy
> ones... I would gladly trade them away.
> > >
> > >
> >
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-q...@erlang.org
> http://erlang.org/mailman/listinfo/erlang-questions
--
In theory, there is no difference between theory and practice.
In practice, there is. .... Yogi Berra
On 02/22/2014 10:14 AM, Maxim Velesyuk wrote:
> Often when I feel I need to change ast I remember how clumsy and
> uncomfortable parse transform is, so I overcome myself and make workarounds.
Why do you even feel the need to change the AST? Don't do that.
> But macros are still useful, programmers use parse transform when they
> have no other choice, and projects like merl appear.
Macros are not useful. Macros are what makes a perfectly readable
program into the worst spaghetti code you have ever seen. Even EPP
macros, which look pretty harmless as they have very limited
capabilities, can make things a lot worse than it needs to be.
Sure macros allow you to write less code. But I spend 90% of my time
reading code, so I like programs that are optimized for my reading. If I
always need to refer to some other source file or document to understand
what the code is doing, then I am not going to be using your program
very long.
Macros make your programs worse than PHP and Java combined.
> List and zip comprehensions could be implemented as macros, ets and
> mnesia query language is actually prefix-notation language with code
> quoting, even pattern matching and so long expected maps could be just a
> libraries.
And then one person creates maps, another creates frames, both with the
same or similar syntax but with different semantics, both get used in
the same system, and the code is completely unreadable. No thanks.
> Take a look at c++ and java, how they suffer from inventing new syntax.
> Hopefully Erlang will not turn in such syntax-monster. It has syntax for
> many things, but it still not as flexible as it could be.
>
> This forwards me back to my first question, why?
You don't need it.
--
Loïc Hoguin
http://ninenines.eu
--
Anthony Ramine
> Le 22 févr. 2014 à 17:31, Vlad Dumitrescu <vlad...@gmail.com> a écrit :
>
> There's nothing to stop the syntax to require special names for macros, it doesn't have to be lisp.
If it doesn't need to be Lisp, why does it need S-expressions?
I beg to differ. file:read_file/1 is pretty obvious. So is lists:map/2.
So is most of the functions you can read in your code. You don't need to
know the internals of a function or even the full spec when you are
reading code, you know that you are reading a file, or mapping a
function over a list. When you have macros, you don't even have any idea
whether what you are calling is a function or something else entirely.
And when you have macros that are being used to create new syntax? Then
it is completely alien to all the code around it.
> >And then one person creates maps, another creates frames, both with
> the same or similar syntax but with different semantics, both get used
> in the same system, and the code is completely unreadable. No thanks.
>
> Macros are dangerous as much as powerful. If programmer does not use
> them correctly its a programmer's fault. In the end who is the target
> audience of a programming language for concurrent, fault tolerant
> systems? Probably the programmer who understands what he does. Should
> language designer force programmer to write code in 'correct' way? I
> don't know, but valuable spaces and programming patterns appeared from
> such ideas.
Hello elitism! I mean, seriously? You aren't using Erlang because you
are a better person. You are a better person because you are using
Erlang, because it gives you the tools to do things that are difficult
to do in other languages. Don't dismiss other people simply because they
don't have the chance to work with Erlang.
I will point out though that the target audience of any code, regardless
of the language it is being written in, is the *reader*. It's not the
programmer who wrote it. It's not the compiler. It's the many guys that
will come afterward, read the code, fix bugs, maintain it. If your code
is just using Erlang, then it's pretty easy for them to see what is
going on. If you have changed all the rules using macros, then they need
to learn more things before they can become productive with your code.
They will not like you for it, especially if the production system is
down and they have to fix the bug quickly.
> >You don't need it.
>
> Who but the particular programmer can decide what does he need and what
> doesn't ?
You don't decide what you need. You need it. That's it. If you can do
without and still meet your requirements and deadlines, then you don't
need it, it's just luxury. Except in this case it's luxury similar to
having snakeskin boots, you get what you want, but at the cost of the
blood of the people that will come after you.
Best regards,
Mikhail Gusarov.
There is Lisp. And then there is Scheme.
On 23/02/2014, at 10:33 AM, Mikhail Gusarov wrote:
>> But when you see unknown function you still have no idea what it does and
>> you have to figure it out. Any abstraction works in same way.
>
> There is subtle difference: all functions conform to the function
> abstraction: function does not alter/capture names from calling
> namespace and function does not arbitrarily transfer control. Function
> is a simple abstraction: it accepts arguments and returns result.
Scheme define-syntax macros do NOT alter/capture names from
the calling namespace. They are said to be "hygienic."
Thanks to throw/1, function calls CAN transfer control.
(The Scheme analogue is call-with-current-continuation.)
So a Scheme-flavoured-Erlang would conform to the claimed
abstraction every bit as well as Erlang without any kind of
macros.