[Gambas-user] static const?

Fabián Flores Vadell fabianfloresvadell at ...626...
Tue Apr 13 21:11:10 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.


-- 
Fabián Flores Vadell
www.speedbooksargentina.blogspot.com




More information about the User mailing list