[Gambas-user] static const?

Jussi Lahtinen jussi.lahtinen at ...626...
Tue Apr 13 21:31:48 CEST 2010


I forgot "Dim a as integer" but you got the point.

Jussi


On Tue, Apr 13, 2010 at 22:29, Jussi Lahtinen <jussi.lahtinen at ...626...> wrote:
> Generally bad code...
> What that supposed to do?
> Either it will return TabStrip3.Count or zero.
>
> This would do exactly same thing:
>
> PUBLIC FUNCTION ScanTab(IdCaption AS Integer) AS Integer
>
>  FOR a = 0 TO TabStrip3.Count - 1
>      IF TabStrip3[a].Caption = IdCaption THEN
>         RETURN TabStrip3.Count
>      ENDIF
>  NEXT
>
> END
>
> Jussi
>
>
> 2010/4/13 Fabián Flores Vadell <fabianfloresvadell at ...626...>:
>>> 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
>>
>> ------------------------------------------------------------------------------
>> Download Intel® Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling, find bugs
>> proactively, and fine-tune applications for parallel performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> _______________________________________________
>> 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