IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New It is not just you
I'm guessing that an "end block" is a block that does final cleanup whenever you exit. I'm further guessing that it isn't named that in PL/I, and Barry is just calling it that because that is what it would be called in Perl.

But I'm kinda fishing here, and wouldn't be very confident in that guess...

Cheers,
Ben
"good ideas and bad code build communities, the other three combinations do not"
- [link|http://archives.real-time.com/pipermail/cocoon-devel/2000-October/003023.html|Stefano Mazzocchi]
New It's both of you
Blocks are like code between {} in Perl.

Given the following code:

\nBLOCK_A:\n BEGIN;\n   some code\n   BLOCK_B:\n     BEGIN;\n        some code within block b\n     END;  /* unnamed end block - end the last block defined, ie: B\n   BLOCK_C:\n     BEGIN;\n        some code within block c\n     END;  /* unnamed end block - end the last block defined, ie: C\n   Some more code\n END BLOCK_A; /* Named end block */\n


See how the ends balance the begins?
Now look at this:

\n\nBLOCK_A:\n BEGIN;\n   some code\n   BLOCK_B:\n     BEGIN;\n        some code within block b\n\n   BLOCK_C:\n     BEGIN;\n        some code within block c\n   Some more code\n END BLOCK_A; /* Named end block */   \n


When an END has a name, the compiler KNOWS which block
you are ending. So it doesn't bother trying to balance
opening and closing blocks. This code is perfectly
legal.

The BLOCKS can be part of inner procedures, flow control, part of
"IF"s, etc. I'm leaving that out of the example to show the
minimum amount of code.

Feels dangerous to me.

New Not what threw me
... you can are allowed not to ...
After seeing your clarification, I assume you meant either "can" or "are allowed", but accidentally typed both things you were thinking. Either way, the named end block does look useful.
===

Implicitly condoning stupidity since 2001.
New How does it know where the blocks end?
Does it use indentation? Does it nest them? (So that BLOCK_C would be in BLOCK_B.) Does it assume that they don't nest? (So BLOCK_C is not in BLOCK_B but "Some more code" accidentally is in BLOCK_C.) Does it depend on cues that depend on the kind of block? (So an IF might naturally terminate at an unexpected ELSE while a simple block remains open...)

It seems like a potentially confusing feature unless the rules are clear. If they are simple (eg it just assumes that when you close a named block then you close all other open blocks there) then it seems like a minor piece of syntactic sugar.

Anyways my limited understanding was that PL/I had exactly this kind of DWIMery built-in, which is why people who disliked Perl tended to likewise dislike PL/I.

Cheers,
Ben
"good ideas and bad code build communities, the other three combinations do not"
- [link|http://archives.real-time.com/pipermail/cocoon-devel/2000-October/003023.html|Stefano Mazzocchi]
New It doesn't
Space does not matter, I just did that to show you.
Only on the final END does it matter.
This sugar is meant for when there are multiple ends,
one after the other, with no code in between being executed.


And like I said, there are many things I like about it.
But this threw me as a major danger.
New There must be SOME rule
Obviously when it parses that code it inserts in the needed ENDs.

My question is where and why it decides to insert them.

If you don't (or can't) know that reliably, then this definitely is very dangerous since you will never be sure what that snippet will do.

Ben
"good ideas and bad code build communities, the other three combinations do not"
- [link|http://archives.real-time.com/pipermail/cocoon-devel/2000-October/003023.html|Stefano Mazzocchi]
New Yup
At the final named "END"
New So it nests blocks
In your example, BLOCK_C is inside of BLOCK_B, and "some more code" is also in BLOCK_C (and hence in BLOCK_B).

Seems sane enough. I just wouldn't name any ENDs. :-)

(Logic that is nested deeply enough that removing the END statements seems like a big win has obvious problems - namely that it is nested too deeply for my sanity.)

Cheers,
Ben
"good ideas and bad code build communities, the other three combinations do not"
- [link|http://archives.real-time.com/pipermail/cocoon-devel/2000-October/003023.html|Stefano Mazzocchi]
New Breaks a coding practice of mine
I ALWAYS comment the ending brace of blocks.
So it would be natural for me to name the END statement.

Which means I am open to breakage if I ever miss a name.
New Re: How does it know where the blocks end?
If the END is followed by a <statement-label> (before the semicolon), it closes that block and any unclosed interior blocks. If the END is not followed be a <statement-label>, it simply closes the preceding unclosed block.
If a statement-label follows END, the END statement closes the unclosed group or block headed by the nearest preceding DO, SELECT, BEGIN, or PROCEDURE statement having that statement-label. It also closes any unclosed groups or blocks physically within that group or block; this is known as multiple closure.

If a statement-label does not follow END, the END statement closes the one group or block headed by the nearest preceding DO, SELECT, BEGIN, or PROCEDURE statement for which there is no other corresponding END statement.
[link|http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/ibm3l101/7.17?DT=19950506201638|IBM Link].
Alex

In every country and every age, the priest had been hostile to Liberty. -- Thomas Jefferson (1743-1826), US president
     MF Language choices - (broomberg) - (29)
         Re: MF Language choices - (deSitter) - (9)
             How would I check for XEDIT? - (broomberg) - (4)
                 tso %xedit dataset.name? no idea - (deSitter) - (2)
                     No Xedit - (broomberg) - (1)
                         ISPF can be very powerful. - (static)
                 no XEDIT - (cforde)
             REXX issues - (broomberg) - (3)
                 Re: REXX issues - (deSitter) - (2)
                     Where to get RXVSAM - (deSitter)
                     Thanks - (broomberg)
         Isn't there a modern version/update of QuickJob? - (tablizer)
         I know less about mainframes than you do but... - (ben_tilly) - (17)
             Yup. - (broomberg) - (16)
                 Is it just me? - (drewk) - (15)
                     It is not just you - (ben_tilly) - (9)
                         It's both of you - (broomberg) - (8)
                             Not what threw me - (drewk)
                             How does it know where the blocks end? - (ben_tilly) - (6)
                                 It doesn't - (broomberg) - (4)
                                     There must be SOME rule - (ben_tilly) - (3)
                                         Yup - (broomberg) - (2)
                                             So it nests blocks - (ben_tilly) - (1)
                                                 Breaks a coding practice of mine - (broomberg)
                                 Re: How does it know where the blocks end? - (a6l6e6x)
                     I took it: - (folkert) - (4)
                         I wish - (broomberg) - (3)
                             Feels very old-fashioned. - (static) - (2)
                                 Hand code baby - (broomberg) - (1)
                                     ... and I thought of that, too. - (static)

Oh, we're on?
92 ms