Sujet : Re: Fun trick
De : johnrreagan (at) *nospam* earthlink.net (John Reagan)
Groupes : comp.os.vmsDate : 15. Jan 2025, 15:20:34
Autres entêtes
Organisation : i2pn2 (i2pn.org)
Message-ID : <23df7f2a0127c00e9af450b8e7b38dcf7c7ed5d8@i2pn2.org>
References : 1 2 3 4 5 6 7 8
User-Agent : Mozilla Thunderbird
On 1/14/2025 11:03 AM, Arne Vajhøj wrote:
On 1/13/2025 11:38 PM, Lawrence D'Oliveiro wrote:
On Mon, 13 Jan 2025 21:08:11 -0500, John Reagan wrote:
### They are probably most useful for modules, but why not allow
### them for programs?
Extended Pascal says only MODULEs so we just didn't
think about allowing them in PROGRAMs even though we allow [INITIALIZE].
>
Not sure what the point would be in having them in PROGRAMs, anyway.
Definitely most useful for modules. I was just wondering
why not allow it in programs as well.
It seems to have been explicit disallowed. The error message is:
%PASCAL-E-TOPROGRAM, TO BEGIN/END DO not allowed in PROGRAM
If one start to look for something useful then I would say that
TO BEGIN is just code after PROGRAM BEGIN, but TO END is more
than just code before PROGRAM END as it get triggered by other
program exits as well.
Demo:
$ type m.pas
module m(input,output);
to begin do writeln('m to begin');
to end do writeln('m to end');
end.
$ type p.pas
[inherit('m', 'sys$library:starlet')]
program p(input,output);
[initialize]
procedure init;
begin
writeln('init');
end;
procedure done;
begin
writeln('done');
end;
var
ent : integer64;
desblk : array [1..4] of integer;
cond : integer;
begin
writeln('begin');
desblk[1] := 0;
desblk[2] := iaddress(done);
desblk[3] := 0;
desblk[4] := iaddress(cond);
$dclexh(desblk);
$get_entropy(ent, 8);
if (ent mod 2) = 0 then $exit(SS$_NORMAL);
$canexh(desblk);
writeln('end');
end.
$ pas/env m
$ pas p
$ link p + m
$ run p
m to begin
init
begin
end
m to end
$ run p
m to begin
init
begin
done
m to end
$ run p
m to begin
init
begin
end
m to end
$ run p
m to begin
init
begin
done
m to end
Arne
I just looked. The TO BEGIN/END DO was added back in 1987 by a former developer (not me). I suspect that since the Extended Pascal standard only allows them in MODULEs, not PROGRAMs, that he just followed the draft standard at that point without considering that TO END DO is a little better than "code at the end".
Date | Sujet | # | | Auteur |
8 Jan 25 | Fun trick | 39 | | Arne Vajhøj |
8 Jan 25 |  Re: Fun trick | 1 | | Lawrence D'Oliveiro |
8 Jan 25 |  Re: Fun trick | 11 | | John Reagan |
8 Jan 25 |   Re: Fun trick | 10 | | Arne Vajhøj |
8 Jan 25 |    Re: Fun trick | 9 | | John Reagan |
8 Jan 25 |     Re: Fun trick | 2 | | Arne Vajhøj |
8 Jan 25 |      Re: Fun trick | 1 | | Arne Vajhøj |
8 Jan 25 |     Re: Fun trick | 6 | | Arne Vajhøj |
14 Jan 25 |      Re: Fun trick | 5 | | John Reagan |
14 Jan 25 |       Re: Fun trick | 4 | | Lawrence D'Oliveiro |
14 Jan 25 |        Re: Fun trick | 3 | | Arne Vajhøj |
14 Jan 25 |         Re: Fun trick | 1 | | Arne Vajhøj |
15 Jan 25 |         Re: Fun trick | 1 | | John Reagan |
8 Jan 25 |  Re: Fun trick | 26 | | hb0815 |
8 Jan 25 |   Re: Fun trick | 25 | | Arne Vajhøj |
8 Jan 25 |    Re: Fun trick | 24 | | hb0815 |
9 Jan 25 |     Re: Fun trick | 23 | | Arne Vajhøj |
9 Jan 25 |      Re: Fun trick | 22 | | hb0815 |
13 Jan 25 |       Re: Fun trick | 11 | | Arne Vajhøj |
17 Jan 25 |        GNU diff command, was: Re: Fun trick | 10 | | Simon Clubley |
17 Jan 25 |         Re: GNU diff command, was: Re: Fun trick | 9 | | Craig A. Berry |
17 Jan 25 |          Re: GNU diff command, was: Re: Fun trick | 8 | | Craig A. Berry |
19 Jan 25 |           Re: GNU diff command, was: Re: Fun trick | 7 | | hb0815 |
21 Jan 25 |            Re: GNU diff command, was: Re: Fun trick | 6 | | Craig A. Berry |
22 Jan 25 |             Re: GNU diff command, was: Re: Fun trick | 5 | | hb0815 |
22 Jan 25 |              Re: GNU diff command, was: Re: Fun trick | 4 | | Lawrence D'Oliveiro |
23 Jan 25 |               Re: GNU diff command, was: Re: Fun trick | 3 | | Robert A. Brooks |
24 Jan 25 |                Re: GNU diff command, was: Re: Fun trick | 2 | | Simon Clubley |
25 Jan 25 |                 Re: GNU diff command, was: Re: Fun trick | 1 | | Dave Froble |
13 Jan 25 |       Re: Fun trick | 10 | | Arne Vajhøj |
13 Jan 25 |        Re: Fun trick | 9 | | Lawrence D'Oliveiro |
13 Jan 25 |         Re: Fun trick | 8 | | Arne Vajhøj |
14 Jan 25 |          Re: Fun trick | 6 | | John Reagan |
14 Jan 25 |           Re: Fun trick | 5 | | Arne Vajhøj |
3 Feb 25 |            Cobol (was Re: Fun trick) | 1 | | Arne Vajhøj |
3 Feb 25 |            Re: Fun trick | 3 | | Arne Vajhøj |
3 Feb 25 |             Cobol (was: Re: Fun trick) | 2 | | Arne Vajhøj |
5 Feb 25 |              Re: Cobol | 1 | | Arne Vajhøj |
14 Jan 25 |          Re: Fun trick | 1 | | Lawrence D'Oliveiro |