what is the assignment expression return value?

V

vlsidesign

Guest
I believe in C, an assignment expression returns the value of the left
side of the assignment. For example, a = 2, would return 2.

If this is true, is Skill similar? For instance, if I have the
following, a = nil, would it return nil ?
 
On May 14, 12:16 pm, vlsidesign <ford...@gmail.com> wrote:
I believe in C, an assignment expression returns the value of the left
side of the assignment. For example, a = 2, would return 2.

If this is true, is Skill similar? For instance, if I have the
following, a = nil, would it return nil ?
It seems like it would return nil but for different reason than C. I
believe it returns the value of the expression on the right side that
happens to be what is assigned to a.
 
Dear vlsidesign,

Why don't you give it a try into your CIW ? you will get the truth by
yourself ;-)
I guess you don't have cadence.

Give a look at the function 'setq' in the following document :
Cadence SKILL Language Reference ($CDSHOME/doc/sklangref.pdf).
As you can see in this document setq is the same as the assignment (=)
operator. It sets a variable to a new value and returns this new value
(or the evaluated result if the assigned new value is an expression).
I think that (=) is internally translated to setq (to be confirmed or
not by the skill experts).

ciw> x = 5
=> 5
ciw> (setq x 5)
=> 5
ciw> a = nil
=> nil

Do mind that nil is a special atom in skill !

Hope it helps !

Riad.
 
Yes it is, it returns the value of the expression on the right side.
 
vlsidesign wrote, on 05/14/08 22:55:
On May 14, 12:16 pm, vlsidesign <ford...@gmail.com> wrote:
I believe in C, an assignment expression returns the value of the left
side of the assignment. For example, a = 2, would return 2.

If this is true, is Skill similar? For instance, if I have the
following, a = nil, would it return nil ?

It seems like it would return nil but for different reason than C. I
believe it returns the value of the expression on the right side that
happens to be what is assigned to a.
The assignment operator is converted into functional equivalent, by working
from right to left. Most operators work left to right:


sstatus(printinfix nil)
nil
'(a=b=c=d=5)
(setq a
(setq b
(setq c
(setq d 5)
)
)
)

The above shows you the functional equivalent (i.e. how it is actually implemented)
for a=b=c=d=5. So you can see precedence and left-to-right/right-to-left handling
by looking at the output of that.

So it behaves just like C in this respect - the compiler expands = operators right to left.

Regards,

Andrew.
 

Welcome to EDABoard.com

Sponsor

Back
Top