Re: [Gambas-user] static const?

2010-04-16 Thread Doriano Blengino
Charlie Reinl ha scritto: Am Donnerstag, den 15.04.2010, 21:07 +0300 schrieb Jussi Lahtinen: Yes, you can test it. This should generate error: If 1 = 2 And 1 / 0 Then Print test This should not.: If 1 = 2 And If 1 / 0 Then Print test if itabstrip1.count and

Re: [Gambas-user] static const?

2010-04-16 Thread Jussi Lahtinen
(my teacher said never try to divide something by 0). And I do not understand why/what/where that condition is/could be good for ... 1/0 !? Dividing by zero is guaranteed error. That is exactly reason why I used it to test if Gambas has short-circuits or not. This is for test purpose

Re: [Gambas-user] static const?

2010-04-15 Thread Doriano Blengino
Fabián Flores Vadell ha scritto: 2010/4/14 Doriano Blengino doriano.bleng...@fastwebnet.it: First example. I store some bookmarks... ... I could break out the loop using a logic variable, but this way I save a variable. Or I could test the variable in the loop construct, like this:

Re: [Gambas-user] static const?

2010-04-15 Thread Jussi Lahtinen
Back to gambas - I don't know if the documentation says anything about short-circuit and things like that. May be we can assume it as a standard, that modern languages always do short-circuit, but the concept remains. Gambas doesn't have short-circuits, you have to write like this: IF a=1

Re: [Gambas-user] static const?

2010-04-15 Thread Doriano Blengino
Jussi Lahtinen ha scritto: Back to gambas - I don't know if the documentation says anything about short-circuit and things like that. May be we can assume it as a standard, that modern languages always do short-circuit, but the concept remains. Gambas doesn't have short-circuits, you

Re: [Gambas-user] static const?

2010-04-15 Thread Charlie Reinl
Am Donnerstag, den 15.04.2010, 19:28 +0200 schrieb Doriano Blengino: Jussi Lahtinen ha scritto: Back to gambas - I don't know if the documentation says anything about short-circuit and things like that. May be we can assume it as a standard, that modern languages always do short-circuit,

Re: [Gambas-user] static const?

2010-04-15 Thread Jussi Lahtinen
Yes, you can test it. This should generate error: If 1 = 2 And 1 / 0 Then Print test This should not.: If 1 = 2 And If 1 / 0 Then Print test Jussi On Thu, Apr 15, 2010 at 20:56, Charlie Reinl karl.re...@fen-net.de wrote: Am Donnerstag, den 15.04.2010, 19:28 +0200 schrieb Doriano Blengino:

Re: [Gambas-user] static const?

2010-04-15 Thread Les Hardy
Charlie Reinl wrote: Am Donnerstag, den 15.04.2010, 19:28 +0200 schrieb Doriano Blengino: Jussi Lahtinen ha scritto: Back to gambas - I don't know if the documentation says anything about short-circuit and things like that. May be we can assume it as a standard, that modern

Re: [Gambas-user] static const?

2010-04-15 Thread Fabián Flores Vadell
I don't agree the criteria for saving one variable or one expresion if it is not justified. Well, perhaps my daily work with little CPUs (some have 32 bytes of ram!) drives me to professional bias, but why use a variable if can be avoided? There is more than one reason for this (reported

Re: [Gambas-user] static const?

2010-04-15 Thread Charlie Reinl
Am Donnerstag, den 15.04.2010, 21:07 +0300 schrieb Jussi Lahtinen: Yes, you can test it. This should generate error: If 1 = 2 And 1 / 0 Then Print test This should not.: If 1 = 2 And If 1 / 0 Then Print test Jussi On Thu, Apr 15, 2010 at 20:56, Charlie Reinl karl.re...@fen-net.de

Re: [Gambas-user] static const?

2010-04-14 Thread Doriano Blengino
Fabián Flores Vadell ha scritto: 2010/4/13 Jussi Lahtinenjussi.lahti...@gmail.com: Just in case: REPEAT b = TabStrip3.Count ' In fact, this does nothing usefull INC a UNTIL a TabStrip3.Count OR TabStrip3[a].Caption = IdCaption This doesn't make same

Re: [Gambas-user] static const?

2010-04-14 Thread Les Hardy
The C language, in facts, does not even have CONSTs - it goes with #define. So, it would be correct to forbid STATIC when declaring CONSTs. Surely this is not correct. ANSI C uses const, and C++ also uses the const keyword. #define (a preprocessor directive) is a relic from old C, and const

Re: [Gambas-user] static const?

2010-04-14 Thread Doriano Blengino
Les Hardy ha scritto: The C language, in facts, does not even have CONSTs - it goes with #define. So, it would be correct to forbid STATIC when declaring CONSTs. Surely this is not correct. ANSI C uses const, and C++ also uses the const keyword. #define (a preprocessor directive)

Re: [Gambas-user] static const?

2010-04-14 Thread Fabián Flores Vadell
2010/4/14 Doriano Blengino doriano.bleng...@fastwebnet.it: Back to the beginning: a CONST declaration is something that uses no memory, so it can not have instances, and hence it can not be STATIC. On the other hand, a CONST is always static, because the effective data it describes reside in

Re: [Gambas-user] static const?

2010-04-14 Thread Les Hardy
If you feel hurt I am sorry for that, it was not my intention to hurt you, and I have no wish to prove you wrong. I do still stand by my statement. Regards Les Hardy Doriano Blengino wrote: Les Hardy ha scritto: The C language, in facts, does not even have CONSTs - it goes

Re: [Gambas-user] static const?

