Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!lll-winken!elroy.jpl.nasa.gov!sdd.hp.com!wuarchive!udel!ee.udel.edu From: new@ee.udel.edu (Darren New) Newsgroups: comp.lang.modula3 Subject: Questions from a new advocate of Modula-3 Message-ID: <44046@nigel.ee.udel.edu> Date: 7 Feb 91 21:10:46 GMT Sender: usenet@ee.udel.edu Organization: University of Delaware Lines: 71 Nntp-Posting-Host: estelle.ee.udel.edu Maybe somebody out there can answer a couple of questions for me about Mod-3, especially if you have a running version (since all I have is the report): (Note: I can FTP to gatekeeper, so a pointer to the appropriate month were this was discussed would be enough. Thanks!) 1) The type of an expression is the set of all values the expression can take on. By definition, a constant expression can only take on one value. So if I declare something as PROCEDURE x(y := 6); does this not imply that the type of y is [6..6]? What is the type really, and why is it INTEGER instead of CARDINAL (if it is)? Should the report not say something about "base type" instead in this case? 2) The NEW expression's behaviour is not defined in the case that not enough memory is left. Is this a checked runtime error, or does it return NIL? If it returns NIL, then it isn't returning a "new" value. If it is a checked runtime error, how do you allocate all available memory without crashing? 3) A new variable is initialized to one of the members of the type. Does this mean that (say) a UNTRACED REF REAL could be initialized to point to any REAL anywhere in memory, or only to a REAL that has been actually allocated via NEW? I.e., if REALs must be on 4-byte boundries, could a newly-declared but otherwise uninitialized UNTRACED REF REAL point to *any* 4-byte-aligned quantity, or to any in the untraced heap, or to any previously-initialized real, or what? Does an initialized nonNIL REF necessarily point to initialized data? 4) BIT n OF t <: t -- I can accept that t <: BIT n OF t -- What about BIT 2 OF [0 .. 255]? Is this a static error, a checked runtime error, or implementation dependant? 5) Why try for generic packages given that objects can support generic types (like the Queue and IntQueue example)? 6) I would think that REAL <: LONGREAL, but that doesn't appear to be the case. 7) Has an "assert" capability been considered? Maybe preconditions and postconditions could be included. It seems like this would make for a much "safer" situation where an unsafe module exports a safe interface. Asserts in interfaces could help document the semantics of the interface. ------------ Then some comments: REFs should be defined to be initialized to NIL (unless explicitly initialized). This would catch more errors because a pointer that missed being initialized could not point to valid data possibly being used by some other module/thread/whatever. This would also prevent code which assumed that pointer are initialized to NIL (probably the vast majority of cases) from failing when it isn't (Holy VAXisms, batman!). An interface should be defined which specifies the ranges of integers, floats, etc. (Like LIMITS.H in ANSI C) --- Darren New --- Grad Student --- CIS --- Univ. of Delaware --- ----- Network Protocols, Graphics, Programming Languages, Formal Description Techniques (esp. Estelle), Coffee, Amigas ----- =+=+=+ Let GROPE be an N-tuple where ... +=+=+= -- --- Darren New --- Grad Student --- CIS --- Univ. of Delaware --- ----- Network Protocols, Graphics, Programming Languages, Formal Description Techniques (esp. Estelle), Coffee, Amigas ----- =+=+=+ Let GROPE be an N-tuple where ... +=+=+=