[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Assignment to array/record constants.
From: |
Gaius Mulley |
Subject: |
Re: Assignment to array/record constants. |
Date: |
Fri, 25 Nov 2022 14:44:23 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) |
Guy <guyfieri@getbackinthe.kitchen> writes:
> Hello again Gaius, due to my lack of experience with mailing lists I'm afraid
> I just recently realized that when attempting to reply to your response to
> me, I accidentally replied directly to your personal email instead of the
> mailing list.
> Due to my email address's domain name, I think that it probably ended up in
> your junk/spam folder, my mistake.
>
> However since then I have installed Debian and was indeed able to compile the
> project mostly without issue, so in hindsight it seems that the latest GCC
> sources just aren't too well suited for macOS (though I'm sure there were
> quite a
> few things I was missing on my end).
>
> So today, the issue/question I had is a bit different and instead related to
> the actual compiler frontend's behavior. One of the first things I happened
> to try after the successful compilation was some features that I made
> frequent use of
> in other languages I have used, that being array/record constants. I saw from
> a Modula-2 ISO reference that the language also supported this via what it
> calls "constant constructors". Just to see how the compiler would respond, I
> tried
> assigning a value to some test constants I made, but to my surprise it didn't
> complain and actually replaced its value with the new one from the program
> body.
>
> More specifically, assignments to the constants in the body of the program
> via a constant constructor ("constant := TypeName{...}") replaced the current
> value, but assignments to individual components of the array/record didn't
> actually have an effect on the values. Running the test program in GDB. I
> noticed the main procedure of executable programs seemed to be named
> _M2_<program_name>_init, and was wondering if all array/record constructors
> (whether for a constant or not), were being moved into some sort of
> pre-"main" area of code. When stepping through the program, the
> new/additional assignments to the constant identifiers via constructors don't
> appear in the places
> they do in the source.
>
> Please pardon me if this is expected behavior, but I just wanted to ask if
> this was considered normal.
>
> Thank you, Guy.
Hello Guy,
thanks for the bug report and test example. It is certainly a bug and
is now fixed (about to be git pushed):
$ gm2 constants.mod
constants.mod:34:14: error: In program module ‘Constants_Example’: cannot
assign a constant designator ‘Test_Point’ with an expression constructor
34 | Test_Point := TPoint{100.0, 80.0};
| ^~
constants.mod:62:14: error: cannot assign a constant designator ‘Test_Color’
with an expression constructor
62 | Test_Color := TColor{0, 0, 0};
| ^~
I hope to improve the carot to span the whole line, but will not delay
the immediate fix and will reply to the other questions later on,
regards,
Gaius