Re: VMS Pascal article

Liste des GroupesRevenir à co vms 
Sujet : Re: VMS Pascal article
De : cross (at) *nospam* spitfire.i.gajendra.net (Dan Cross)
Groupes : comp.os.vms
Date : 03. Jan 2025, 16:11:43
Autres entêtes
Organisation : PANIX Public Access Internet and UNIX, NYC
Message-ID : <vl8unf$99n$1@reader2.panix.com>
References : 1
User-Agent : trn 4.0-test77 (Sep 1, 2010)
In article <vl3pi8$2r2sr$1@dont-email.me>,
Arne Vajhøj  <arne@vajhoej.dk> wrote:
VMS Pascal for C/Java/C# programmers:
     https://www.vajhoej.dk/arne/articles/vmspascal.html
>
It is a "pre-release" - I am not sure I got it right.
>
So I would love some feedback.

You should get a native English speaker to edit for grammar.

C supports 'long double' which _may_ be the same as
`quadruple`, depending on the implementation, though
that's usually 80-bit floats.  There is also _Float128,
_Quad, and __float128.

You mention `packed array` for dealing with character data,
but mention the usual, non-packed variant only in passing
later.  It may be useful to explain the difference and why
it matters: `packed` originated on the CDC6500, where Wirth
wanted to fit multiple values into a machine word (that
was a word-oriented machine).  You curiously don't mention
the String type at all.  From
https://docs.vmssoftware.com/vsi-pascal-for-openvms-reference-manual/#STRING_TYPES_SEC:

|The STRING types provide a standard way for you to specify
|storage for varying-length character strings with a maximum
|length that can be specified at run time.

When discussing comparisons to other languages, you seem to
lump C, Java, and C# all in the same general bucket, which is
odd.  Java and C# are closer to one another, but compared to
C they support rather different programming paradigms (OO and
some functional versus strictly procedural, or pseudo-OO
implemented by the programmer).  It would be useful to state
clearly that VSI Pascal is a procedural language.

You write this:

|Pascal has pointers, but Pascal pointers are more like
|Java/C# references than C pointers.
|
|Pascal pointers can be used to allocate, to reference the
|allocated and to free the allocated. No fancy pointer arithmetic.

Don't bury the lede: if you're going to say that Pascal pointers
are "more like Java/C# references than C pointers" then say why
immediately, don't wait until the second sentence of the next
paragraph.

Also, "Pascal pointers can be used to allocate" doesn't make
much sense.  Pointers can be used to point to allocated storage,
sure, but they are not themselves a memory allocator.

Here's a potential rewrite:

|Pascal has pointers: they can be null, and can point to
|allocated storage. But unlike C, they do not support pointer
|arithmetic.  In this sense, they are closer to references in
|Java and C#.

I would not say that 'chr' and 'ord' are like casts in C.
Pascal is strongly, statically typed; C is weakly typed with
implicit conversions.  Conversion between characters and integer
types in Pascal is an explicit operation, but `int c = 'a' + 1;`
is perfectly legal in C.

You give two C equivalents of, `round`: `lround` and
`ceil(v + 0.5)`.  Surely the latter should be `trunc(v + 0.5)`:

term% cat d.c
#include <stdio.h>
#include <math.h>

int
main()
{
        printf("ceil(0.2 + 0.5) = %g\n", ceil(0.2 + 0.5));
        printf("ceil(0.6 + 0.5) = %g\n", ceil(0.6 + 0.5));
        printf("trunc(0.6 + 0.5) = %g\n", trunc(0.6 + 0.5));
        return 0;
}
term% make d
cc     d.c   -o d
: chandra; ./d
ceil(0.2 + 0.5) = 1
ceil(0.6 + 0.5) = 2
trunc(0.6 + 0.5) = 1
term%

But, consider negative numbers, and note that one would still
have to do a conversion to an integer type.

