home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / acorn / tech / 40 next >
Encoding:
Internet Message Format  |  1992-08-13  |  4.3 KB

  1. Path: sparky!uunet!mcsun!sunic!dkuug!diku!torbenm
  2. From: torbenm@diku.dk (Torben AEgidius Mogensen)
  3. Newsgroups: comp.sys.acorn.tech
  4. Subject: Re: New Language/Compiler (ideas wanted)
  5. Keywords: Compiler/Language
  6. Message-ID: <1992Aug13.130618.18871@odin.diku.dk>
  7. Date: 13 Aug 92 13:06:18 GMT
  8. References: <1195@grun.is>
  9. Sender: torbenm@freke.diku.dk
  10. Organization: Department of Computer Science, U of Copenhagen
  11. Lines: 75
  12.  
  13. orion@grun.is (Halfdan Ingvarsson) writes:
  14.  
  15.  
  16. >Hiya folks...
  17.  
  18. >  Erm. I was thinking of writing a (sort of :) compiler using
  19. >my own language (a weirdo mixture of C, Pascal etc.. ) and I
  20. >am getting a little short of ideas. As I don't want to describe
  21. >it in whole, I'm gonna give you a general idea of what it shall
  22. >be..
  23. >  I'm going to make it very neat, small, fast and clean and
  24. >make it produce code that lives up to that. It's probably going
  25. >to be very Archimedes (yeah, yeah Ax000 too) specific, that is
  26. >not portable code. The reason for that is that I'm going to
  27. >implement SWI calls like procedure calls eg.
  28. ...
  29.  
  30. >So.. If anyone has some cool ideas or something dreamthings they'd like to
  31. >see in a compiler I'd be glad to hear from them.
  32.                                                       -Journal of Misfacts
  33. >P.S. If I had some idea about what (blush) Object Oriented code was like
  34. >(and no, I'm not talking about C++. It's crap) I'd also try to make this
  35. >language OO... So be it.. And no flame wars please >:-)
  36.  
  37. How about letting every statement also define a value, so that it can
  38. be used as an expression. For assignments, the obvious result is the
  39. assigned value. For if-then-elses the result of the succeeding branch
  40. is fine. For blocks, the result of the last statement, for procedure
  41. calls the value of the body etc.
  42.  
  43. This would get the effect of C's special expressions: a=e, (p ? q : r)
  44. (p , q) etc. and avoid the need for a return statement for functions.
  45.  
  46. The problems are if-then (without else) and while, as they might not
  47. execute their bodies at all. One could force else-branches to all if
  48. statements and add an else-branch to while, which will be used if the
  49. test fails initially. Alternatively, one could have a "null" value
  50. that would be returned in case the body is not executed.
  51.  
  52. Afeature I have sorely missed in compilers for C etc. is a cheap
  53. tail-call: if the last thing you do in a procedure or function is to
  54. call a procedure or function, this can be implemented as a goto rather
  55. than a general procedure/function call. Also, the local variables of
  56. the calling procedure need not be saved before the call, as they will
  57. never be used again. Note that this is not a laguage feature, but a
  58. compiler feature. This requires a callee-saves-registers strategy, but
  59. that is often the simplest anyway.
  60.  
  61. OO features can be (and has been) added in myriad ways. I prefer the
  62. original idea, where every object carries its own methods.
  63. Essentially, an object is a record of values (fields) and procedures
  64. (methods). To save space, the methods can be collected in a record
  65. that is referred to by a pointer in the object record. This allows the
  66. methods record to be shared by all objects in the class. A class
  67. consists of a methods record and a "make" procedure that takes some
  68. initial arguments and returns an object by setting the fields
  69. according to the arguments and setting the method pointers to the
  70. class' own method record.
  71.  
  72. Apart from typing problems, OO can be easily simulated if you allow
  73. procedures as general values that can be stored and passed as
  74. arguments. If you (like C) have no nested procedure definitions, a
  75. pointer to the execution address is enough to represent a procedure.
  76. If you have nested procedure definitions, you need also the
  77. environment in which the procedure is defined. Pascal does this, but
  78. only allows procedures as parameters, not as stored objects etc. The
  79. reason is that the environment that a procedure value refers to might
  80. not exist at the time it is called.
  81.  
  82. OO is interesting for the Arc mainly for desktop programming: you can
  83. define a window-class that has methods for the messages that the
  84. desktops returns from a polling call. In the broadest class all the
  85. mask bits are set and most methods are null methods. When defining a
  86. subclass, some mask bits are unset and the corresponding methods
  87. defined. The remaining methods are inherited from the superclass.
  88.