[Gambas-user] strange problem with NOT

Jim Ward zjimward at ...626...
Mon Mar 21 23:11:29 CET 2005


It might be interesting to see how serveral languages handle NOT (C,
Pascal, other variants of Basic, etc.) I'm happy with the
functionality the way it is presently, but am open to change.

On Mon, 21 Mar 2005 18:02:33 +0100, Benoit Minisini
<gambas at ...1...> wrote:
> On Friday 18 March 2005 19:51, Jean-Francois Perreault wrote:
> > Hi,
> >
> > I found this "problem" with NOT , I'm pretty sure VB doesn't behave this
> > way
> >
> > for this code
> >
> > DIM X as Integer
> >
> > x = 1
> > PRINT "X is 1"
> > IF x = 0 THEN PRINT "x = 0 returned TRUE"
> > IF NOT x = 0 THEN PRINT "NOT x = 0 returned true"
> > IF NOT (x = 0) THEN PRINT "NOT (x = 0) returned true"
> >
> > x = 0
> > PRINT "X is 0"
> > IF x = 0 THEN PRINT "x = 0 returned TRUE"
> > IF NOT x = 0 THEN PRINT "NOT x = 0 returned true"
> > IF NOT (x = 0) THEN PRINT "NOT (x = 0) returned true"
> >
> > if you run this you'll get the surprising output
> >
> > X is 1
> > NOT (x = 0) returned true
> > X is 0
> > x = 0 returned true
> >
> >
> > it's as if NOT was a function NOT() and not a logic keyword !
> >
> > I'm pretty sure vb would have turned both
> >
> > NOT x = 0 returned true
> > NOT (x = 0) returned true
> >
> > (that is if VB had a PRINT function ;) )
> > I don't have vb installed right now so I can't test , but that
> > behavior sure puzzled me in the form of a bug in my program !!!
> >
> > ---
> > Jean-Francois Perreault
> >
> >
> 
> The Not operator has a priority greater than comparison operators in Gambas.
> 
> You can see the priority of each operator in the 'gb_reserved_temp.h' file in
> the 'share' directory.
> 
> Should Gambas operators have exactly the same priority than in VB ? Anyway,
> you can use parenthesis to force the priority without fear - it does not slow
> the interpreter.
> 
> We can decide all together to change priorities if there are good reasons for
> that. The development version is done for that - breaking everything :-)
> 
> Regards,
> 
> --
> Benoit Minisini
> mailto:gambas at ...1...
> 
> 
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>




More information about the User mailing list