RE: [UV] Pass by value [was:Need/Want/Would like to know]

2004-02-18 Thread Anthony Youngman
Maybe passing a matrix in parentheses DOES pass by value - it passes the
value of the matrix reference! Which still contains pointers to the
matrix elements ... :-)

With respect to the docu, I suspect it's meaningless when talking about
matrices because it's not talking about what you think it is. For the
same reason that C actively discourages passing structs by value (it's a
HORRENDOUS performance hit on anything beyond the trivial), I suspect UV
doesn't pass matrix CONTENTS by value for the same reason.

Cheers,
Wol

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Stuart Boydell
Sent: 17 February 2004 23:10
To: U2 Users Discussion List
Subject: [UV] Pass by value [was:Need/Want/Would like to know]

 I know that UDT passes by reference

Interesting. The UV documentation for the CALL statement says: All
scalar
and matrix variables are passed to subroutines by reference. If you want
to
pass variables by value, enclose them in parentheses.

Enclosing a matrix in parentheses apparently does not actually work.
(UV10.0.7 aix)

Vlisting the difference between a scalar and a vector (1D matrix)
variable
surrounded by parentheses shows in the first example, using a scalar
variable, passes by value using a new internal variable _T. In the
second example, surrounding a vector in parentheses does nothing and the
vector is passed by reference, the same as if there were no parentheses.

--- 1
5: CALL P2((A), MAT X)
5 00022 : 0F8 move   A  = _T
5 00028 : 01E call   P2 _T X