Similarly, Java's `Math.ceil` is not the same as Pascal's
`trunc`, unless the number is negative, and again there's the
integer conversion to consider.

Your C equivalent of `substr` is not correct; exercise left to
the reader (consider what happens when `ix` is beyond the end of
the string).  For that matter, this is true of the VSI Pascal
example as well: you should specify the preconditions that must
be true.

You may want to mention that strings are origin 1, not origin 0,
as in most syntactically C-like languages.  Also, array bounds
are inclusive in Pascal, unlike in C et al where the upper bound
is exclusive: `array [0..10] of integer` has 11 elements in
Pascal, while `array [1..10] of integer` has 10.

`readln` and `fgets` are not similar in that `readln` strips the
line ending sequence, and `fgets` does not.

`f = fopen,fnm "r");` is an obvious typo.
`while not eof(f)) do` is an obvious typo.

You might want to mention what `reset` and `rewrite` do.  You
might want to mention `extend` and compare to `fopen(..., "a")`
or whatever.

You may want to mention that Pascal, the semicolon is a
statement separator, not a terminator, and hence why the last
"END" in the protocol is followed by "." and not ";".

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.

- Dan C.


Date Sujet#  Auteur
1 Jan 25 * VMS Pascal article72Arne Vajhøj
1 Jan 25 +* Re: VMS Pascal article3Chris Townley
1 Jan 25 i+- Re: VMS Pascal article1Arne Vajhøj
1 Jan 25 i`- Re: VMS Pascal article1Dennis Boone
2 Jan 25 +* Re: VMS Pascal article18Marc Van Dyck
2 Jan 25 i`* Re: VMS Pascal article17Arne Vajhøj
3 Jan 25 i +* Re: VMS Pascal article5Lawrence D'Oliveiro
3 Jan 25 i i`* Re: VMS Pascal article4Arne Vajhøj
3 Jan 25 i i +* Re: VMS Pascal article2Lawrence D'Oliveiro
3 Jan 25 i i i`- Re: VMS Pascal article1Robert A. Brooks
3 Jan 25 i i `- Re: VMS Pascal article1Simon Clubley
3 Jan 25 i `* Re: VMS Pascal article11Arne Vajhøj
3 Jan 25 i  `* Re: VMS Pascal article10Robert A. Brooks
3 Jan 25 i   `* Re: VMS Pascal article9Arne Vajhøj
3 Jan 25 i    `* Re: VMS Pascal article8Robert A. Brooks
3 Jan 25 i     `* Re: VMS Pascal article7Arne Vajhøj
3 Jan 25 i      `* Re: VMS Pascal article6Robert A. Brooks
4 Jan 25 i       `* Re: SDL, SDLC, PL/I (was Re: VMS Pascal article)5Stephen Hoffman
4 Jan 25 i        +* Re: SDL, SDLC, PL/I (was Re: VMS Pascal article)3Arne Vajhøj
6 Jan 25 i        i`* Re: SDL, SDLC, PL/I (was Re: VMS Pascal article)2Simon Clubley
6 Jan 25 i        i `- Re: SDL, SDLC, PL/I (was Re: VMS Pascal article)1Robert A. Brooks
4 Jan 25 i        `- Re: SDL, SDLC, PL/I (was Re: VMS Pascal article)1Lawrence D'Oliveiro
3 Jan 25 +- Re: VMS Pascal article1David Meyer
3 Jan 25 +* Re: VMS Pascal article24Dan Cross
3 Jan 25 i`* Re: VMS Pascal article23Arne Vajhøj
3 Jan 25 i `* Re: VMS Pascal article22Dan Cross
3 Jan 25 i  `* Re: VMS Pascal article21Arne Vajhøj
3 Jan 25 i   `* Re: VMS Pascal article20Dan Cross
3 Jan 25 i    `* Re: VMS Pascal article19Arne Vajhøj
3 Jan 25 i     +* Re: VMS Pascal article4Dan Cross
3 Jan 25 i     i+* Re: VMS Pascal article2Dan Cross
4 Jan 25 i     ii`- Re: VMS Pascal article1Arne Vajhøj
4 Jan 25 i     i`- Re: VMS Pascal article1Arne Vajhøj
3 Jan 25 i     +* Re: VMS Pascal article2Lawrence D'Oliveiro
4 Jan 25 i     i`- Re: VMS Pascal article1Arne Vajhøj
5 Jan 25 i     `* Coding examples (Re: VMS Pascal article)12David Meyer
5 Jan 25 i      +* Re: Coding examples (Re: VMS Pascal article)2Arne Vajhøj
5 Jan 25 i      i`- Re: Coding examples (Re: VMS Pascal article)1Arne Vajhøj
5 Jan 25 i      `* Re: Coding examples (Re: VMS Pascal article)9Stephen Hoffman
6 Jan 25 i       `* Re: Coding examples (Re: VMS Pascal article)8Marc Van Dyck
6 Jan 25 i        +- Re: Coding examples (Re: VMS Pascal article)1Craig A. Berry
6 Jan 25 i        `* Re: Coding examples (Re: VMS Pascal article)6Arne Vajhøj
6 Jan 25 i         +- Re: Coding examples (Re: VMS Pascal article)1Arne Vajhøj
7 Jan 25 i         +- Re: Coding examples (Re: VMS Pascal article)1mjos_examine
8 Jan 25 i         `* Re: Coding examples (Re: VMS Pascal article)3Craig A. Berry
8 Jan 25 i          `* Re: Coding examples (Re: VMS Pascal article)2Arne Vajhøj
8 Jan 25 i           `- Re: Coding examples (Re: VMS Pascal article)1Lawrence D'Oliveiro
4 Jan 25 +- Re: VMS Pascal article1Martin Vorländer
6 Jan 25 +* Re: VMS Pascal article23John Reagan
7 Jan 25 i`* Re: VMS Pascal article22John Reagan
7 Jan 25 i +* Re: VMS Pascal article20Dan Cross
7 Jan 25 i i`* Re: VMS Pascal article19John Reagan
8 Jan 25 i i `* Re: VMS Pascal article18Dan Cross
8 Jan 25 i i  `* Re: VMS Pascal article17Arne Vajhøj
8 Jan 25 i i   +* Re: VMS Pascal article5Dan Cross
9 Jan 25 i i   i+- Re: VMS Pascal article1Arne Vajhøj
9 Jan 25 i i   i+- Re: VMS Pascal article1Simon Clubley
9 Jan 25 i i   i`* Re: VMS Pascal article2jayjwa
10 Jan 25 i i   i `- Re: VMS Pascal article1Craig A. Berry
9 Jan 25 i i   `* Re: VMS Pascal article11Dave Froble
9 Jan 25 i i    +* Re: VMS Pascal article5Arne Vajhøj
9 Jan 25 i i    i`* Re: VMS Pascal article4Dan Cross
9 Jan 25 i i    i `* Re: VMS Pascal article3Simon Clubley
10 Jan 25 i i    i  `* Re: VMS Pascal article2Simon Clubley
10 Jan 25 i i    i   `- Re: VMS Pascal article1Arne Vajhøj
9 Jan 25 i i    `* Re: VMS Pascal article5Arne Vajhøj
9 Jan 25 i i     +* Re: VMS Pascal article2Robert A. Brooks
9 Jan 25 i i     i`- Re: VMS Pascal article1Arne Vajhøj
9 Jan 25 i i     `* Re: VMS Pascal article2Simon Clubley
9 Jan 25 i i      `- Re: VMS Pascal article1Arne Vajhøj
8 Jan 25 i `- Re: VMS Pascal article1Arne Vajhøj
8 Jan 25 `- Re: VMS Pascal article1Arne Vajhøj

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal