gm2
[Top][All Lists]
Advanced

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

Re: [Gm2] Bug report.... offending code works outside of procedure, but


From: Fischlin Andreas
Subject: Re: [Gm2] Bug report.... offending code works outside of procedure, but inside - not.
Date: Wed, 28 Jul 2010 12:41:58 +0000

It seems the compiler is not recognizing the difference between procedure 
variable assignment and the case where an expression is to be evaluated. The 
difference in the syntax should be:

        where := AlwaysTrue;

and

        where := AlwaysTrue();

The latter should lead to an error "incompatible types" and the first should be 
accepted as an assignement statement. Modula-2 syntax is clear on this, since a 
procedure of standard type PROC can not be confounded with an expression. Only 
function procedures can be a factor or term in an expression and need therefore 
be called by using parantheses when actually called. 

Duric, you say something about an outer scope, but scope should not matter in 
any way (except of course that the assignment statement has to be within the 
scope of 'where' as well as 'AlwaysTrue').

Regards,
Andreas
 

ETH Zurich
Prof. Dr. Andreas Fischlin
Systems Ecology - Institute of Integrative Biology
CHN E 21.1
Universitaetstrasse 16
8092 Zurich
SWITZERLAND

address@hidden
www.sysecol.ethz.ch

+41 44 633-6090 phone
+41 44 633-1136 fax
+41 79 221-4657 mobile

             Make it as simple as possible, but distrust it!
________________________________________________________________________



On 25/Jul/2010, at 07:36 , Dragiša Durić wrote:

> gm2 -fiso -c TestCase.mod
> TestCase.mod:15:5: error: assignment designator 'where' of type 'Where'
> is a variable and expression 'AlwaysTrue' of type 'BOOLEAN' are
> incompatible
> 
> ==================
> MODULE TestCase;
> 
> PROCEDURE AlwaysTrue(): BOOLEAN;
>  BEGIN
>    RETURN TRUE;
>  END AlwaysTrue;
> 
> TYPE
>  Where = PROCEDURE (): BOOLEAN;
> 
> PROCEDURE DoIt();
>  VAR
>    where: Where;
>  BEGIN
>    where := AlwaysTrue;
>  END DoIt;
> 
> END TestCase.
> 
> -- 
> Dragiša Durić <address@hidden>
> 
> 
> _______________________________________________
> gm2 mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/gm2


reply via email to

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