dww@math.fu-berlin.de (Debora Weber-Wulff) (05/27/91)
The question came up in class today: Why is there no ** or ^ (x to the nth power) operator in standard Modula2? To make you start your own private module collection of goodies? Because it is machine dependant??? We checked the 3 books we use in class and found no mention of why this is missing. -- Debora Weber-Wulff snail: FU Berlin, ZI Fachdidaktiken, Habelschwerdter Allee 45, W-1000 Berlin 33 email: weberwu@inf.fu-berlin.de, dww@math.fu-berlin.de
sakkinen@jyu.fi (Markku Sakkinen) (05/28/91)
In article <1KBRSVP@math.fu-berlin.de> dww@math.fu-berlin.de (Debora Weber-Wulff) writes: >The question came up in class today: Why is there no ** or ^ >(x to the nth power) operator in standard Modula2? >To make you start your own private module collection of goodies? >Because it is machine dependant??? > >We checked the 3 books we use in class and found no mention of >why this is missing. Simple: When designing Pascal, Wirth considered the exponentiation operator not to be utile enough to justify its cost in the language. I think the rationale can be read in his old books or articles (early 70's). Someone else (more arithmetically minded) would probably have done the opposite decision, and omitted some triviality like 'odd' instead. Modula2 has been designed with somewhat minimalistic tendencies (although comparing to Oberon, maybe even "somewhat minimalistic" is an overstatement). Therefore, any new feature certainly needed very strong reasons for addition. As regards arithmetic features, Modula2 has long reals (and long integers), for whose lack Pascal had been sharply criticised. Markku Sakkinen Department of Computer Science and Information Systems University of Jyvaskyla (a's with umlauts) PL 35 SF-40351 Jyvaskyla (umlauts again) Finland SAKKINEN@FINJYU.bitnet (alternative network address)
kgs@dvncnms.Devoncnms.Unisys.COM (Ken Salter) (05/28/91)
In article <1KBRSVP@math.fu-berlin.de> dww@math.fu-berlin.de (Debora Weber-Wulff) writes: >The question came up in class today: Why is there no ** or ^ >(x to the nth power) operator in standard Modula2? I speculate that Modula2 contains no exponentiation operator for the same reason that Pascal (as defined Jensen and Wirth in "Pascal User Manual and Report, second edition, Springer-Verlag 1978") contains no exponentiation operator. The beginning of the "Report" on page 133 states: The development of the language Pascal is based on two principal aims. The first is to make available a language suitable to teach programming as a systematic discipline based on certain fundamental concepts clearly and naturally reflected by the language. The second is to develop implementations of the language which are both reliable and efficient on presently available computers. One can argue that exponentiation does not support these aims. -------------------------------------------------------------------------------- Kenneth G. Salter | To do good is noble. Unisys Corporation | To tell others how THEY can do good 215-341-4902 | is far nobler. Cheaper too. kgs@dvncnms.cnms.dev.unisys.com "The Small Society" --------------------------------------------------------------------------------
Rw.Hutchinson@f503.n151.z1.fidonet.org (Rw Hutchinson) (05/29/91)
In a message to All <27 May 91 13:09> Debora Weber-Wulff wrote: DW> The question came up in class today: Why is there no ** or ^ DW> (x to the nth power) operator in standard Modula2? DW> We checked the 3 books we use in class and found no mention of DW> why this is missing. Some textbooks state that (in Pascal, and I see no reason for there to be a change in reason) the reason is to make the programmer think twice before using such an "expensive" (in computer resources) function without thinking, when it may be unnecessary. The issue is whether the n (as in nth. power) is an integer, or real. If n is an integer, then a succession of multiplications (or squarings, or whatever for efficiency [see Knuth, Vol. 2]) can yield a fairly efficient implementation, whereas if n is real, then the logarithm is called for, which is a transcendental function and rather more work to compute. -- uucp: uunet!m2xenix!puddle!151!503!Rw.Hutchinson Internet: Rw.Hutchinson@f503.n151.z1.fidonet.org
Kevin.Williams@f64.n128.z1.fidonet.org (Kevin Williams) (05/29/91)
Hello Debora! In a msg of <27 May 91>, Debora Weber-Wulff writes to All: DW> The question came up in class today: Why is there no ** or ^ DW> (x to the nth power) operator in standard Modula2? DW> To make you start your own private module collection of goodies? DW> Because it is machine dependant??? DW> DW> We checked the 3 books we use in class and found no mention of DW> why this is missing. Hmmm. All of my references list it as a library function. I suppose this makes sense, since you don't have generics in Modula-2 (like you have in Ada). As for WHY Wirth left it out, well, I'd suppose that he either didn't see it as important (unlikely) or he decided that it'd be too much trouble to make it standard (more likely). Whatever the case, it's fairly easy to implement, and it's used rarely enough, that it should be a fairly reasonable problem to do so for all the assorted types. Also, note that there's more than one way to skin a programmer -- that is, there are so many different ways to implement something like this that you'll usually get arguments about which way is better. kwill -- uucp: uunet!m2xenix!puddle!128!64!Kevin.Williams Internet: Kevin.Williams@f64.n128.z1.fidonet.org
Ben.Stuyts@p6.f202.n281.z2.fidonet.org (Ben Stuyts) (05/31/91)
dww@math.fu-berlin.de (Debora Weber-Wulff) writes:
DW> The question came up in class today: Why is there no ** or ^
DW> (x to the nth power) operator in standard Modula2?
DW> To make you start your own private module collection of goodies?
DW> Because it is machine dependant???
Probably because it is the spirit of Wirth's languages that they are
easy to parse and it is easy to generate code for the underlying machine
architecture. And as there are usually no 'power' type instructions, Wirth
did not add it to the language but put it in the MathLib library instead.
Best regards,
Ben
--
uucp: uunet!m2xenix!puddle!2!281!202.6!Ben.Stuyts
Internet: Ben.Stuyts@p6.f202.n281.z2.fidonet.org
Bernd.Goetz@p21.f815.n302.z2.fidonet.org (Bernd Goetz) (06/01/91)
Hi Debora.. DW> The question came up in class today: Why is there no ** or ^ (x to the DW> nth power) operator in standard Modula2? To make you start your own DW> private module collection of goodies? Because it is machine DW> dependant??? I am a student of computer science at the federal institute of technology in zurich. as you know, Wirth is doing his stuff here. so we hear some inside informations here and there. now the most possible answer to your question: because taking functions liker power into the language makes the compiler bigger!!! note: Wirth: a compiler has to be as small as possible (see also Oberon). for my opinion this is a good solution for compiler writers and it is easy to port such a compiler (in comparision to e.g. a ADA-compiler). decentralism (hm?) Read ya Bernd Goetz -- uucp: uunet!m2xenix!puddle!2!302!815.21!Bernd.Goetz Internet: Bernd.Goetz@p21.f815.n302.z2.fidonet.org
rjc@devo.unify.com (Ronald Cole) (06/05/91)
In article <1302.284A5A7F@puddle.fidonet.org> Ben.Stuyts@p6.f202.n281.z2.fidonet.org (Ben Stuyts) writes: dww@math.fu-berlin.de (Debora Weber-Wulff) writes: DW> The question came up in class today: Why is there no ** or ^ DW> (x to the nth power) operator in standard Modula2? DW> To make you start your own private module collection of goodies? DW> Because it is machine dependant??? Probably because it is the spirit of Wirth's languages that they are easy to parse and it is easy to generate code for the underlying machine architecture. And as there are usually no 'power' type instructions, Wirth did not add it to the language but put it in the MathLib library instead. Because x ** y is written in Modula-2 as MathLib0.exp(y * MathLib0.log(x)). It's so obvious that Wirth didn't even bother to mention it in his book! :-) -- Ronald Cole +----------------------+ internet: rjc@unify.com Software Engineer II | This space for rent. | uucp: uunet!unify!rjc Unify Corporation +----------------------+ voice: +1 916 928 6238 "Relax. What is mind? No matter. What is matter? Never mind!" - Homer Simpson
warwick@cs.uq.oz.au (Warwick Allison) (06/05/91)
>note: Wirth: a compiler has to be as small as possible (see also Oberon). >for my opinion this is a good solution for compiler writers and it is easy to >port such a compiler (in comparision to e.g. a ADA-compiler). decentralism >(hm?) Agreed. Except we cannot define our own "**", we have to use one of... y:=IntegerToRealPower(A,x) y:=RealToIntegerPower(A,x) B:=IntegerToIntegerPower(A,x) y:=RealToRealPower(A,x) :-) Warwick. Actually, I take that back (-:, I think I would prefer to use those functions. Bye, I've got a module to write... -- _-_|\ warwick@cs.uq.oz.au / * <-- Computer Science Department, \_.-._/ University of Queensland, v Brisbane, AUSTRALIA.
MDORMAN1@UA1VM.BITNET (Mike Dorman) (06/05/91)
Someone opined in a Dr. Dobbs Journal many years back, that one obvious addition to Modula-2 (or any other language, for that matter) is a keyword like OPERATOR, or something, which would let you define thingies which you use to perform operations on variables, like **. The only problem I see is that it would either have to take into account all possible variable types, or be variable-type-specific. It would be quite nice to be able to write a + operator for concatenating strings, and stuff like that. Mike. ------------------------------------------------------------------------------- : Michael Alan Dorman : : : MDORMAN1@UA1VM.UA.EDU : Hobbies are things people do when they should be : : BIX: syssupport : sleeping. --M.A.D. : : GEnie: M.DORMAN2 : : : PostalNet: : : : Box 8068 : Stonehenge was built by two drunks with no : : Tuscaloosa, AL : witnesses. --P.S.McGhee : : 35486 : : -------------------------------------------------------------------------------
UNBCIC@BRFAPESP.BITNET (06/07/91)
=> Someone opined in a Dr. Dobbs Journal many years back, that one obvious => addition to Modula-2 (or any other language, for that matter) is a keyword => like OPERATOR, or something, which would let you define thingies which you => use to perform operations on variables, like **. There are MANY languages with this features. In first place, functional languages, like LISP or SCHEME, doesn't have infixed operators, and treats all operators the same way. There are other languages working this way (Forth, for example, although it's possible to create infixed operators in Forth). Object Oriented Languages, like Smalltalk, usually let you create infixed operators. In fact, in Smalltalk it's possible to take three or more elements. (8-DCS) Daniel C. Sobral UNBCIC@BRFAPESP.BITNET
Kevin.Williams@f64.n128.z1.fidonet.org (Kevin Williams) (06/11/91)
Hello Mike! In a msg of <05 Jun 91>, Mike Dorman writes to All: MD> Someone opined in a Dr. Dobbs Journal many years back, that one MD> obvious addition to Modula-2 (or any other language, for that matter) MD> is a keyword like OPERATOR, or something, which would let you define MD> thingies which you use to perform operations on variables, like **. MD> MD> The only problem I see is that it would either have to take into MD> account all possible variable types, or be variable-type-specific. It MD> would be quite nice to be able to write a + operator for concatenating MD> strings, and stuff like that. Yes, but most of the operators in Modula-2 ARE type specific. If they would add in a "CLASS" structure as part of the standard, it would make the def. of operators not only MUCH easier, but make them make more sense too (for example, what does POINTER_TYPE_VAR ** mean?). Modula-2 has a great chance of making good sense of object orientedness, if they would get away from the standards of thinking and teaching (and especially if they would quit saying that THIS way is the ONLY way). kwill -- uucp: uunet!m2xenix!puddle!128!64!Kevin.Williams Internet: Kevin.Williams@f64.n128.z1.fidonet.org
mfranz@bernina.ethz.ch (Michael Franz) (06/11/91)
A guiding principle of Wirth's languages is to put into the language all of those features that are usually found in processors and leave to libraries all of those that are not. Note that if you *desparately* need the efficiency gained by having *inline* floating-point-exponentiation, you might build a pseudo-module Math into the compiler, similar to module SYSTEM. I did that in an experimental version of an Oberon compiler, but removed it again because in my case, the efficiency gained was minimal while it forced me to maintain a separate version of our compiler front-end. Michael Franz Computersysteme, ETH Zurich, Switzerland
smith@ctron.com (Larry Smith) (06/17/91)
In article <1717.285A64EB@puddle.fidonet.org> Kevin.Williams@f64.n128.z1.fidonet.org (Kevin Williams) writes: >Modula-2 has a great chance of making good sense of object orientedness, >if they would get away from the standards of thinking and teaching (and > especially if they would quit saying that THIS way is the ONLY way). I tend to agree with you, though I'm not sure what this has to do with the topic. In any event, I have not seen anyone mention Wirth's own comments on the subject - when asked why no ** was defined for Pascal (and I presume this applies to Modula and Oberon, as well) was that it is non-trivial to calculate independently of the program in which it is most likely to be used. It was *his* feeling that most uses of the ** operator in FORTRAN was within loops, usually calculating a series of some sort. He felt most strongly that the programmer should be calculating the exponent as part of the loop, by repeated addition or multiplication of either the previous exponent or the loop control variable. He is not well-respected for this. As I recall, Jean Ichbiah (the man responsible for inflicting - I mean, *providing* - Ada to the world) had a bit of an argument with him at the symposium (don't recall which one) over this topic. Wirth believes in tiny, highly-orthogonal languages with teeny little compilers that programmers can use safely. Ichbiah believes compilers should be huge, gigantic things, with all previous programming problems ever encountered encapsulated within so no one has to rewrite them as a library module. Who's right? Depends on your own perspective. I think Wirth is *closer* to right, but I was unhappy with Oberon (it seemed to toss out a bit of the baby with the bathwater). But Ada just seems right out. -- Larry Smith smith@ctron.com The usual disclaimer stuff...
tarjeij@ulrik.uio.no (Tarjei Jensen) (06/18/91)
I agree that Wirth is onto something. I don't dispute that oberon and modula2 might be academically sound (you can do anything with them), but I think that he has forgotten the programmer. There seems to be very little thought about ergonomics (look and feel?) in his programming languages. I think somebody needs to do approximately the same to oberon as UCSD and Borland did to Pascal. It is not accident that made Turbo Pascal outdo Modula 2. Greetings from Norway, -- // Tarjei T. Jensen - if it ain't broken, fix it anyway! // tarjeij@ulrik.uio.no || +47 87 21138 // Working, but not speaking for the Norwegian National Library.
mcmahan@cs.unca.edu (Scott McMahan) (06/19/91)
The look and feel of Wirth's languages is the exact problem with them. While the theory is great, and I admire his modular, structured approach to programming, I hate *typing* everything! I mean, some of his modula-2 library modules have names that are simply too cumbersome to use. I'll spare you the examples. They lack a certain day to day comfortableness -- they are fine for theoretical models, but not practical use. and I *HATE* CaseSensiTivityInModulesAndProcedures! I never *use* uppercase/lowercase names (:-)) but the library modules do. To close: Which is better? WriteString("Amount: "); WriteInt(NumberOfThings[1]); Write("."); WriteLn(); -or- printf("Amount: %d.\n"); From a programmer's point of view? -- Scott McMahan FROM LibraryModule IMPORT Disclaimer, Signature; (or #include <stddisclaimer.h> #include <stdsig.h>)
smith@ctron.com (Larry Smith) (06/19/91)
In article <1991Jun18.171233.22657@rock.concert.net> mcmahan@cs.unca.edu (Scott McMahan) writes: > >and I *HATE* CaseSensiTivityInModulesAndProcedures! I never *use* >uppercase/lowercase names (:-)) but the library modules do. Of course, it *does* enforce a consistancy of spelling which makes for more readable programs, at the expense of typing them properly in the first time. >To close: Which is better? > >WriteString("Amount: "); >WriteInt(NumberOfThings[1]); >Write("."); >WriteLn(); > -or- > >printf("Amount: %d.\n"); > >From a programmer's point of view? Well, Scott, I'd have to say the former is better, from a programmers view. After all, the Modula you gave is correct, but the C version will print garbage. :) :) :) -- Larry Smith smith@ctron.com The usual disclaimer stuff...
robart@agora.rain.com (Robert Barton) (06/19/91)
In article <TARJEIJ.91Jun18084649@ulrik.uio.no> tarjeij@ulrik.uio.no (Tarjei Jensen) writes: >I agree that Wirth is onto something. I don't dispute that oberon and modula2 >might be academically sound (you can do anything with them), but I think that >he has forgotten the programmer. There seems to be very little thought about >ergonomics (look and feel?) in his programming languages. Maybe because Wirth himself is such a poor programmer? Ever seen the code he wrote for the simple Pascal compiler? Ugly to the bone!
UNBCIC@BRFAPESP.BITNET (06/19/91)
=> Date: Tue, 18 Jun 91 18:13:10 GMT
=> From: Larry Smith
=> <cis.ohio-state.edu!zaphod.mps.ohio-state.edu!samsung!balrog!smith@UCBVAX.BI
TNET>
=> Subject: RE: Why no ** operator in Modula2?
=> In article <1991Jun18.171233.22657@rock.concert.net> mcmahan@cs.unca.edu (Sco
tt
=> McMahan) writes:
=> >
=> >and I *HATE* CaseSensiTivityInModulesAndProcedures! I never *use*
=> >uppercase/lowercase names (:-)) but the library modules do.
=>
=> Of course, it *does* enforce a consistancy of spelling which makes for
=> more readable programs, at the expense of typing them properly in the
=> first time.
Well, in other languages I *do* use a lot upper/lowercase names. I use
uppercase names for external (to the module) names, lowercase for functions and
Uppercase just the first letter for procedures. This can't be done in Modula 2.
=> Larry Smith
=> smith@ctron.com
(8-DCS)
Daniel C. Sobral Errare Humanum Est...
UNBCIC@BRFAPESP.BITNET ...Perseverare Autem Diabolicum
UNBCIC@FPSP.FAPESP.ANSP.BR
--------------------------------------------------------------------------
No one, but me, is responsible for the above message.
robart@agora.rain.com (Robert Barton) (06/19/91)
In article <INFO-M2%91061907542707@UCF1VM.BITNET> Modula2 List <INFO-M2%UCF1VM.BITNET@ucf1vm.cc.ucf.edu> writes: >Well, in other languages I *do* use a lot upper/lowercase names. I use >uppercase names for external (to the module) names, lowercase for functions and >Uppercase just the first letter for procedures. This can't be done in Modula 2. It certainly can be done, as long as there is no conflict with the reserved words of the language.
88132293@BRUFSC.BITNET (Marcos Macedo) (06/20/91)
On Wed, 19 Jun 91 08:51:00 -0300 <UNBCIC@BRFAPESP> said: >Well, in other languages I *do* use a lot upper/lowercase names. I use >uppercase names for external (to the module) names, lowercase for functions and >Uppercase just the first letter for procedures. This can't be done in Modula 2. Why Not ?
mcmahan@cs.unca.edu (Scott McMahan) (06/20/91)
To keep the debate going: >>Well, in other languages I *do* use a lot upper/lowercase names. I use >>uppercase names for external (to the module) names, lowercase for functions and >>Uppercase just the first letter for procedures. This can't be done in Modula 2. > > > It certainly can be done, as long as there is no conflict with the reserved >words of the language. One feature I *especially* like about Modula-2 is the way it will let you use lowercase versions of reserve words as identifiers! For example, TYPE arraytype = ARRAY [0..10] OF settype; is perfectly legal! In a type declaration, you can be very descriptive (foobartype -- what is it? An array? A set? A file?) of your types. Or variable names, for that matter, but if the types document themselves it isn't necessary. When you import a type from somewhere else, it is very obvious which type it really is. No pun intended, but: The only thing I dislike is mixed case, because it is awful to type. Scott McMahan "It's not a bug, it's a *feature* " :-)
warwick@cs.uq.oz.au (Warwick Allison) (06/20/91)
>To keep the debate going: >One feature I *especially* like about Modula-2 is the way it >will let you use lowercase versions of reserve words as identifiers! >For example, > TYPE > arraytype = ARRAY [0..10] OF settype; >is perfectly legal! TYPE ARRAYOF = CHAR; OFARRAY = ARRAY ARRAYOF OF ARRAYOF; is too. Warwick. -- _-_|\ warwick@cs.uq.oz.au / * <-- Computer Science Department, \_.-._/ University of Queensland, v Brisbane, AUSTRALIA.
zzassgl@uts.mcc.ac.uk (Geoff Lane) (06/20/91)
In article <1991Jun19.053127.29333@agora.rain.com> robart@agora.rain.com (Robert Barton) writes: > Maybe because Wirth himself is such a poor programmer? Ever seen the >code he wrote for the simple Pascal compiler? Ugly to the bone! (*$c+,t-,d-,l-*) (********************************************** * * * * * portable pascal compiler * * ************************ * * * * pascal p4 * * * * * * authors: * * urs ammann * * kesav nori * * christian jacobi * * * * address: * * * * institut fuer informatik * * eidg. technische hochschule * * ch-8096 zuerich * * * * * * last changes completed in may 76 * * * * * **********************************************) His name does not appear on the commonly available P4 compiler But, yes there is some really nasty code in it. Parts of the compiler aren't even legal Pascal! -- Geoff. Lane. Janet: zzassgl@uk.ac.mcc.uts UTS Sys Admin, Manchester Computing Centre, Oxford Rd, Manchester, M13 9PL
UNBCIC@BRFAPESP.BITNET (06/20/91)
=> Date: Wed, 19 Jun 91 16:22:41 BRA => From: Marcos Macedo <88132293@BRUFSC.BITNET> => Subject: RE: Why no ** operator in Modula2? => On Wed, 19 Jun 91 08:51:00 -0300 <UNBCIC@BRFAPESP> said: => >Well, in other languages I *do* use a lot upper/lowercase names. I use => >uppercase names for external (to the module) names, lowercase for functions and => >Uppercase just the first letter for procedures. This can't be done in Modula 2. => Why Not ? Because the case I use for a function when inside the module it's defined its not the same I use when I IMPORT it. (8-DCS) Daniel C. Sobral Errare Humanum Est... UNBCIC@BRFAPESP.BITNET ...Perseverare Autem Diabolicum UNBCIC@FPSP.FAPESP.ANSP.BR -------------------------------------------------------------------------- No one, but me, is responsible for the above message.
Jon.Guthrie@p25.f506.n106.z1.fidonet.org (Jon Guthrie) (06/21/91)
On a message of 18-Jun-91, Scott McMahan (1:105/42.0) Said: > To close: Which is better? > > WriteString("Amount: "); > WriteInt(NumberOfThings[1]); > Write("."); > WriteLn(); > -or- > printf("Amount: %d.\n"); > From a programmer's point of view? Well, since the latter leads itself to errors that the compiler cannot catch (for example, LEAVING OUT WHAT YOU WANTED TO PRINT!) I'd have to say the first. A bug that the compiler catches is one that the customer will not. -- uucp: uunet!m2xenix!puddle!106!506.25!Jon.Guthrie Internet: Jon.Guthrie@p25.f506.n106.z1.fidonet.org
warwick@cs.uq.oz.au (Warwick Allison) (06/27/91)
On a message of 18-Jun-91, Scott McMahan (1:105/42.0) Said: > To close: Which is better? > > WriteString("Amount: "); > WriteInt(NumberOfThings[1]); > Write("."); > WriteLn(); > -or- > printf("Amount: %d.\n"); > From a programmer's point of view? In addition to Jon Guthrie's comments, WriteFormattedInt("Amount: %d.\n", NumberOfThings[1]); Is perfectly legit Modula-2, providing someone has written the module for it. It is just that so many C hackers have been bumbling around for so long that such procedures exist in C. If you REALLY WANT variable arg counts in M2, write a parameter-passing module. I think you'd be crazy to use such an abomination of structure. Warwick. DEFINITION MODULE VarArgs; FROM SYSTEM IMPORT BYTE; PROCEDURE Push(VAR Arg:ARRAY OF BYTE); PROCEDURE Pop(VAR Arg:ARRAY OF BYTE); END VarArgs. beleuch! Looks like C. -- _-_|\ warwick@cs.uq.oz.au / * <-- Computer Science Department, \_.-._/ University of Queensland, v Brisbane, AUSTRALIA.
UNBCIC@BRFAPESP.BITNET (06/28/91)
=> If you REALLY WANT variable arg counts in M2, write a parameter-passing modul e. => I think you'd be crazy to use such an abomination of structure. I remember that FTS Modula 2 have the source of an implementation of variable arguments in it's documentation. As ugly as C's implementation. (8-DCS) Daniel C. Sobral Errare Humanum Est... UNBCIC@BRFAPESP.BITNET ...Perseverare Autem Diabolicum UNBCIC@FPSP.FAPESP.ANSP.BR -------------------------------------------------------------------------- No one, but me, is responsible for the above message.