home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 10 / Fresh_Fish_10_2352.bin / new / dev / obero / oberon / oberon-faq-language.doc < prev    next >
Text File  |  1995-03-07  |  13KB  |  238 lines

  1. Newsgroups: comp.lang.oberon,comp.answers,news.answers
  2. Path: bloom-beacon.mit.edu!gatech!europa.eng.gtefsd.com!library.ucla.edu!psgrain!m2xenix!mikeg
  3. From: mikeg@psg.com (Mike Gallo)
  4. Subject: Comp.lang.oberon FAQ (monthly) 2/3
  5. Expires: Fri, 20 Jan 1995 00:00:00 GMT
  6. Reply-To: mikeg@psg.com
  7. Organization: PSGnet, Portland Oregon US
  8. Date: Tue, 20 Dec 1994 14:06:18 GMT
  9. Approved: news-answers-request@MIT.Edu
  10. Message-ID: <1994Dec20.140618.27037@psg.com>
  11. Followup-To: comp.lang.oberon
  12. Summary: This posting contains a list of Frequently Asked Questions (and their answers) about Oberon.  It should be read before posting to the Comp.lang.oberon newsgroup.
  13. Lines: 221
  14. Xref: bloom-beacon.mit.edu comp.lang.oberon:3511 comp.answers:9055 news.answers:31596
  15.  
  16. Archive-name: Oberon-FAQ/language
  17.  
  18. (*  * *  * *  * *  * *  * *  * *  * *  * *  * *  * *  * *  * *  * *  * *  *)
  19.  
  20. Many FAQ lists, including this one, are available by anonymous ftp from rtfm.mit.edu in the /pub/usenet/news.answers directory.
  21.  
  22. Although I have aimed for accuracy, there is no guarantee that the information in this document is error-free.  Neither the FAQ maintainer nor anyone else associated with this document assume any liability for the content or use of this document.  If you find any errors, please report them to the address below.
  23.  
  24. Thanks to all who have contributed!  Further additions, corrections, and suggestions are welcome.
  25.  
  26. mikeg@psg.com
  27.  
  28. (*  * *  * *  * *  * *  * *  * *  * *  * *  * *  * *  * *  * *  * *  * *  *)
  29.  
  30. Comp.lang.oberon Frequently Asked Questions: The Programming Language
  31.  
  32. Copyright 1994 Michael Gallo
  33. (c) 1994 Michael Gallo
  34.  
  35.  
  36. This is one of three documents that attempt to answer some frequently asked questions (FAQs) about Oberon.  This text concerns the Oberon languages, while the other two are about general topics and about Oberon the operating system.
  37.  
  38.  
  39. THE PROGRAMMING LANGUAGE OBERON 
  40.  
  41. >From "From Modula to Oberon"
  42.     The programming language Oberon is the result of a concentrated effort to increase the power of Modula-2 and simultaneously to reduce its complexity. Several features were eliminated, and a few were added in order to increase the expressive power and flexibility of the language. This paper describes and motivates the changes. The language is defined in a concise report.
  43.     Whereas modern languages, such as Modula, support the notion of extensibility in the procedural realm, the notion is less well established in the domain of data types. In particular, Modula does not allow the definition of new data types as extensions of other, programmer-defined types in an adequate manner. An additional feature was called for, thereby giving rise to an extension of Modula.
  44.     The evolution of a new language that is smaller, yet more powerful than its ancestor is contrary to common practices and trends, but has inestimable advantages. Apart from simpler compilers, it results in a concise defining document, an indispensable prerequisite for any tool that must serve in the construction of sophisticated and reliable systems.
  45.  
  46. Among the eliminations in the move from Modula-2 to Oberon are variant records, opaque types, enumeration types, subrange types, the basic type CARDINAL, local modules, and Modula's WITH statement.  The major addition to Oberon is the concept of type extension (i.e., single inheritance) for records.
  47.  
  48.  
  49. OBJECT ORIENTED PROGRAMMING IN OBERON
  50.  
  51. Oberon does not offer multiple inheritance.  However, it has been shown that multiple inheritance can be efficiently implemented in terms of single inheritance and been argued that multiple inheritance is therefore syntactic sugar that is rarely used in practice.  For details, see Templ (1993) and Mssenbck (1993). 
  52.  
  53. The original Oberon language does not offer built in "methods" as do many other languages supporting OOP.  Instead, conventional virtual methods can easily be implemented as a pointer to a procedure table, or "messages" can be sent to procedures as extensible records.  
  54.  
  55. While some people complain about Oberon's minimalistic support of object oriented programming, others feel that this is one of Oberon's strengths, that the language does not institutionalize aparticular approach to OOP (see the Comp.object FAQ list for an examination of several variations on the object oriented paradigm).  For another discussion, see Oberon2.OOP by H. Mssenbck.  
  56.  
  57.  
  58. THE PROGRAMMING LANGUAGE OBERON-2
  59.  
  60. >From "Differences between Oberon and Oberon-2"
  61.     Oberon-2 is a true extension of Oberon. . . .
  62.     One important goal for Oberon-2 was to make object oriented programming easier without sacrificing the conceptual simplicity of Oberon. After three years of using Oberon and its experimental offspring Object Oberon we merged our experiences into a single refined version of Oberon.
  63.     The new features of Oberon-2 are type-bound procedures [i.e., virtual methods], read-only export of variables and record fields, open arrays as pointer base types, and a with statement with variants. The for statement is reintroduced after having been eliminated in the step from Modula-2 to Oberon.
  64.  
  65.  
  66. THE "OBERON FAMILY" OF LANGUAGES
  67.  
  68. Mona is an experimental dialect (but not a superset) of Oberon which provides recursive data types (trees) as a first class data-structure.  It attempts to reduce reliance on pointers and to offer a faster alternative to automatic garbage collection.  For details, see ETH technical report 102.
  69.  
  70. Oberon-V is an experimental dialect (but not a superset) of Oberon.  It is concerned with issues of numerical computing, array processing, and code verification.  It's primary new features are the ALL statement (much like a parallel version of the FOR loop) and array constructors for open array parameters.  Since it was originally aimed at vector architectures in general and the Cray Y-MP in particular, no Oberon-V compiler has been implemented for the Oberon System.  For details, see Griesemer (1993).
  71.  
  72.  
  73. COMMON PROBLEMS PROGRAMMING IN OBERON
  74.  
  75. On numerical programming:
  76.  
  77. whitney@christie.Meakins.McGill.CA (Whitney de Vries) writes:
  78.     The gist of the situation is that numeric expressions [can be] too complex for the backend of the Oberon for Windows compiler. . . .  Complex expressions ( particularly those with floating point operations ) quickly exhausts the short supply of registers on the Intel chips. At this point it is worth noting that the ETH supports Oberon for Windows but does not consider the Intel chips to be an intresting research topic ( the answer to the Intel problem is to have more registers ).  I think it is unlikely t
  79. hat Intel compiler will ever be as robust as the POWERoberon compiler.
  80.     At any rate you will probably get your code to work if you simplify the expressions.
  81.  
  82.  
  83. The WITH statement:
  84.  
  85. "This [compiler error] has to be a bug, correct me if I'm wrong! (I'm going nuts over this)"
  86.  
  87. TYPE
  88.     Obj* = POINTER TO Empty;
  89.     Empty = RECORD (*nothing*) END;
  90.  
  91.     OpObj = POINTER TO OpNode;
  92.     OpNode = RECORD (Empty)
  93.         name : CHAR;
  94.         left, right : Obj;
  95.     END;
  96.  
  97. PROCEDURE doeval (ex: Obj): REAL;
  98.     BEGIN
  99.         WITH ex : OpObj DO
  100.             CASE ex.name OF
  101.                 "+" : RETURN doeval(ex.left (* err 113 *)) 
  102.                     + doeval(ex.right (* err 113 *));
  103.                 "-" : (* clever code here *)
  104.                 "*" : (* more clever code *)
  105.                 "/" : (* you get the idea *)
  106.             END;
  107.             (* et cetera *)
  108.         END;
  109.     END doeval;
  110.  
  111. Error #113 is an "incompatible assignment".  ex.left and ex.right certainly seem to be of type Obj.  Why won't doeval accept them?
  112.  
  113. As thutt@clark.net (Taylor Hutt) points out,
  114.     This is not a bug.  The WITH statement actually changes the static type of the WITHed variable for the entire duration of the WITH statement.  A workaround to this problem is to assign the parameter to a temporary variable and to use the WITH on the temp.  A type guard will not work properly in this case, do not attempt to use it.
  115.  
  116. Some people on Comp.lang.oberon think that the WITH statement should be avoided entirely because of its non-local effects.  They point out that a programmer can use individual type guards or, if a guarded variable is used very many times, can pass the variable to a procedure.
  117.  
  118.  
  119. BIBLIOGRAPHY
  120.  
  121. Sources cited in the FAQ list that are not listed in the bibliography are elec