2010-04-14 Thread Doriano Blengino
Fabián Flores Vadell ha scritto: 2010/4/14 Doriano Blenginodoriano.bleng...@fastwebnet.it: Back to the beginning: a CONST declaration is something that uses no memory, so it can not have instances, and hence it can not be STATIC. Thanks Doriano. I understand that. My question was

Re: [Gambas-user] static const?

2010-04-14 Thread Doriano Blengino
Errata corrige: Finally, your last lines of code do not work: Yes, it works. PRIVATE FUNCTION ScanTab(IdCaption AS String) AS Byte DIM a AS Byte = 0 WHILE (aTabStrip1.Count - 1) AND (TabStrip1[a].Text IdCaption) INC a WEND

Re: [Gambas-user] static const?

2010-04-14 Thread Fabián Flores Vadell
2010/4/14 Doriano Blengino doriano.bleng...@fastwebnet.it: And here we return on your idea about a good compiler - and it is mine idea too. I don't want judge if the Gambas compiler is good or not, I feel that I don't have the knowledge or experience required for do that. But, I shared with you

Re: [Gambas-user] static const?

2010-04-14 Thread Fabián Flores Vadell
2010/4/14 Doriano Blengino doriano.bleng...@fastwebnet.it: Errata corrige: May be that I am missing something, but... how can you say that it works if it omits to test the last item? Time later, driving to home and still thinking about this routine, I finally recalled what you wanted to

[Gambas-user] static const?

2010-04-13 Thread Fabián Flores Vadell
Hi everybody. Well, all us knows that a constant is something that can't change. Then, constants would be class members. So, when a class is instantiated, constants should be shared by all instances. The online help exclude the use of STATIC keyword in the declaration of constants, so the STATIC

Re: [Gambas-user] static const?

2010-04-13 Thread Benoît Minisini
Hi everybody. Well, all us knows that a constant is something that can't change. Then, constants would be class members. So, when a class is instantiated, constants should be shared by all instances. The online help exclude the use of STATIC keyword in the declaration of constants, so

Re: [Gambas-user] static const?

2010-04-13 Thread Fabián Flores Vadell
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   

Re: [Gambas-user] static const?

2010-04-13 Thread Benoît Minisini
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

Re: [Gambas-user] static const?

2010-04-13 Thread Jussi Lahtinen
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

Re: [Gambas-user] static const?

2010-04-13 Thread Jussi Lahtinen
I forgot Dim a as integer but you got the point. Jussi On Tue, Apr 13, 2010 at 22:29, Jussi Lahtinen jussi.lahti...@gmail.com 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

Re: [Gambas-user] static const?

2010-04-13 Thread Fabián Flores Vadell
Why shouldn't the compiler allow to modify a loop variable? It is sometimes useful. I'm refering to the loop FOR only. IMHO, WHILE and REPEAT are good structures that allow at programmer take absolute control over iterations, objective of FOR is iterate all items of a memory structure. At

Re: [Gambas-user] static const?

2010-04-13 Thread Fabián Flores Vadell
2010/4/13 Jussi Lahtinen jussi.lahti...@gmail.com: I forgot Dim a as integer but you got the point. Jussi Yes Jussi. But my point isn't to do that the code work, it's show a bad use of language resources. -- Fabián Flores Vadell www.speedbooksargentina.blogspot.com

Re: [Gambas-user] static const?

2010-04-13 Thread Jussi Lahtinen
First you referred to FOR loop only, but with case of return command you are talking more generally about loops? Or so I understand as you are speaking about it's influence to code structure. Consider this, if you have VERY long iteration and but you are done with first element of iteration. Then

Re: [Gambas-user] static const?

2010-04-13 Thread Jussi Lahtinen
Aaa I think you meant it this way: PUBLIC FUNCTION ScanTab(IdCaption AS Integer) AS Integer Dim a as Integer Dim b as Integer REPEAT IF TabStrip3[a].Caption = IdCaption THEN b = TabStrip3.Count BREAK ENDIF WHILE a TabStrip3.Count RETURN b END Jussi On Wed, Apr 14, 2010

Re: [Gambas-user] static const?

2010-04-13 Thread Jussi Lahtinen
Always forgetting something... INC a. Jussi On Wed, Apr 14, 2010 at 01:59, Jussi Lahtinen jussi.lahti...@gmail.com wrote: Aaa I think you meant it this way: PUBLIC FUNCTION ScanTab(IdCaption AS Integer) AS Integer Dim a as Integer Dim b as Integer REPEAT   IF TabStrip3[a].Caption =

Re: [Gambas-user] static const?

2010-04-13 Thread Fabián Flores Vadell
2010/4/13 Jussi Lahtinen jussi.lahti...@gmail.com: Aaa I think you meant it this way: PUBLIC FUNCTION ScanTab(IdCaption AS Integer) AS Integer Dim a as Integer Dim b as Integer REPEAT   IF TabStrip3[a].Caption = IdCaption THEN      b = TabStrip3.Count      BREAK   ENDIF WHILE a

Re: [Gambas-user] static const?

2010-04-13 Thread Jussi Lahtinen
Just in case: REPEAT     b = TabStrip3.Count ' In fact, this does nothing usefull     INC a UNTIL a TabStrip3.Count OR TabStrip3[a].Caption = IdCaption This doesn't make same functionality. Because if ldCaption doesn't match to any of tabstrip captions, function will still answer

Re: [Gambas-user] static const?

2010-04-13 Thread Fabián Flores Vadell
2010/4/13 Jussi Lahtinen jussi.lahti...@gmail.com: Just in case: REPEAT     b = TabStrip3.Count ' In fact, this does nothing usefull     INC a UNTIL a TabStrip3.Count OR TabStrip3[a].Caption = IdCaption  This doesn't make same functionality. That is why I did not want to follow the