I read this at OSDEV.org.
Bye.
Yes, but the question was about C--, not C++.aladdin wrote:I think there is many 32b kernels in C++
Just a thing I noticed, c-- seems to have a special explicit tail-call mechanism. Why is this?Wishmaster wrote: Hi, i have heard that someone has written a 32bit OS in C--. But i dont know who. I wanted to ask, wheter he can send me the source, because i try to create a 32bit OS in C--
![]()
I read this at OSDEV.org.
Bye.
To make the compiler's job easier? Fear that the optimizer might miss it otherwise?Candy wrote:Just a thing I noticed, c-- seems to have a special explicit tail-call mechanism. Why is this?
Oops -- even more specifically, it was about Sphinx C--, which, as it turns out, is not the same as cminusminus.org's C--. Ignore my last link, try this instead:Dreamsmith wrote:Yes, but the question was about C--, not C++.
Code: Select all
int foo() {
return foo();
}
Code: Select all
Indeed, one would hope so. I assume the thrust of Candy's question was on the word explicit, as the benefits of tail call optimization are fairly well known. Why must it be explicitly requested in C--, rather than simply handled by the optimizer as in higher level languages?Solar wrote:I'm a bit confused here. I would expect any decent C/C++ compiler would be capable of optimizing away tail-recursion at a moderate optimizer setting?
I'll take a look. I can't quite recall that rant, but I agree that Lisp is nicer intermediate form. I have a Lisp compiler on the works, which works by source-to-source transformations, mostly evil amounts of lambda's. Nothing really new though, quite similar to Orbit, Twobit and such.. Infact, my intermediate language isn't even quite Lisp: it's more or less just call-by-value lambda-calculus with primitive functions.Schol-R-LEA wrote: PS: Mystran, if you haven't already done so, you might want to take a look at the thesis paper, especially the part about Register Transfer Language. Remember my mini-rant about how it would make more sense to compile C into a Lisp-like AST language rather than compiling Lisp into C? Well, if I'm reading this right, that is what gcc actually does!
I don't know. What I currently do is compile stuff into lambda-nodes of form: (lambda args call) where args is Scheme like argument list and call is of form (a b c ... d) where all the members are either symbols or lambda-expressions.It occurs to me that if there were options to emit RTL code (or a binary representation thereof), and accept it as input later, you'd effective have a portable intermediate language similar to the 'slim binaries' used in Oberon: a partially compiled, (mostly) portable, language-independent representation which could be used with a JIT final compiler, which could furthermore do both safety checking and localized optimization. Put that in Java's pipe and smoke it!
The particular method I'm using is described in at least:I'm sure someone else has thought of it before though - it's a pretty old idea - which means there are probably reasons why it would be practical.
ups, i didn't read thisOops -- even more specifically, it was about Sphinx C--, which, as it turns out, is not the same as cminusminus.org's C--. Ignore my last link, try this instead:
http://www.goosee.com/cmm/