[Gambas-user] TreeView: why is error = TRUE?

Rolf-Werner Eilert eilert-sprachen at ...221...
Mon May 4 08:25:07 CEST 2009


Thank you for that explanation, it does make sense, you're right :-)

 From the reading-and-understanding-code point of view, however, it
might have been better to have it the other way round. In everyday
language (= everyday logic), a NOT clause is used pretty often, and
"failing" (error) is connected to being "false".

There is a dilemma: should code be more elegant or easier to read? When
I come back to a piece of code in one of my projects after a long time,
I will have to read and understand what I did when creating it. There
are pieces which I read just once and know what it's supposed to do. And
there are others where I have to read and think about several times to
remember what this was all about (even if there are comments). One of
these pieces had those .MoveChild clauses, and I had to look into the
documentation first to remember that "TRUE" actually means "failed".

In another function, I used a Boolean named "wahr" (German for TRUE) as
a flag when the previous part of code came to a positive result. This
made the IF clauses easy (IF wahr THEN) but somewhat further there is
confusion:

IF wahr THEN
   wahr = FALSE
ELSE
   wahr = TRUE
END IF

ROTFL :-)

Now I've got into the same trap I thought when I came back to this site
the other day.

Regards

Rolf


Fabien Bodard schrieb:
> in fact nothing is unlogical ... it's the gambas way...
> 
> in gambas an error, impossibility, return true... in all the function
> that return a boolean
> 
> you can imagine to write this in that way
> 
> CONST bError as Boolean =True
> 
> if .MoveChild = bError then ...
> 
> its the same !
> 
> in another way it limit the use of the NOT Function keyword
> 
> 
> 
> 
> exemple :
> if .MoveChild then
>   .MoveBack
>   if .MoveNext
>     .MoveBack
>     if .MoveParent then
>        .MoveNext
>     endif
>   endif
> Endif
> 
> 2009/4/29 Rolf-Werner Eilert <eilert-sprachen at ...221...>:
>> Just one question for understanding it better:
>>
>> Why is e. g. MoveNext or MoveChild TRUE in case there is NOTHING and not
>> vice-versa? Seems pretty unlogical and looks somewhat strange in code...
>>
>> Regards
>>
>> Rolf
>>
>> ------------------------------------------------------------------------------
>> Register Now & Save for Velocity, the Web Performance & Operations
>> Conference from O'Reilly Media. Velocity features a full day of
>> expert-led, hands-on workshops and two days of sessions from industry
>> leaders in dedicated Performance & Operations tracks. Use code vel09scf
>> and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
>> _______________________________________________
>> 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