[Gambas-user] To wish list; optional compiler warning

Fabián Flores Vadell fabianfloresvadell at ...626...
Thu Sep 8 23:28:33 CEST 2011


2011/9/8 Jussi Lahtinen <jussi.lahtinen at ...626...>

> >
> > By having to specify ByRef in the caller, you can't forget that the
> > function
> > will modify your variable (forgetting that leads to hard-to-fix bugs) and
> > it
> > help readers of your code.
> >
>
> Sorry, I don't understand what you mean, can you elaborate?
> I mean I forgot to write Test(Byref i), instead I always write old vb style
> Test(i).
>
> Jussi
>

 Hi Jussi. The keyword Byref allows that a parameter may cause side effects.
The double request to specify Byref on both, the real and the actual
parameter (in the declaration and in the call) help to the programmer to be
award that he or she could cause a side effect.

Side effects should be caused by returning a value by specifing "RETURN
value" according to the return data type specified in the declaration (i.e.
using a function, speaking in conceptual terms).

So, if you are porting VB code, maybe you'll probably have to use ByRef,
sometimes. Otherwise isn't recommended byref (according to Gambas idiom).

PD: sorry for my (probably unnecessary) verbosity and my poor english.



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



More information about the User mailing list