Re: c macros -- turing complete?
- From: Pascal Bourguignon <pjb@xxxxxxxxxxxxxxxxx>
- Date: Sun, 29 Oct 2006 17:27:16 +0100
"Jimka" <jimka@xxxxxxxxx> writes:
I'd like to make a claim in an article i'm writing:
The lisp macro facility is Turing complete, whereas the C macro system
is not.
Does anyone know whether that is a correct statement?
If cpp is not Turing Complete, it's very close...
You can do loops including the current file,
you can change the state with #define and #undef,
and you can test with #ifdef and #if.
Unfortunately, #define cannot compute:
#define a 42
#define a ((a)+1)
doesn't make a = 43
Theorically, you can test with #if a = 43, and macros are expanded here,
but since a is defined in terms of a, you don't get ((42)+1) but ((a)+1)
and this is not equal to 43, but to 1.
And #if can test only integer values, not strings, so you cannot fall
back to even simple string processing.
Perhaps we can do something with just #define and #ifdef, but it's
harder to test for equality.
Finally, if may hit the very small limits there are in cpp, like 200
levels of #include max, etc.
Is a computer with so little memory you cannot even implement a TM in
it still TC, even ignoring the "unlimited tape length"?
--
__Pascal Bourguignon__ http://www.informatimago.com/
CAUTION: The mass of this product contains the energy equivalent of
85 million tons of TNT per net ounce of weight.
.
- Follow-Ups:
- Re: c macros -- turing complete?
- From: Brian Downing
- Re: c macros -- turing complete?
- References:
- c macros -- turing complete?
- From: Jimka
- c macros -- turing complete?
- Prev by Date: Re: Why is Lisp attacked on Reddit almost as often as Republicans?
- Next by Date: Re: allegro cl installer -- A.I built in, all the way DOWN
- Previous by thread: Re: c macros -- turing complete?
- Next by thread: Re: c macros -- turing complete?
- Index(es):
Relevant Pages
|