gm2
[Top][All Lists]
Advanced

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

AW: Boolean constants


From: address@hidden
Subject: AW: Boolean constants
Date: Mon, 26 Aug 2024 12:44:41 +0200 (CEST)

Andreas,

 

you are right - it crashes the compiler (versions 13 and 14 to answer Gaius question as well).

 

And I only meant that a form "CONST LogicalX = (1 = 1);" is not the best way to define the value of a boolean constant. It is legal but not good style (at least in my personal view).

 

Gruß

 

Michael

 

 

 

 

 

-----Original-Nachricht-----

Betreff: Re: Boolean constants

Datum: 2024-08-25T15:01:34+0200

Von: "Fischlin Andreas" <andreas.fischlin@env.ethz.ch>

An: "Michael Riedl" <udo-michael.riedl@t-online.de>

 

 

 

Dear Michael,
 
All are legal Modula-2 constant definitions. It is not clear to me why you write “at least the line "Logical2 = NOT Logical1;" and "Logical3 = NOT TRUE;" should be OK.” And as there is nothing to be executed at run time, by crash you mean the compiler crashes without an error message?
 
Cheers,
Andreas


ETH Zurich
Prof. em. Dr. Andreas Fischlin
Formerly IPCC Vice-Chair WGII
Systems Ecology - Institute of Biogeochemistry and Pollutant Dynamics
CHN E 24
Universitaetstrasse 16
8092 Zurich
SWITZERLAND
 
 
+41 44 633-6090 phone
+41 79 595-4050 mobile
 
             Make it as simple as possible, but distrust it!
________________________________________________________________________
 



On 25 Aug 2024, at 11:09, Michael Riedl <udo-michael.riedl@t-online.de> wrote:

Hallo Gaius,

can you have a look on the following small piece of code:

MODULE TestBool;

CONST Logical1 = TRUE;

      Logical2 = NOT Logical1; (* crash *)
      Logical3 = NOT TRUE;     (* crash *)

      Logical4 = (1 = 0);      (* crash *)
      Logical5 = (1 = 1);      (* crash *)
BEGIN
END TestBool.

I would think that at least the line "Logical2 = NOT Logical1;" and "Logical3 = NOT TRUE;" should be OK.

The lines with Logical4 and Logical5 are for sure "quick and dirty" but handy to quickly switch off and on some code segments during development (would not do that in production code).

Gruß / Greetings

Michael


 


reply via email to

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