gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Questions about behavior observed in gm2


From: Jack Perry
Subject: Questions about behavior observed in gm2
Date: Mon, 4 Dec 2023 05:49:19 +0000 (UTC)

Hello!

I used Modula-2 a lot 25-30 years ago, but haven't been able to use it since 
then until the happy advent of gm2 (13.2.1). I decided to get back into it by 
solving Advent of Code puzzles, and I've encountered some questions. I think 
some of these may be bugs, but since I'm using the online reference at 
modula2.org I may simply be misunderstanding what I see. (Some are due to my 
comparing it with Ada and Rust.)

I would be very grateful for any insight people can give on these; I'm pretty 
sure they're easy to answer!

1. If I define the type `Constraints = [1..140]` and the variable `Idx: 
Constraints`, then if I increment `Idx` repeatedly until `Idx = 
MAX(Constraints) + 1`, should that be a run-time error? It is in Ada, but not 
in Modula-2 w/gm2. I can provide a fuller example if needed.

2. I can't seem to define a constant for a variant record type; that is, this 
fails to compile:

       TYPE TwoLocations = RECORD
             CASE Valid: BOOLEAN OF
             TRUE:
                   First, Second: UsedLocation;
             | ELSE
             END;
          END;

       CONST
          InvalidAdjacencies = TwoLocations { FALSE };

3. If you neglect the parentheses on a function procedure that takes no 
parameters, gm2 treats it as if you want the address(?). Thus, the following 
line gives an unexpected answer:

      InOut.WriteInt(Part1, 0); (* needs to be Part1() *)

4. There's no way to obtain a subscript of an array by "slicing", is there? For 
example,

      VAR
         A: ARRAY [1..10] OF CHAR;
     BEGIN
         DoSomethignWith(A[3..5]);

thanks in advance for any insight!

Jack Perry
--
I'd rather be unhappy than have a false, lying sort of happiness. -- Brave New 
World


reply via email to

[Prev in Thread] Current Thread [Next in Thread]