🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #1040

Re: Small Language Wanted

#1040
From: Fergus James HENDERSON
Date: Sun, 23 Aug 1992 08:41
50 lines
2182 bytes
mbk@lyapunov.ucsd.edu (Matt Kennel) writes:

>mdchaney@fractal.ucs.indiana.edu (M Darrin Chaney) writes:
>: Not to fan a flame war, but indeed C++ is _excellent_ for working with
>: complex numbers, etc.  And, nobody will accuse you of using an outdated
>: language.
>
>C++:  complex A, B, C;
>
>C = A + B
>
>{ get A and B, call "+" operator.  Create new temporary structure for
>  result by calling complex constructor.  Run "+" operator. 
>  call overloaded "=" operator.  Copy into C. Delete temporary.}

The calls to operator "+" and operator "=" will be inlined.
Smart compilers (including Cfront) will optimize the temporary away.
The resulting object code is exactly the same as would result from
equivalent Fortran.

>And can C++ optimize
>
>for (i=1; i<1000; i++) {
>	<junk not altering A and B>
>	C = A + B
>	<more junk not altering A and B>
>	func(C)
>}
>
>by taking out C=A+B as a loop invariant?

Yes.

>How can it if the "+" and "=" operators could conceivably do *ANYTHING*
>which might possibly alter something else somewhere else.

These operators are declared as inline functions, so the
compiler can see exactly what they do and can thus make the
appropriate optimizations.

-- 
Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
This .signature virus is a self-referential statement that is true - but 
you will only be able to consistently believe it if you copy it to your own
.signature file!
-- 
Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
This .signature virus is a self-referential statement that is true - but 
you will only be able to consistently believe it if you copy it to your own
.signature file!
Technical Details
Message-ID: <9223618.1639@mulga.cs.mu.OZ.AU>
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!sdd.hp.com!mips!mips!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
References: <BtCFs9.4ox@usenet.ucs.indiana.edu> <173lvpINNiov@network.ucsd.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.misc
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!sdd.hp.com!mips!mips!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
Subject: Re: Small Language Wanted
Message-ID: <9223618.1639@mulga.cs.mu.OZ.AU>
Sender: news@cs.mu.OZ.AU
Organization: Computer Science, University of Melbourne, Australia
References: <BtCFs9.4ox@usenet.ucs.indiana.edu> <173lvpINNiov@network.ucsd.edu>
Date: Sun, 23 Aug 1992 08:41:17 GMT
Lines: 50