> a && b   is    if a THEN b else TRUE

?

Shirley a && b   is    if a THEN b else FALSE

Short circuit operators can be very nice.


--
Shmuel (Seymour J.) Metz
http://mason.gmu.edu/~smetz3

________________________________________
From: IBM Mainframe Discussion List [[email protected]] on behalf of 
Peter Sylvester [[email protected]]
Sent: Sunday, September 25, 2022 3:52 PM
To: [email protected]
Subject: Re: Assembler courses

Hi,

I have the feeling that the author of

https://secure-web.cisco.com/1Z9n56_GZoR00w22sogI3_RQ0O39K_O1yP3HvzHAo2fpEAgxBr-hrxrkfU9NnK-J_fHfMvKrrdldl7xs2GUeZtBH26GpYTwxXkCtfjggtpM4uYJDgglgpvpHb48TiwP2JGRlE422xyKe0alHCWSijzmqu7l-jxTRNWc4h0K_RrukNO3FqVh1i-8GvKbJ9YTMoySYFbhElKEvk_ikLVO0piVZmYo77F07K6i8Smv41n1rTN2LwPscOnE9kzSZf0GDEPtJ-uIMyH-zXU-i4vAcoJZWYs5_xESPjzl2FjMDNKpBzv4So1URdb4KPG8kvhSLxL6DC5i8sJnPc5vfVl6cUIS-7eaQm7wfN-Ps2ILng-E8S-x04_oAx2Xzj0VtFcMW0doXUavXUdYNkDKsTJOinS70X9QNUIdI13NhpoibFkNsxhzxSVKnZ-bDD5J50g3ax/https%3A%2F%2Fgithub.com%2Feclipse-openj9%2Fopenj9%2Fblob%2Fmaster%2Fruntime%2Fvm%2Fclasssupport.c.

might not know/like/understand the && operator.

The huge case testing length and values can be contracted into a single if.

using     (len = 3 && memcmp(v,"ddd",3)

    Ah the || operator. :-)

not talking about a static inline or macro in order to avoid writing "3" twice. 
caution about
obfuscation)

This "smells" using C like simple assembler.

Or the used compiler optimations cannot be trusted ;-)

When I read if a if b if c  I tend to expect some else. ==> if a && b && c

the  "goto done" can either be return whatever, it is done in almost all other 
situations).

I don't want to go into a length debate about 'return'.

if cond1 { ... return } if cond2 { ... return }

vs using "else" is sometimes "not so bad".

The "techniques" used in the code are not consistently used, and this *may* 
hurt the reader.

Anecdote: In Simula (and Algol?) :

      a & b     is    a AND b

      a && b   is    if a THEN b else TRUE

==>    if (a && b) { .. becomes

       if if a then b else true then begin ...

you might or might not like it.

doing things before return or at the end of a block: syntactically "finally" or 
the infamous "else"
in a python "for".

I kind of cheated in assembler:  Whatever "block"  (block, (if, (loop, (while, 
(for, ...) there is a
"POSTLUDE name" (kind of named finally) and a "SIGNAL name" from the inside in 
order not to use
GOTO. Wording is all.

        (block ...   SIGNAL c1  ...  SIGNAL c2 ...   POSTLUDE c1 ... POSTLUDE  
c2 ...  block)

writing all kind of variations of

        goto end;

case1:  whatever := nonsense; goto end;

case2 : ....

end:  return whatever

shows what:   C can be regarded as a better macro assembler (and this very 
useful for OS kernel dev)

The point is readability, expectation, avoiding noise ...  and obfuscation is a 
funny game.

I got used to hear (but extremely rarely to read) qualifications such as  
"c'est la merde"  or "so'n
Scheiss mach i nett".

I know two generations considered "lost" (grandpa was in Verdun and "dad" was 
born in 1922)


Best

Peter






----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to