[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaMacro
- From: "steve donovan" <steve.j.donovan@...>
- Date: Thu, 3 Jan 2008 15:54:46 +0200
On Jan 3, 2008 3:40 PM, Fabien <fleutot+lua@gmail.com> wrote:
> The boundary between gratuitous syntax tweaks and support for a new paradigm
> is not always obvious to trace (to take a recurring example, would a switch
> statement be carcinogen syntax sugar, or would it substantially improve
> readability?)
It's a delicate balance. Macros were often necessary in C, because it
didn't have inlining and you could get a serious performance increase.
But C macros are not very intelligent, and were applied by people with
'arbitrary tastes'. So C++ people regard them as the work of the
devil. Lua is naturally fully polymorphic so a lot of the traditional
uses of macros aren't necessary.
Sometimes we have to try out some sugar, to see if it makes our life
easier. A candidate for that is try..except, since it makes a slightly
awkward syntax easier to use. Of course, it conceals the fact that
we're really creating a new closure for each try..except, and that
might bite you in performance-critical code. So this kind of macro
makes it easier to evaluate any Lua extension proposals.
Another use case is when implementing a DSL, to make the syntax fit
the domain more tightly. Then we are essentially making a specialized
Lua-based language.
Strangely enough, I am not fully convinced that lua macros are a good
idea ;) There are far too many Joe Random Hackers around - but on the
other hand, we should be rather restrained by good style than by a
simple 'No you can't do that!
steve d.