Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Ansi -iso > Re: function as...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 14 of 16 Topic 187 of 215
Post > Topic >>

Re: function as a pointer.

by John Reagan <john.reagan@[EMAIL PROTECTED] > Jan 2, 2007 at 03:21 PM

scott moore wrote:

> The result register is not an ordinary register. Because it only has to
> be loaded at the exit of the function, it does not compete for resources
> with any other register. 

Maybe on your machines the result register is special, but on VAX, 
Alpha, and Itanium, the result register is normal register.  I can be 
used for anything right up to the point where the function returns.

The act of "assigning" the function result to
> a register (or whatever) at the end of the function is distinctly
> different from common variable register allocation, and should not be
> unified with, and treated the same as, common variables.

Well, it is in my compilers.  The function result variable might live in 
R0 during the body and the "special move" at the end might be optimized 
away.  Other times, the function result variable might live in various 
registers and/or stack locations and get moved to R0 right at the end. 
It is already strange.

> 
> This aside, let's go back to WWWD (What Would Wirth Do). The basis of
> Wirth design philosophy is that we don't include language features
> unless there is no other way to easily accomplish the same result
> without it.
> 
> Extrapolating the result to a full variable neither enables the language
> to do something it formerly could not, nor does it significantly
> facilitate an ability that did not formerly exist. The alternative to
> function results as variables is, yes, a variable, as in a formally
> declared variable.
> 
> Finally, the purpose of the function result mechanism is to provide,
> yes, function results. Promoting it to a full variable changes the
> meaning and purpose of the feature, duplicates a language feature that
> is already in existence (variables), and worse, creates a hybrid
> "variable" that has special, and inexplicable, powers over a standard
> variable, with the addition that it isn't declared in an obvious way
> either.

Yep, we're in agreement here.  Function result variables aren't full 
variables.  You can't READ into them, you can't pass them to VAR 
parameters, etc.

However, we didn't "promote" anything.  The function result variable is 
still the same.  What we added is another variable that gets 
automatically assigned to the function result at the function's exit. 
You still have to fill it in (or it may have an initial state). 
Functions that want to "build" the function result (especially for 
functions that return records or arrays) really want to read the 
"current" result in their body.  So instead of changing the existing 
syntax to allow reading of the "current" result, we added a new syntax 
that forced the programmer to pick a new name of the function result 
that could be read as well as written.

Classic Pascal already has the weird function result variable that 
wasn't a real variable.  It was already special cased in the grammer. 
Throw some of the mud at Wirth.

> 
> This feature qualifies as pure syntactic (and semantic) sugar. It's one
> of the many reasons I don't sup****t the extended standard.

Well, it may appear to be syntatic sugar to you (and perhaps to me, it 
wasn't one of my favorite items in EP), but it does have a purpose. 
With the addition of functions that return run-time sized values, it is 
confusing how to declare your local variable of the correct size.

> 
> With respect, I know we disagree over the standard. However, realize
> that your part in the standard was as a fundamental implementer of it
> (which I do respect). My part was the possession of shock and awe
> when I first read a copy of it. That is why, I suspect, we will never
> see eye to eye on these matters.
> 

There are several parts of EP that I think were a waste of time both to 
define and to implement.


-- 
John Reagan
HP Pascal/{A|I}MACRO/COBOL for OpenVMS Project Leader
Hewlett-Packard Company
 




 16 Posts in Topic:
function as a pointer.
"steelman22" &l  2006-12-13 12:50:35 
Re: function as a pointer.
"Chris Burrows"  2006-12-14 12:18:26 
Re: function as a pointer.
CBFalconer <cbfalconer  2006-12-13 21:45:35 
Re: function as a pointer.
"Chris Burrows"  2006-12-14 14:50:51 
Re: function as a pointer.
John Reagan <john.reag  2006-12-14 15:10:25 
Re: function as a pointer.
CBFalconer <cbfalconer  2006-12-13 20:22:40 
Re: function as a pointer.
Waldek Hebisch <hebisc  2006-12-14 19:24:48 
Re: function as a pointer.
John Reagan <john.reag  2006-12-15 16:49:02 
Re: function as a pointer.
scott moore <nospam@[E  2006-12-16 09:55:57 
Re: function as a pointer.
John Reagan <john.reag  2006-12-20 00:45:08 
Re: function as a pointer.
scott moore <nospam@[E  2006-12-20 10:13:07 
Re: function as a pointer.
"Chris Burrows"  2006-12-21 09:55:38 
Re: function as a pointer.
CBFalconer <cbfalconer  2006-12-20 23:26:40 
Re: function as a pointer.
John Reagan <john.reag  2007-01-02 15:21:12 
Re: function as a pointer.
scott moore <nospam@[E  2007-01-02 07:59:18 
Re: Standards Committees (was: function as a pointer).
"Chris Burrows"  2007-01-03 10:01:01 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Jul 23 15:53:05 CDT 2008.