> >  - Powerful macros that cover the "needs to be efficient" cases as well
> >    as the various other macro scenarios. Definitely front-end!
>
> I do not understand the need for macros. Could someone explain?
> If you have polymorphic functions you basically don't need macros.
> But perhaps I misunderstand what a macro is in Rust.


Scheme has a very powerful macro system and it doesn't even have static
types. Macros abstract over whatever second-class features a language has.
In a non-polymorphic language, this includes types, but even the lambda
calculus has a second-class feature: binding. If you want to create a new
kind of 'let' or 'case' or 'lambda' construct (and Scheme people love doing
that kind of thing), you need macros. The surface syntax of the language is
also second-class, so macros can provide nicer surface syntaxes (for things
like printf and regexpes, for example). Macros are ideal for embedding
domain-specific languages.

Macros could be used to create what are effectively inline functions, but if
that's all the macro does, I'm really uncomfortable with the thought,
because we don't want to encourage that kind of behavior. I have this
terrible vision of programmers saying "Oh, use macros instead of functions,
they're faster.", and then writing code that is (a) terrible, since it uses
macros as if they were functions, and (b) slow, since the huge hunks of code
produced don't fit in the instruction cache.

Paul
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to