home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / acorn / tech / 47 < prev    next >
Encoding:
Text File  |  1992-08-14  |  2.3 KB  |  57 lines

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