
Simon Buchan wrote:
Jonathan Turkanis wrote:
Simon Buchan wrote:
Jonathan Turkanis wrote:
... It would be nice to have a truly formal specification, but in the case of C++ it's probably not realistic.
I do think it's possible
(If it wasn't, we wouldn't be able to write compilers for it!),
That's like saying: Of course it must be possible to provide a formal semantics for English -- otherwise I'd never be able to understand the instructiosn that come with my coffee maker :-)
Can you?
Okay, I was exaggerating. I should have picked a simpler example.
If so, English (or more precisely, the subset used in the instructions) can be formally defined (in fact, you can find programs that do).
I think it's possible to come pretty close, but nobody knows how to do it yet.
The problem with natural languages is that they have a symbol table with trillions of entries, and that table is dynamicly generated based on the situation the compiler (ie, you) is in.
What are the trillions of entries?
but remember the standard has basicly grown out of rewordings from the days of C (which did likewise back to B, etc...) I think a formal, but human-readable, grammar, kind of like EBNF for semantics, would be useful here.
It would be very useful (except I'm not sure what you mean by "kind of like EBNF for semantics")
Think algebra for syntax. That's EBNF. I don't know of any generalised definition of semantics
I don't think there is one.
(Turing machines don't count, 'cause they arn't human-readable (even the definition of Turing machines arn't!), and Lambda Calculus isn't general enough.) that would be useful, but feel free to correct me.
I'd settle for unreadable semantics. -- Jonathan Turkanis www.kangaroologic.com