--- 2
5: CALL P2((X(100)), MAT X)
5 00018 : 01E call   P2 X(100(1(X

Seems like a bug in the documentation.
Stuart














**
This email message and any files transmitted with it are confidential
and intended solely for the use of addressed recipient(s). If you have 
received this email in error please notify the Spotless IS Support
Centre (61 3 9269 7555) immediately who will advise further action.

This footnote also confirms that this email message has been scanned
for the presence of computer viruses.
**

-- 
u2-users mailing list
[EMAIL PROTECTED]
http://www.oliver.com/mailman/listinfo/u2-users




***

This transmission is intended for the named recipient only. It may contain private and 
confidential information. If this has come to you in error you must not act on 
anything disclosed in it, nor must you copy it, modify it, disseminate it in any way, 
or show it to anyone. Please e-mail the sender to inform us of the transmission error 
or telephone ECA International immediately and delete the e-mail from your information 
system.

Telephone numbers for ECA International offices are: Sydney +61 (0)2 9911 7799, Hong 
Kong + 852 2121 2388, London +44 (0)20 7351 5000 and New York +1 212 582 2333.

***

--
u2-users mailing list
[EMAIL PROTECTED]
http://www.oliver.com/mailman/listinfo/u2-users


RE: [UV] Pass by value [was:Need/Want/Would like to know]

2004-02-18 Thread Stuart Boydell
 Maybe passing a matrix in parentheses DOES pass by value - it passes the
 value of the matrix reference! Which still contains pointers to the
 matrix elements ... :-)

 With respect to the docu, I suspect it's meaningless when talking about
 matrices because it's not talking about what you think it is. For the
 same reason that C actively discourages passing structs by value (it's a
 HORRENDOUS performance hit on anything beyond the trivial), I suspect UV
 doesn't pass matrix CONTENTS by value for the same reason.

Thanks but I'm not convinced. I still think this is buggy behaviour or bad
documentation. My reasons for not being convinced are:

A scalar and a matrix variable may refer to the same types of things (value,
pointer, dyn array etc).
Scalar variables with datum over eight bytes are pointers - same as a matrix
variable. So in this case there is virtually no difference between a scalar
variable and matrix variable.

The documentation suggests that the effect of pass-by-value-parentheses will
be the same on either scalar or matrix variable.
The documentation says : When data is passed by value, the contents of the
variable in the main program do not change as a result of manipulations to
the data in the subroutine. This rule breaks when passing a matrix variable
by value.

The compiler will specifically fail on a call xxx((mat array)) type
syntax. This specifically excises passing whole dimensioned arrays by value
(your HORRENDOUS struct scenario).
The compiler does not fail on a call xxx((array(9))) type syntax
suggesting to the developer that certain behaviour will be exhibited. This
expected behaviour is not manifested.
The compiler treats scalar or matrix variables differently.

So, to summarise, I feel my thesis is sound and the U2 developers should
either amend the documentation of fix the compiler so that passing a matrix
variable by value works.

Regards, Stuart

Note: in researching this I discovered there are 2 types of dimensioned
arrays Prime and Pick style. I tested this for both styles of array with
negative results.



**
This email message and any files transmitted with it are confidential
and intended solely for the use of addressed recipient(s). If you have 
received this email in error please notify the Spotless IS Support Centre (61 3 9269 
7555) immediately who will advise further action.

This footnote also confirms that this email message has been scanned
for the presence of computer viruses.
**

-- 
u2-users mailing list
[EMAIL PROTECTED]
http://www.oliver.com/mailman/listinfo/u2-users


RE: [UV] Pass by value [was:Need/Want/Would like to know]

2004-02-18 Thread Gyle Iverson
Hello, Stuart.

I say this is a compiler flaw rather than a documentation flaw. While it
may prove challenging to dig through the parse-tree to figure out when
to make use of the implicit temporary, it should be done for matrix
components as it is for scalars. The compiler can do it far more
reliably for us than we can manually. 

Best regards,
Gyle

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Stuart Boydell
Sent: Wednesday, February 18, 2004 5:27 PM
To: U2 Users Discussion List
Subject: RE: [UV] Pass by value [was:Need/Want/Would like to know]
[snip]
So, to summarise, I feel my thesis is sound and the U2 developers should
either amend the documentation of fix the compiler so that passing a
matrix
variable by value works.
[snip]


-- 
u2-users mailing list
[EMAIL PROTECTED]
http://www.oliver.com/mailman/listinfo/u2-users


RE: [UV] Pass by value [was:Need/Want/Would like to know]

2004-02-18 Thread Stuart Boydell
   EQUATE CONST LIT ':'
   CALL xxx(CONST zzz(n))

Good call!











**
This email message and any files transmitted with it are confidential
and intended solely for the use of addressed recipient(s). If you have 
received this email in error please notify the Spotless IS Support Centre (61 3 9269 
7555) immediately who will advise further action.

This footnote also confirms that this email message has been scanned
for the presence of computer viruses.
**

-- 
u2-users mailing list
[EMAIL PROTECTED]
http://www.oliver.com/mailman/listinfo/u2-users


RE: [UV] Pass by value [was:Need/Want/Would like to know]

2004-02-18 Thread Stuart Boydell
 I say this is a compiler flaw rather than a documentation flaw. While it
 may prove challenging to dig through the parse-tree to figure out when
 to make use of the implicit temporary, it should be done for matrix
 components as it is for scalars. The compiler can do it far more
 reliably for us than we can manually. 
 
 Best regards,
 Gyle

Sounds good. Cheers S









**
This email message and any files transmitted with it are confidential
and intended solely for the use of addressed recipient(s). If you have 
received this email in error please notify the Spotless IS Support Centre (61 3 9269 
7555) immediately who will advise further action.

This footnote also confirms that this email message has been scanned
for the presence of computer viruses.
**

-- 
u2-users mailing list
[EMAIL PROTECTED]
http://www.oliver.com/mailman/listinfo/u2-users


RE: [UV] Pass by value [was:Need/Want/Would like to know]

2004-02-18 Thread Gyle Iverson
Hello, Stuart.

Hmmm. The technique shown deals with string, real and whole number
variables. What about files, subroutines, sockets, etc? And performing
string concatenation would coerce numerics into strings, which may slow
things further down stream.

Best regards,
Gyle

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Stuart Boydell
Sent: Wednesday, February 18, 2004 6:20 PM
To: U2 Users Discussion List
Subject: RE: [UV] Pass by value [was:Need/Want/Would like to know]


   EQUATE CONST LIT ':'
   CALL xxx(CONST zzz(n))

Good call!

[snip]


-- 
u2-users mailing list
[EMAIL PROTECTED]
http://www.oliver.com/mailman/listinfo/u2-users