On Wednesday, 15 February 2012 at 20:55:47 UTC, Timon Gehr wrote:
<snip>
Lisp/scheme macros come to mind :)
=D. I actually thought about explicitly excluding those to get
a more meaningful answer. Using runtime code modification is
cheating.
There are certainly ways to dynamically dispatch, expand and
execute a macro in lisp. If every D program was allowed to
include a complete D compiler, virtual template functions would
work too. Can you point me to an implementation in lisp that
does this and is actually fast enough to be considered for real
work?
There are no issues AFAIK integrating
those with OOP, in fact the OOP features are implemented with
macros
(CLOS).
You can use templates to implement a multiple-dispatch virtual
function system just fine. We are not talking about
implementing OOP using templates, but about using templated
virtual methods.
Anyway, I don't see your point yet: You seem to think templates
are poorly designed because dynamic languages such as lisp are
more flexible than static languages such as D?
I'm no lisp expert and as such Google would be better than me to
point to specific implementations and such :)
regarding run-time modification of code - as I said, i'm no lisp
expert but I did hear about lisp AOT compilers so it should be a
matter of implementation. Another example which I'm more familiar
with is Nemerle macros which are closely related to Lisp macros
and follow similar design principles. In fact Nemerle macros are
separately compiled plugins for the compiler which can manipulate
the AST directly.
Regarding templated virtual methods - take a look at:
http://nemerle.org/wiki/index.php?title=Design_patterns