• Re: VMS Pascal article

    From Martin =?UTF-8?Q?Vorl=C3=A4nder?=@21:1/5 to arne@vajhoej.dk on Sat Jan 4 12:41:31 2025
    Arne Vajh°j <arne@vajhoej.dk> schrieb:
    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.

    Arne,

    in your first example, the global variable declaration of v must come before the procedure declaration of add_one_and_print.

    cu,
    Martin

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From John Reagan@21:1/5 to All on Mon Jan 6 17:52:42 2025
    On 1/1/2025 11:12 AM, Arne Vajhøj 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.

    Arne

    I'll look and give feedback.

    John

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Arne_Vajh=C3=B8j?=@21:1/5 to All on Wed Jan 1 11:12:57 2025
    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.

    Arne

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Arne_Vajh=C3=B8j?=@21:1/5 to Chris Townley on Wed Jan 1 11:39:56 2025
    On 1/1/2025 11:31 AM, Chris Townley wrote:
    On 01/01/2025 16:12, Arne Vajhøj 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.

    Interesting - many thanks
    I was surprised to see that Pascal was created in 2970!

    Ooops. Let me fix that.

    Arne

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris Townley@21:1/5 to All on Wed Jan 1 16:31:53 2025
    On 01/01/2025 16:12, Arne Vajhøj 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.

    Arne

    Interesting - many thanks
    I was surprised to see that Pascal was created in 2970!

    --
    Chris

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dennis Boone@21:1/5 to All on Wed Jan 1 18:50:55 2025
    I was surprised to see that Pascal was created in 2970!

    In the year 3535, if Wirth is still alive...

    De

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Marc Van Dyck@21:1/5 to All on Thu Jan 2 11:01:50 2025
    Arne Vajh°j has brought this to us :
    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.

    Arne

    I like it.

    In the first section, you might also mention that VMS Pascal has
    excellent support in LSE/SCA - for those who still use DECset...

    Didn't see anything about the VARYING type and its so useful
    <varying>.BODY and <varying>.LENGTH functions, as well as READV and
    WRITEV. Probably the most important things to know if you have to
    manipulate character strings.

    May be also mention that the VMS Pascal compiler comes with declaration
    modules for all VMS system services and RTLs. Combined with LSE/SCA
    support, this makes system programming extremely easy.

    Ah, and also, good support of VMS Pascal by SDL...

    --
    Marc Van Dyck

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Arne_Vajh=C3=B8j?=@21:1/5 to Marc Van Dyck on Thu Jan 2 17:19:14 2025
    On 1/2/2025 5:01 AM, Marc Van Dyck wrote:
    Arne Vajhøj has brought this to us :
    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.

    In the first section, you might also mention that VMS Pascal has
    excellent support in LSE/SCA - for those who still use DECset...

    Added something about choices for editor.

    Didn't see anything about the VARYING type and its so useful
    <varying>.BODY and <varying>.LENGTH functions, as well as READV and
    WRITEV. Probably the most important things to know if you have to
    manipulate character strings.

    May be also mention that the VMS Pascal compiler comes with declaration modules for all VMS system services and RTLs. Combined with LSE/SCA
    support, this makes system programming extremely easy.

    Added mention of SYS$LIBRARY:STARLET and SYS$LIBRARY:LIB$ROUTINES and
    added example making 3 simple LIB$ calls.

    And used that to show and explain .BODY and .LENGTH, which made
    sense to me because that is where I typical use them.

    Ah, and also, good support of VMS Pascal by SDL...

    Too advanced for me.

    :-)

    Arne

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to All on Fri Jan 3 00:34:04 2025
    On Thu, 2 Jan 2025 17:19:14 -0500, Arne Vajhøj wrote:

    On 1/2/2025 5:01 AM, Marc Van Dyck wrote:

    Ah, and also, good support of VMS Pascal by SDL...

    Too advanced for me.

    SDL is just the common language used for defining interfaces. That’s how files like STARLET.PAS get automatically generated.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Arne_Vajh=C3=B8j?=@21:1/5 to Lawrence D'Oliveiro on Thu Jan 2 20:49:43 2025
    On 1/2/2025 7:34 PM, Lawrence D'Oliveiro wrote:
    On Thu, 2 Jan 2025 17:19:14 -0500, Arne Vajhøj wrote:
    On 1/2/2025 5:01 AM, Marc Van Dyck wrote:
    Ah, and also, good support of VMS Pascal by SDL...

    Too advanced for me.

    SDL is just the common language used for defining interfaces. That’s how files like STARLET.PAS get automatically generated.

    I know what it is is. Otherwise I could not have commented on
    the level.

    Arne

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Arne_Vajh=C3=B8j?=@21:1/5 to All on Thu Jan 2 20:52:10 2025
    On 1/2/2025 5:19 PM, Arne Vajhøj wrote:
    On 1/2/2025 5:01 AM, Marc Van Dyck wrote:
    Ah, and also, good support of VMS Pascal by SDL...

    Too advanced for me.

    :-)

    But speaking of SDL.

    Does anybody know what VSI's plan is for SDL on VMS x86-64?
    Rewrite?

    Arne

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to All on Fri Jan 3 02:53:16 2025
    On Thu, 2 Jan 2025 20:49:43 -0500, Arne Vajhøj wrote:

    On 1/2/2025 7:34 PM, Lawrence D'Oliveiro wrote:

    On Thu, 2 Jan 2025 17:19:14 -0500, Arne Vajhøj wrote:

    On 1/2/2025 5:01 AM, Marc Van Dyck wrote:
    Ah, and also, good support of VMS Pascal by SDL...

    Too advanced for me.

    SDL is just the common language used for defining interfaces. That’s
    how files like STARLET.PAS get automatically generated.

    I know what it is is.

    It’s also not that hard to understand, if you take the “Rosetta Stone” approach of looking at the original SDL source and comparing with its
    output for a particular language that you know.

    There was also one called MDL, if I recall rightly, which looked like it
    was more on the MACRO level.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Robert A. Brooks@21:1/5 to Lawrence D'Oliveiro on Thu Jan 2 22:30:36 2025
    On 1/2/2025 9:53 PM, Lawrence D'Oliveiro wrote:
    On Thu, 2 Jan 2025 20:49:43 -0500, Arne Vajhøj wrote:

    On 1/2/2025 7:34 PM, Lawrence D'Oliveiro wrote:

    On Thu, 2 Jan 2025 17:19:14 -0500, Arne Vajhøj wrote:

    On 1/2/2025 5:01 AM, Marc Van Dyck wrote:
    Ah, and also, good support of VMS Pascal by SDL...

    Too advanced for me.

    SDL is just the common language used for defining interfaces. That’s
    how files like STARLET.PAS get automatically generated.

    I know what it is is.

    It’s also not that hard to understand, if you take the “Rosetta Stone” approach of looking at the original SDL source and comparing with its
    output for a particular language that you know.

    There was also one called MDL, if I recall rightly, which looked like it
    was more on the MACRO level.

    Depending on whom you ask, it was either Module or Maynard Definition Language.

    --
    --- Rob

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Robert A. Brooks@21:1/5 to All on Thu Jan 2 22:29:19 2025
    On 1/2/2025 8:52 PM, Arne Vajhøj wrote:
    On 1/2/2025 5:19 PM, Arne Vajhøj wrote:
    On 1/2/2025 5:01 AM, Marc Van Dyck wrote:
    Ah, and also, good support of VMS Pascal by SDL...

    Too advanced for me.

    :-)

    But speaking of SDL.

    Does anybody know what VSI's plan is for SDL on VMS x86-64?
    Rewrite?

    It's written in C++ so we were waiting for a native C++ compiler.

    As it turns out, SDL uncovered some dark areas of the compiler that needed addressing.

    We have a working SDL on X86 now.


    --

    --- Rob

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Arne_Vajh=C3=B8j?=@21:1/5 to Robert A. Brooks on Thu Jan 2 22:32:21 2025
    On 1/2/2025 10:29 PM, Robert A. Brooks wrote:
    On 1/2/2025 8:52 PM, Arne Vajhøj wrote:
    On 1/2/2025 5:19 PM, Arne Vajhøj wrote:
    On 1/2/2025 5:01 AM, Marc Van Dyck wrote:
    Ah, and also, good support of VMS Pascal by SDL...

    Too advanced for me.

    :-)

    But speaking of SDL.

    Does anybody know what VSI's plan is for SDL on VMS x86-64?
    Rewrite?

    It's written in C++ so we were waiting for a native C++ compiler.

    As it turns out, SDL uncovered some dark areas of the compiler that needed addressing.

    We have a working SDL on X86 now.

    I thought it was PL/I. Which is why I asked.

    Arne

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Robert A. Brooks@21:1/5 to All on Thu Jan 2 22:48:35 2025
    On 1/2/2025 10:32 PM, Arne Vajhøj wrote:
    On 1/2/2025 10:29 PM, Robert A. Brooks wrote:
    On 1/2/2025 8:52 PM, Arne Vajhøj wrote:
    On 1/2/2025 5:19 PM, Arne Vajhøj wrote:
    On 1/2/2025 5:01 AM, Marc Van Dyck wrote:
    Ah, and also, good support of VMS Pascal by SDL...

    Too advanced for me.

    :-)

    But speaking of SDL.

    Does anybody know what VSI's plan is for SDL on VMS x86-64?
    Rewrite?

    It's written in C++ so we were waiting for a native C++ compiler.

    As it turns out, SDL uncovered some dark areas of the compiler that needed >> addressing.

    We have a working SDL on X86 now.

    I thought it was PL/I. Which is why I asked.

    Rewritten in the early 2000's.

    --

    --- Rob

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Meyer@21:1/5 to All on Fri Jan 3 20:52:59 2025
    You wrote it for me! Many thanks. It looks like a very useful document.

    --
    David Meyer
    Takarazuka, Japan
    papa@sdf.org

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Simon Clubley@21:1/5 to arne@vajhoej.dk on Fri Jan 3 13:10:03 2025
    On 2025-01-02, Arne Vajh°j <arne@vajhoej.dk> wrote:
    On 1/2/2025 7:34 PM, Lawrence D'Oliveiro wrote:
    On Thu, 2 Jan 2025 17:19:14 -0500, Arne Vajh°j wrote:
    On 1/2/2025 5:01 AM, Marc Van Dyck wrote:
    Ah, and also, good support of VMS Pascal by SDL...

    Too advanced for me.

    SDL is just the common language used for defining interfaces. That?s how
    files like STARLET.PAS get automatically generated.

    I know what it is is. Otherwise I could not have commented on
    the level.


    The open source ecosystem equivalent is called swig, which comes across
    as much more flexible than SDL:

    https://www.swig.org/tutorial.html

    Simon.

    --
    Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
    Walking destinations on a map are further away than they appear.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Arne_Vajh=C3=B8j?=@21:1/5 to Robert A. Brooks on Fri Jan 3 07:59:58 2025
    On 1/2/2025 10:48 PM, Robert A. Brooks wrote:
    On 1/2/2025 10:32 PM, Arne Vajhøj wrote:
    On 1/2/2025 10:29 PM, Robert A. Brooks wrote:
    On 1/2/2025 8:52 PM, Arne Vajhøj wrote:
    But speaking of SDL.

    Does anybody know what VSI's plan is for SDL on VMS x86-64?
    Rewrite?

    It's written in C++ so we were waiting for a native C++ compiler.

    As it turns out, SDL uncovered some dark areas of the compiler that
    needed
    addressing.

    We have a working SDL on X86 now.

    I thought it was PL/I. Which is why I asked.

    Rewritten in the early 2000's.

    Ah. So it was rewritten for Itanium instead of being AEST'ed.

    I wonder whether it was because someone at HP decided
    to do the right thing or because AEST couldn't handle
    it.

    Arne

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to arne@vajhoej.dk on Fri Jan 3 15:11:43 2025
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Robert A. Brooks@21:1/5 to All on Fri Jan 3 09:30:37 2025
    On 1/3/2025 7:59 AM, Arne Vajhøj wrote:
    On 1/2/2025 10:48 PM, Robert A. Brooks wrote:
    On 1/2/2025 10:32 PM, Arne Vajhøj wrote:

    I thought it was PL/I. Which is why I asked.

    Rewritten in the early 2000's.

    Ah. So it was rewritten for Itanium instead of being AEST'ed.

    I wonder whether it was because someone at HP decided
    to do the right thing or because AEST couldn't handle
    it.

    I am not aware of an attempt to AEST it; it was rewritten
    by Walter Breu (sp?) of HP Germany. He was not in VMS Engineering,
    so I wasn't paying a lot of attention when he was doing the work.

    Pretty sure it was part of the "get rid of all PL/I" initiative.

    --

    --- Rob

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Arne_Vajh=C3=B8j?=@21:1/5 to Dan Cross on Fri Jan 3 11:45:59 2025
    On 1/3/2025 10:11 AM, Dan Cross wrote:
    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.

    C supports 'long double' which _may_ be the same as
    `quadruple`, depending on the implementation, though
    that's usually 80-bit floats.

    Very good point. It is 128 bit on VMS unless using /L_DOUBLE=64.

    Added.

    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.

    It was the best explanation I could come up with.

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

    Ooops. All ceil should be floor.

    Fixed.

    But, consider negative numbers,

    Very good point.

    I have added notes.

    and note that one would still
    have to do a conversion to an integer type.

    Yes.

    Fixed.

    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.

    Invalid index or length causes an exception in VMS Pascal.

    But I don't want to get into that level of detail.

    `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.


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

    Fixed.

    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 article is more what to do than why to do that.

    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.

    Arne

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to arne@vajhoej.dk on Fri Jan 3 18:17:25 2025
    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:
    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.

    C supports 'long double' which _may_ be the same as
    `quadruple`, depending on the implementation, though
    that's usually 80-bit floats.

    Very good point. It is 128 bit on VMS unless using /L_DOUBLE=64.

    Added.

    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.

    It was the best explanation I could come up with.

    Why not simply say that Pascal is strongly typed, and C is not?
    Conversion from a Pascal character to an integer type requires
    using an explicit conversion operation; in C you don't, though
    one may cast.

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

    Ooops. All ceil should be floor.

    Fixed.

    But, consider negative numbers,

    Very good point.

    I have added notes.

    and note that one would still
    have to do a conversion to an integer type.

    Yes.

    Fixed.

    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.

    Invalid index or length causes an exception in VMS Pascal.

    But I don't want to get into that level of detail.

    *Shrug* it's your document, but in C that'll just be UB.

    `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.

    `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);
    }

    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 article is more what to do than why to do that.

    It's actually a rather important syntactical detail of the
    language, and the reason one can often omit semi-colons in
    surprising ways. It's the reason one can write, e.g.:

    if foo <> 0 then x := 1 else y := 2;

    But hey, it's your document.

    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 would also seriously recommend revising the section on
    pointers.

    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.
    $ pascal foo.pas
    $ link foo
    $ run foo
    Hello, World!
    $

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to arne@vajhoej.dk on Fri Jan 3 18:51:37 2025
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Arne_Vajh=C3=B8j?=@21:1/5 to Dan Cross on Fri Jan 3 13:35:35 2025
    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.

    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.

    Arne

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Arne_Vajh=C3=B8j?=@21:1/5 to Dan Cross on Fri Jan 3 14:58:22 2025
    On 1/3/2025 1:51 PM, Dan Cross wrote:
    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>,
    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.

    I never use string (on VMS).

    $ search sys$common:[syshlp.examples.pascal]*.pas varying
    $ search sys$common:[syshlp.examples.pascal]*.pas "string("

    indicate that whoever write VMS Pascal examples also prefer
    varying of char over string.

    If I were to guess about why, then I believe it is historic
    reasons. varying of char has been there since like forever.
    string was added with ISO Pascal support later.

    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.

    Good point.

    I have updated.

    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.

    I don't indent them.

    With the blank lines I put in then I feel that indenting
    nested procedures/functions would make it too much space.

    But it is a close decision. In C# I do not use blank lines
    and I do indent local methods.

    Same code:

    using System;

    public class Program
    {
    public static void TestFac()
    {
    int Fac(int n)
    {
    if(n < 2)
    {
    return 1;
    }
    else
    {
    return n * Fac(n - 1);
    }
    }
    for(int i = 0; i < 6; i++)
    {
    Console.WriteLine("fac({0})={1}", i, Fac(i));
    }
    }
    public static void Main(string[] args)
    {
    TestFac();
    }
    }

    Arne

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to arne@vajhoej.dk on Fri Jan 3 21:24:09 2025
    In article <6778415e$0$708$14726298@news.sunsite.dk>,
    Arne Vajhøj <arne@vajhoej.dk> wrote:
    On 1/3/2025 1:51 PM, Dan Cross wrote:
    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>,
    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.

    I never use string (on VMS).

    $ search sys$common:[syshlp.examples.pascal]*.pas varying
    $ search sys$common:[syshlp.examples.pascal]*.pas "string("

    indicate that whoever write VMS Pascal examples also prefer
    varying of char over string.

    If I were to guess about why, then I believe it is historic
    reasons. varying of char has been there since like forever.
    string was added with ISO Pascal support later.

    I suspect that's close, but ISO Pascal doesn't have a 'VARYING'
    array type, either.

    I suspect you're referring to what ISO calls "Extended Pascal"
    (ISO 10206); ISO Pascal (ISO 7185) doesn't support a `String`
    type of either the VSI Pascal form or the Turbo
    Pascal/Delphi/FreePascal form, only manifest string literals and
    `packed array [1..n] of char`. Of course, one can define a type
    alias, and ISO 7185 says this:

    |Any type designated packed and denoted by an array-type having
    |as its index-type a denotation of a subrange-type specifying a
    |smallest value of 1 and a largest value of greater than 1, and
    |having as its component-type a denotation of the char-type,
    |shall be designated a string-type.

    An annoyance with ISO Pascal is that an array's size is part of
    its type, and there is no separate slice type that could act
    as a window into an array independent of size and be passed
    around, so it is difficult to write procedures and functions
    that operate on e.g. strings, generically. See also, https://www.lysator.liu.se/c/bwk-on-pascal.html

    However, these deficiencies are largely addressed in ISO 10206
    Extended Pascal, which provides a variable-length string type
    and permits conformant array parameters, which for VSI Pascal
    appear to monomorphize over the argument type.

    It's perhaps worth noting that Wirth's subsequent languages,
    particularly Oberon, didn't have most of these problems.

    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.

    Good point.

    I have updated.

    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.

    I don't indent them.

    With the blank lines I put in then I feel that indenting
    nested procedures/functions would make it too much space.

    Meh, personally I sacrifice horizontal space for readability,
    but I suppose styles differ.

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to Dan Cross on Fri Jan 3 21:51:43 2025
    In article <vl9khp$cdg$1@reader2.panix.com>,
    Dan Cross <cross@spitfire.i.gajendra.net> wrote:
    In article <6778415e$0$708$14726298@news.sunsite.dk>,
    Arne Vajhøj <arne@vajhoej.dk> wrote:
    On 1/3/2025 1:51 PM, Dan Cross wrote:
    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>,
    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.

    I never use string (on VMS).

    $ search sys$common:[syshlp.examples.pascal]*.pas varying
    $ search sys$common:[syshlp.examples.pascal]*.pas "string("

    indicate that whoever write VMS Pascal examples also prefer
    varying of char over string.

    If I were to guess about why, then I believe it is historic
    reasons. varying of char has been there since like forever.
    string was added with ISO Pascal support later.

    I suspect that's close, but ISO Pascal doesn't have a 'VARYING'
    array type, either.

    I suspect you're referring to what ISO calls "Extended Pascal"
    (ISO 10206); ISO Pascal (ISO 7185) doesn't support a `String`
    type of either the VSI Pascal form or the Turbo
    Pascal/Delphi/FreePascal form, only manifest string literals and
    `packed array [1..n] of char`. Of course, one can define a type
    alias, and ISO 7185 says this:

    |Any type designated packed and denoted by an array-type having
    |as its index-type a denotation of a subrange-type specifying a
    |smallest value of 1 and a largest value of greater than 1, and
    |having as its component-type a denotation of the char-type,
    |shall be designated a string-type.

    An annoyance with ISO Pascal is that an array's size is part of
    its type, and there is no separate slice type that could act
    as a window into an array independent of size and be passed
    around, so it is difficult to write procedures and functions
    that operate on e.g. strings, generically. See also, >https://www.lysator.liu.se/c/bwk-on-pascal.html

    However, these deficiencies are largely addressed in ISO 10206
    Extended Pascal, which provides a variable-length string type
    and permits conformant array parameters, which for VSI Pascal
    appear to monomorphize over the argument type.

    Actually, I guess that conformant array parameterss were in ISO
    7185, which had two "levels" of compliance; level 0 omitted them
    and level 1 includes them. That language is retained in ISO
    10206. Original, Wirth Pascal does not have them.

    Extended Pascal's variable string type appears more or less
    identical to the string type in VSI Pascal.

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to All on Fri Jan 3 21:34:46 2025
    On Fri, 3 Jan 2025 14:58:22 -0500, Arne Vajhøj wrote:

    ... I feel that indenting nested
    procedures/functions would make it too much space.

    At an indentation step of 4 columns and a window width of typically 100 columns, I find that leaves room for plenty of indentation steps.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Arne_Vajh=C3=B8j?=@21:1/5 to Lawrence D'Oliveiro on Fri Jan 3 18:54:57 2025
    On 1/3/2025 4:34 PM, Lawrence D'Oliveiro wrote:
    On Fri, 3 Jan 2025 14:58:22 -0500, Arne Vajhøj wrote:
    ... I feel that indenting nested
    procedures/functions would make it too much space.

    At an indentation step of 4 columns and a window width of typically 100 columns, I find that leaves room for plenty of indentation steps.

    I am typical at 132 width.

    Width is not the problem.

    But it looks like Iceland on a map of the northern
    atlantic ocean.

    Arne

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Arne_Vajh=C3=B8j?=@21:1/5 to Dan Cross on Fri Jan 3 18:53:23 2025
    On 1/3/2025 4:24 PM, Dan Cross wrote:
    In article <6778415e$0$708$14726298@news.sunsite.dk>,
    Arne Vajhøj <arne@vajhoej.dk> wrote:
    On 1/3/2025 1:51 PM, Dan Cross wrote:
    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>,
    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.

    I never use string (on VMS).

    $ search sys$common:[syshlp.examples.pascal]*.pas varying
    $ search sys$common:[syshlp.examples.pascal]*.pas "string("

    indicate that whoever write VMS Pascal examples also prefer
    varying of char over string.

    If I were to guess about why, then I believe it is historic
    reasons. varying of char has been there since like forever.
    string was added with ISO Pascal support later.

    I suspect that's close, but ISO Pascal doesn't have a 'VARYING'
    array type, either.

    I am saying that VMS Pascal had VARYING before ISO existed. A
    VMS specific (or DEC specific??) extension.

    I suspect you're referring to what ISO calls "Extended Pascal"
    (ISO 10206); ISO Pascal (ISO 7185) doesn't support a `String`
    type of either the VSI Pascal form or the Turbo
    Pascal/Delphi/FreePascal form, only manifest string literals and
    `packed array [1..n] of char`.

    Yes, 10206.

    Arne

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Arne_Vajh=C3=B8j?=@21:1/5 to Dan Cross on Fri Jan 3 19:06:02 2025
    On 1/3/2025 4:51 PM, Dan Cross wrote:
    In article <vl9khp$cdg$1@reader2.panix.com>,
    Dan Cross <cross@spitfire.i.gajendra.net> wrote:
    However, these deficiencies are largely addressed in ISO 10206
    Extended Pascal, which provides a variable-length string type
    and permits conformant array parameters, which for VSI Pascal
    appear to monomorphize over the argument type.

    Actually, I guess that conformant array parameterss were in ISO
    7185, which had two "levels" of compliance; level 0 omitted them
    and level 1 includes them. That language is retained in ISO
    10206. Original, Wirth Pascal does not have them.

    Extended Pascal's variable string type appears more or less
    identical to the string type in VSI Pascal.

    The SPD ( https://vmssoftware.com/docs/VSI_Pascal_spd.pdf )
    says:

    <quote>
    VSI Pascal is an implementation of the Pascal language that accepts
    programs compatible with either
    level of the ISO specification for Programming languages - Pascal ([ISO 7185-1987]) as well as
    (ANSI/IEEE 770X3.97-1987).
    ...
    VSI
    Pascal also accepts many features from the Extended Pascal standard
    ((ANSI/IEEE 770X3. 160-1989)
    and (ISO 10206)).
    ...
    Major Pascal Language Elements:
    ...
    ● STRING schema denoting variable-length character strings up to 65,535 characters
    </quote>

    which I read as that string is supposed to be the standard (10206) string.

    Arne

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)