Sujet : Re: VMS Pascal article
De : cross (at) *nospam* spitfire.i.gajendra.net (Dan Cross)
Groupes : comp.os.vmsDate : 03. Jan 2025, 19:51:37
Autres entêtes
Organisation : PANIX Public Access Internet and UNIX, NYC
Message-ID : <vl9bjp$eq3$1@reader2.panix.com>
References : 1 2 3 4
User-Agent : trn 4.0-test77 (Sep 1, 2010)
In article <
vl9aln$o72$1@dont-email.me>, Arne Vajhøj <
arne@vajhoej.dk> wrote:
On 1/3/2025 1:17 PM, Dan Cross wrote:
In article <67781447$0$711$14726298@news.sunsite.dk>,
Arne Vajhøj <arne@vajhoej.dk> wrote:
On 1/3/2025 10:11 AM, Dan Cross wrote:
`readln` and `fgets` are not similar in that `readln` strips the
line ending sequence, and `fgets` does not.
>
Close enough for the purpose of this article.
Perhaps. I may be worth an asterisk, as often C programmers
will want to write:
while ((s = fgets(s, len, fp)) != NULL) {
char *nl = strchr(s, '\n');
if (nl != NULL)
*nl = '\0';
}
Which is a bit more cumbersome than the Pascal equivalent. When
carriage returns get mixed in, it gets even nastier, so much so
that one may just write a helper function to deal with it.
>
I think you are right. I have added a note.
>
`f = fopen,fnm "r");` is an obvious typo.
`while not eof(f)) do` is an obvious typo.
>
Fixed.
Fixed, but the comparison to C is slightly wrong:
`while not(eof(f)) do` is not exactly the same as
`while(!feof(f))`. In particular, while in VSI Pascal `EOF(f)`
will be true on the first iteration of the loop if `f` is empty,
the same is not true for `feof` from stdio: in order for `feof`
to be true, stdio must observe the end-of-file condition of `f`
via some input operation. This leads to awkward code sequences
like this:
ch = fgetc(fp);
while (!feof(fp)) {
/*
* Do something with `ch`
* ...
*/
ch = fgetc(fp);
}
>
C feof is a crap function.
>
I think I will drop feof completely and add fgetc
not returning EOF. I already have fgets not returning NULL.
>
The structure you present at the end as "equivalent" of a
varying character array is not correct. `integer16` is a signed
type, with a maximum value of 32,767. The length field for a
`varying [n] of char` is an integer subrange type with word
representation. That is, `length` is unsigned 0..max, where max
is <= 65,535.
>
Ooops.
>
You are right.
>
I was sure that the limit was 32K but it is 64K.
>
Fixed.
>
And also fixed in the description of VARYING further up.
You should seriously mention the STRING type, though.
>
I think VARYING OF CHAR is what is used most in VMS Pascal.
Weird; I can't imagine why. Regardless, it may be worthwhile to
at least mention it, since you state explicitly that there are
three types for representing textual, string-like data, but
VSI's documentation makes it clear that there are actually four.
Also, it's a bit of a bummer that you didn't mention nested
functions/procedures, which are among the cooler aspects of the
language:
$ type foo.pas
(* foo *)
program foo(output);
procedure hello;
procedure world(var who: String);
function punct: char;
begin
punct := '!'
end;
begin
who := 'World' + punct
end;
var
who: String (10);
begin
world(who);
writeln('Hello, ', who)
end;
begin
hello
end.
>
There is already an example. fac is inside testfac.
>
I will add a note about it.
Ah, I see it now; the lack of indentation makes it hard to spot.
- Dan C.
Date | Sujet | # | | Auteur |
1 Jan 25 | VMS Pascal article | 72 | | Arne Vajhøj |
1 Jan 25 |  Re: VMS Pascal article | 3 | | Chris Townley |
1 Jan 25 |   Re: VMS Pascal article | 1 | | Arne Vajhøj |
1 Jan 25 |   Re: VMS Pascal article | 1 | | Dennis Boone |
2 Jan 25 |  Re: VMS Pascal article | 18 | | Marc Van Dyck |
2 Jan 25 |   Re: VMS Pascal article | 17 | | Arne Vajhøj |
3 Jan 25 |    Re: VMS Pascal article | 5 | | Lawrence D'Oliveiro |
3 Jan 25 |     Re: VMS Pascal article | 4 | | Arne Vajhøj |
3 Jan 25 |      Re: VMS Pascal article | 2 | | Lawrence D'Oliveiro |
3 Jan 25 |       Re: VMS Pascal article | 1 | | Robert A. Brooks |
3 Jan 25 |      Re: VMS Pascal article | 1 | | Simon Clubley |
3 Jan 25 |    Re: VMS Pascal article | 11 | | Arne Vajhøj |
3 Jan 25 |     Re: VMS Pascal article | 10 | | Robert A. Brooks |
3 Jan 25 |      Re: VMS Pascal article | 9 | | Arne Vajhøj |
3 Jan 25 |       Re: VMS Pascal article | 8 | | Robert A. Brooks |
3 Jan 25 |        Re: VMS Pascal article | 7 | | Arne Vajhøj |
3 Jan 25 |         Re: VMS Pascal article | 6 | | Robert A. Brooks |
4 Jan 25 |          Re: SDL, SDLC, PL/I (was Re: VMS Pascal article) | 5 | | Stephen Hoffman |
4 Jan 25 |           Re: SDL, SDLC, PL/I (was Re: VMS Pascal article) | 3 | | Arne Vajhøj |
6 Jan 25 |            Re: SDL, SDLC, PL/I (was Re: VMS Pascal article) | 2 | | Simon Clubley |
6 Jan 25 |             Re: SDL, SDLC, PL/I (was Re: VMS Pascal article) | 1 | | Robert A. Brooks |
4 Jan 25 |           Re: SDL, SDLC, PL/I (was Re: VMS Pascal article) | 1 | | Lawrence D'Oliveiro |
3 Jan 25 |  Re: VMS Pascal article | 1 | | David Meyer |
3 Jan 25 |  Re: VMS Pascal article | 24 | | Dan Cross |
3 Jan 25 |   Re: VMS Pascal article | 23 | | Arne Vajhøj |
3 Jan 25 |    Re: VMS Pascal article | 22 | | Dan Cross |
3 Jan 25 |     Re: VMS Pascal article | 21 | | Arne Vajhøj |
3 Jan 25 |      Re: VMS Pascal article | 20 | | Dan Cross |
3 Jan 25 |       Re: VMS Pascal article | 19 | | Arne Vajhøj |
3 Jan 25 |        Re: VMS Pascal article | 4 | | Dan Cross |
3 Jan 25 |         Re: VMS Pascal article | 2 | | Dan Cross |
4 Jan 25 |          Re: VMS Pascal article | 1 | | Arne Vajhøj |
4 Jan 25 |         Re: VMS Pascal article | 1 | | Arne Vajhøj |
3 Jan 25 |        Re: VMS Pascal article | 2 | | Lawrence D'Oliveiro |
4 Jan 25 |         Re: VMS Pascal article | 1 | | Arne Vajhøj |
5 Jan 25 |        Coding examples (Re: VMS Pascal article) | 12 | | David Meyer |
5 Jan 25 |         Re: Coding examples (Re: VMS Pascal article) | 2 | | Arne Vajhøj |
5 Jan 25 |          Re: Coding examples (Re: VMS Pascal article) | 1 | | Arne Vajhøj |
5 Jan 25 |         Re: Coding examples (Re: VMS Pascal article) | 9 | | Stephen Hoffman |
6 Jan 25 |          Re: Coding examples (Re: VMS Pascal article) | 8 | | Marc Van Dyck |
6 Jan 25 |           Re: Coding examples (Re: VMS Pascal article) | 1 | | Craig A. Berry |
6 Jan 25 |           Re: Coding examples (Re: VMS Pascal article) | 6 | | Arne Vajhøj |
6 Jan 25 |            Re: Coding examples (Re: VMS Pascal article) | 1 | | Arne Vajhøj |
7 Jan 25 |            Re: Coding examples (Re: VMS Pascal article) | 1 | | mjos_examine |
8 Jan 25 |            Re: Coding examples (Re: VMS Pascal article) | 3 | | Craig A. Berry |
8 Jan 25 |             Re: Coding examples (Re: VMS Pascal article) | 2 | | Arne Vajhøj |
8 Jan 25 |              Re: Coding examples (Re: VMS Pascal article) | 1 | | Lawrence D'Oliveiro |
4 Jan 25 |  Re: VMS Pascal article | 1 | | Martin Vorländer |
6 Jan 25 |  Re: VMS Pascal article | 23 | | John Reagan |
7 Jan 25 |   Re: VMS Pascal article | 22 | | John Reagan |
7 Jan 25 |    Re: VMS Pascal article | 20 | | Dan Cross |
7 Jan 25 |     Re: VMS Pascal article | 19 | | John Reagan |
8 Jan 25 |      Re: VMS Pascal article | 18 | | Dan Cross |
8 Jan 25 |       Re: VMS Pascal article | 17 | | Arne Vajhøj |
8 Jan 25 |        Re: VMS Pascal article | 5 | | Dan Cross |
9 Jan 25 |         Re: VMS Pascal article | 1 | | Arne Vajhøj |
9 Jan 25 |         Re: VMS Pascal article | 1 | | Simon Clubley |
9 Jan 25 |         Re: VMS Pascal article | 2 | | jayjwa |
10 Jan 25 |          Re: VMS Pascal article | 1 | | Craig A. Berry |
9 Jan 25 |        Re: VMS Pascal article | 11 | | Dave Froble |
9 Jan 25 |         Re: VMS Pascal article | 5 | | Arne Vajhøj |
9 Jan 25 |          Re: VMS Pascal article | 4 | | Dan Cross |
9 Jan 25 |           Re: VMS Pascal article | 3 | | Simon Clubley |
10 Jan 25 |            Re: VMS Pascal article | 2 | | Simon Clubley |
10 Jan 25 |             Re: VMS Pascal article | 1 | | Arne Vajhøj |
9 Jan 25 |         Re: VMS Pascal article | 5 | | Arne Vajhøj |
9 Jan 25 |          Re: VMS Pascal article | 2 | | Robert A. Brooks |
9 Jan 25 |           Re: VMS Pascal article | 1 | | Arne Vajhøj |
9 Jan 25 |          Re: VMS Pascal article | 2 | | Simon Clubley |
9 Jan 25 |           Re: VMS Pascal article | 1 | | Arne Vajhøj |
8 Jan 25 |    Re: VMS Pascal article | 1 | | Arne Vajhøj |
8 Jan 25 |  Re: VMS Pascal article | 1 | | Arne Vajhøj |