At T said that's in other languages (notably C style languages where = is
always assignment and == or === is equality/equivalence). In Pascal and
Delphi := is assignment, which gets confusing when you have three windows
open, one with UniVerse Basic, one with Delphi and one with C# or
JavaScript, and you're writing end-to-end code !

In MultiValue code = always binds to a LHS value as an assignment, and
otherwise as an equality.

So yes, X = Y = 3 is the same as X = (Y = 3)

But the parentheses make it clearer and do force precedence though in your
example the resulting ordering actually works out to be the same as the
original (it still forces an expression jump in a compiler). 

Consider:

X = X + Y = 3

You'd want to know whether you mean:

X = (X + Y) = 3
Or
X = X + (Y = 3)

Brian


-----Original Message-----
From: u2-users-boun...@listserver.u2ug.org
[mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Jim Swain
Sent: 01 August 2013 17:46
To: U2 Users List
Subject: Re: [U2] What is true

Now I'm getting confused... its not a case of precedence

In the case of X = Y = 3

X is set to 1 (true) when Y = 3
X is set to 0 (false) when Y # 3

X in this instance will never = 3




Jim Swain - Developer
Telephone: +44 (0) 1295 701 810  | Fax: +44 (0) 1295 701 819

www.zafire.com

Consider the environment.  Think before you print.

This is a commercial communication from Zafire Group.
This communication is confidential and is intended only for the person to
whom it is addressed. If you are not that person you are not permitted to
make use of the information and you are requested to notify us immediately
that you have received it and then destroy the copy in your possession.
Zafire Group may monitor outgoing and incoming e-mails.  By replying to this
e-mail you consent to such monitoring.  This e-mail message and any attached
files have been scanned for the presence of computer viruses. However, you
are advised that you open attachments at your own risk.

Zafire Limited is a limited liability company registered in England and
Wales. Co. Reg. No. 3968255. Our registered address is Zafire House, Manor
Park, Banbury, Oxfordshire OX16 3TB. VAT Reg.No. 754 0161 55. Zafire
Aviation Software Limited is a limited liability company registered in
England and Wales. Co. Reg. No. 05577742. Our registered address is Zafire
House, Manor Park, Banbury, Oxfordshire OX16 3TB. VAT Reg.No. 874 5890 70

If you have any concerns regarding the content of this e-mail please contact
postmas...@zafire.com

-----Original Message-----
From: u2-users-boun...@listserver.u2ug.org
[mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Tony Gravagno
Sent: 01 August 2013 17:34
To: u2-users@listserver.u2ug.org
Subject: Re: [U2] What is true

Just adding a little more subtlety. Consider:
X = Y = 3
In some languages this sets Y to 3 and then X to Y, so X=3. But in BASIC, as
Brian said, we need to force the precedence on Y=3 before X=Y.

In other contexts, parentheses force an equation. Consider:
SUBROUTINE FOO( X,Y,Z )
and
CALL FOO( X,Y,(Z) )
In this case, X and Y can be set and returned. But the third argument is an
equation, and while FOO can write to the variable in its own context, when
the data comes back it's read-only, since what went out was not a variable
but the result of the evaluation of an equation.

(X) does nothing to define the Boolean nature of a variable. While it's a
nice visual cue it's not "functional" in the code.

T



> From: Brian Leach
> It's not the parentheses that define the Boolean, it's the equality
by
> the way. Parentheses just force the precedence.


> From: Jim Swain
> This is not true as when A='HELLO'  IF (A) returns true.
>
> You use the parenthesis to set a Boolean variable, i.e  BRITISH =
> (COUNTRY = 'ENGLAND' OR COUNTRY = 'WALES')  etc   the var BRITISH is
set to 1
> when the conditions inside the parenthesis are met, otherwise
BRITISH is set to 0


> From: Tom Whitmore
> If you wrap a variable in parenthesis it will be treated as a
Boolean test.
> For example:
> A='HELLO'
> IF (A) THEN CRT 'TRUE' ELSE CRT 'FALSE'   will result in TRUE.

_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users
_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to