home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.acorn.tech
- Path: sparky!uunet!mcsun!fuug!funic!nokia.fi!newshost!charlie
- From: charlie@uk.tele.nokia.fi (Charlie Brown)
- Subject: Re: New Language/Compiler (ideas wanted)
- In-Reply-To: jwil1@cs.aukuni.ac.nz's message of Thu, 13 Aug 1992 20:55:28 GMT
- Message-ID: <CHARLIE.92Aug14134629@charlie.uk.tele.nokia.fi>
- Sender: usenet@noknic.nokia.fi (USENET at noknic)
- Nntp-Posting-Host: charlie.uk.tele.nokia.fi
- Organization: Nokia Telecommunications, Cambridge, UK
- References: <1195@grun.is> <1992Aug13.130618.18871@odin.diku.dk>
- <1992Aug13.205528.15434@cs.aukuni.ac.nz>
- Date: Fri, 14 Aug 1992 11:46:29 GMT
- Lines: 42
-
- jwil1@cs.aukuni.ac.nz (TMOTA) writes:
- >torbenm@diku.dk (Torben AEgidius Mogensen) writes:
- >
- >>Afeature I have sorely missed in compilers for C etc. is a cheap
- >>tail-call: if the last thing you do in a procedure or function is to
- >>call a procedure or function, this can be implemented as a goto rather
- >>than a general procedure/function call.
- >
- >What do you mean? What if the tail-called function then tries to call
- >another function or (even worse) recurses? This could only work if
- >the tail-called function expected to recieve *exactly* the stack frame
- >that the tail-caller has had set up when it was called.
-
- Maybe my brain has been rotted by using HPs for too long, but I'm sure
- that Norcroft C does tail call optimization (I'll give my Arc a break
- from being a Tertis and Icon server some time, and check it).
- Certainly lots of compilers (OK, I mean gcc) do it, and manage the
- necessary frame fiddling.
-
- It's occasionally useful for writing gross/cute things like:
-
- int countBits (int i, int acc)
- {
- return i == 0 ? acc : countBits (i & (i - 1), acc + 1);
- }
-
- (doubtless originally due to Martin Richards :-) I think Norcroft
- produces near identical code for the above and an equivalent explicit
- loop.
-
- On designing languages in general, if you're trying to produce a fast
- system language you could try something a bit like B (typeless C +/- a
- bit), which would be fun. Once you start integrating all those
- wonderful little features you love from Lisp and Icon and Eiffel et
- al, you tend to lose some of the elegance and simplicity you meant to
- achieve :-)
-
- Cheers,
- Charlie
-
- Anything approximating an opinion is my own
- and is not necessarily shared by my company
-