On 19-Jul-2016 18:30 -0500, John Yeung wrote:
[…]
In most languages, the following code snippet is not a complete,
self-contained statement:

if x > 0

Since it's not a statement, it shouldn't end in a semicolon.

I had the same observation, initially. But I soon, and I must say quite easily, overcame that feeling\issue I was having with coding the free form RPG if[-then] construct; overcome, after thinking differently about such apparent fragments. And perhaps overcome only because, often, I was not just _omitting_ the required semicolon, but also sometimes _adding_ a superfluous "then" [or even _adding_ "then do;", so with the required semicolon, but as part of a still-incorrect "then do;"]. I just decided that what I originally perceived as an incomplete statement, could be rationalized\interpreted as having an implied "then do". With that shift in thinking, I was adding the semicolon quite consistently; so easily overcome, probably because the following is quite familiar to me, and was already quite comfortable for me to write:

if (x>0) then do; /* as PL/… is familiar to me */
… ;
end do ; /* despite ending "do" vs "if", I align "end" with "if" just as I would align "end" with "case" in SQL */

Thus quite easily, I made the transition to:

if (x>0) ; /* implied "then do" */
… ;
endif ;


Let me try to make an analogy: In English, we use the period to
denote the end of a sentence. How does it feel to write the
following in English:

If you are happy and you know it. Clap your hands.

RPG is making us punctuate our sentences like the above. It's just
not comfortable or intuitive for people who have already learned
standard English punctuation and have been using it their whole
lives.


While in that analogy the observation and implication seems apropos, do other programming languages that you are thinking of, in contrast, actually analogize with [the above example of] English punctuated writing? Some might use bracketing, and that certainly must look just as strange and non-intuitive from a perspective of a long-term English punctuation user?:

If (you are happy and you know it)
{ Clap your hands ;
} // why would there be a semicolon before ending bracket?

FWiW: Replacing periods with semicolons [and dropping the "you(r)" to have an implied "you(r)" ;-)], each of the following make sense to me; are sensibly structured language, as might be used for coding in a programming language. And despite not directly matching to the RPG free form, each is consistent for the use of the semicolon, despite the character indicating the end of an /incomplete sentence/:

If (happy and know it) then do ;
Clap hands ;
End-If [of If-then-Do construct] ;

Do (If happy and know it) ;
Clap hands ;
End-Do [of Do-If construct] ;

Do While (happy and know it) ;
Clap hands ;
If (tired of clapping) ;
Leave ; // ;-)
End-If ;
End-Do While ;

I also have done quite well with separate lines delimiting the same fragment [incomplete sentence] in the same manner, as contrasted with the glyph as delimiter :-)

if (x>0) then(do) /* as CL is familiar to me */

EndDo /* despite ending "do" I align "end" with "if" */


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.