[Gambas-user] Removing / Modifying IsXXXX() functions in Gambas 3

Rolf-Werner Eilert eilert-sprachen at ...221...
Wed Nov 24 16:12:49 CET 2010


Am 24.11.2010 12:08, schrieb Benoît Minisini:
> Hi,
>
> I'm currently thinking about modifying/removing all IsXXXX() functions in
> Gambas 3.
>
> They mainly test the datatype of their expression. So, either the datatype is
> known at compile time, and there should be no need of testing it ; either you
> are using a Variant, and you can use TypeOf() to get the datatype of the
> value.
>
> I will replace them by some functions that will test if a value can be
> converted safely from a string by using localization. This is what most users
> expected from these functions.
>
> For exemple, in french localization:
>
> 	IsDate("13/2/20") ->  True
> 	IsNumber("3,34") ->  True
> 	IsInteger("3,34") ->  False
> 	IsNumber("3.34") ->  False
> 	
> Internally, they will use Val() and see if the conversion works.
>
> I will kept most of the name, so there will be a big incompatibility between
> Gambas 2, current Gambas 3, and final Gambas 3.
>
> What do you think about that?
>
> Who is using the IsXXXX() functions, and in which context?
>

I just checked it. As far as I remember and due to my search within my 
most important projects, I have only used IsNull so far.

In one project, I used it very often to manage Val() because Val() 
doesn't understand empty strings or strings without numbers. Wasn't it 
you or Fabien who once pointed me to this fact and gave me the tip to 
use IsNull for it?

In that project there are lots of places where wrong inputs could occur, 
so there are lots of IF IsNull(bla) THEN RETURN "bullshit" or IF NOT 
IsNull(bla) THEN RETURN Val(bla) ;-)

So from my point of view, if you let be Val() less critical, you my 
discard IsNull, otherwise leave it there or replace it by something useful.

Regards

Rolf





More information about the User mailing list