Sorry if the discussion bellow may seem a little bit vague, but there is too much to say.
I have only theoretical knowledge of Lisp, not hands on.
On the other side, Forth could have (but normal Forth hasn't) a complete metaprogramming inside the language. But metaprogramming is contemplated and possible but without a coherent syntax. I think the same happens in Lisp.
I have implemented a very clean solution with includes that possibility in a small paradigm of Forth like language. In order to have metaprogramming we should be able to refer to what we write. So when we write a program to be executed immediatelly as:
bread eat
we should be able too to refer to the same phrase with the intent instead of executing it to keep it for later reference. That could be done writing e.g.
{ bread eat }
The phrase above could have as consequence to leave the created object on the stack. But as we created a new word as {
and }
we have the right to refer to that too.
So, we could like to refer to:
{ bread
How could we refer to that ? A tentative syntax is: {{ { bread }}
.
If we give the name XXX
to the previous phrase we could write the initial phrase as:
XXX eat }
and the phrase above should work correctly in leaving on the stack the
{ bread eat }
As I don't know if what I say is exactly what are you looking for let it suffice to say that by the above reasoning and their implementation inside Forth each word gets an execution level and that defines which is the level of metaprogramming of the word.
Obviously, we have the first infinity level and every successive level. So execution levels are based on the mathematical infinity.
I have implemented the above inside a kind of Forth and at the first level (bellow infinity) everything works smoothly. So for example a am able to change the syntax of:
{ bread eat } { tomatos eat } x 3 = if
into:
{ bread eat | tomatos eat } x 3 = if
That is done by defining |
as } {
as bellow:
{{ } { }} "|" define
or if you like it better as:
2{ } { 2} "|" define
The method above takes inside the language with a correct syntax the meta language and makes it language.
So in my opinion, both Lisp and Forth have the possibility of metaprogramming, but both lack that possibility as an integrating part of the language.
I have more details on that on napl.wikispaces.com.
LANG1
you can't implementfoo
, which has been implemented inLANG2
, because you lackbar
, whichLANG1
has andLANG2
has not." In the Why are some questions marked "on hold"? there is no mention of "too many answer" as a reason questions should be closed. – user3750103