[Gambas-user] static const?

Benoît Minisini gambas at ...1...
Tue Apr 13 21:22:41 CEST 2010


> > No STATIC with CONST. Or maybe the compiler is more tolerant than that?
> 
> Maybe the compiler is a too much good guy :)
> 
> I think that the compiler shouldn't allow to do something like that:
> 
> 
> PUBLIC FUNCTION ScanTab(IdCaption AS Integer) AS Integer
> 
>   DIM a AS Integer = 0
>   DIM b AS Integer = 0
> 
>   FOR a = 1 TO TabStrip3.Count STEP 1
>       IF TabStrip3[(a - 1)].Caption = IdCaption THEN
>          b = a
>          a = TabStrip3.Count
>          RETURN a
>       ENDIF
>   NEXT
> 
> END
> 
> 
> Someone thought that this code is good one.
> 
> Leaving aside the obvious conceptual confusion of the author, and that
> the routine doesn't do what it claims, it is important to note that it
> is possible to change the variable that controls the FOR structure,
> and included the return statement inside the loop.
> 
> I think the compiler should not allow these things, at least for mercy
> through the eyes of those who are finally forced to read code like
> this.

Why shouldn't the compiler allow to modify a loop variable? It is sometimes 
useful.

Why shouldn't the compiler allow to return from inside a loop? It is perfectly 
valid to do that.

A bad programmer using some syntax for writing bad code does not necessary 
imply that that syntax should be forbidden.

Regards,

-- 
Benoît Minisini




More information about the User mailing list