[Gambas-user] components automatically loading based on usage

Tobias Boege taboege at ...626...
Tue Jul 23 10:59:45 CEST 2013


On Mon, 22 Jul 2013, Kevin Fishburne wrote:
> I just noticed that referencing a boolean variable "Match" now 
> automatically loads the pcre component and tries to use it as a function 
> (then obviously fails). This seems a dangerous precedent, as most GAMBAS 
> users probably don't use most components and therefore shouldn't be 
> constrained by their reserved keywords. Having any component 
> automatically enable itself for any reason is also troubling, as it 
> exposes the application to any vulnerabilities the component may possess 
> without the knowledge of the developer.
> 
> For the time being I'm just renaming my variable, but I was surprised to 
> see this. Thoughts anyone?
> 

Hi Kevin,

as you may have read in the commit logs, the Match operator was added by
Benoit after I added a static Regexp.Check() shorthand function (which was
subsequently renamed to Regexp.Match()).

I personally am very lucky with Match being an operator because it is more
powerful than Like and just looks more natural than a function call - and
extended regular expressions should be part of every language. The thing
with "constrained by their reserved keywords" is that Match _is_ now part of
the language - which is IMO a good thing in itself - and you normally don't
plug in keywords into a language. It's not that Gambas will be flooded by
new keywords and the variable namespace will be polluted... A keyword is
only added once in a while.

I was sceptical, too, when I read that it loads the gb.pcre component in the
background but: you wouldn't use Match if you didn't want to use gb.pcre,
right? In this case, you would accept the risk that gb.pcre was buggy (and,
come on, the component consists of ~400 LOC).

That the new keyword could collide with a variable name was something I
didn't think about as I stick to the naming conventions[0] ;-) Also if
"Match" was a boolean variable, the literate way to name it would have been
HasMatched or something as "match" is an action and "has matched" is a
boolean state. Just joking :-)

If you still want to use the name Match (e.g. for public symbols,
properties, etc.), use braces[1].

Regards,
Tobi

[0] http://gambasdoc.org/help/doc/naming?v3
[1] http://gambasdoc.org/help/cat/resident?v3




More information about the User mailing list