[Gambas-user] Gambas3 byref behavior

Benoît Minisini gambas at ...1...
Thu Feb 26 14:27:23 CET 2009


> Hi
> I could be wrong, but.
> I think that byref command should behave like this:
>
> a = 0
> TestFunction(a)
> Print a
>
> Public Function TestFunction(Byref x as Integer)
>  Inc x
> End
>
> Result:
> 1
>
>
> And if you like to pass byref argument byval instead for some reason,
> you should do this:
>
> a = 0
> TestFunction(Byval a)
> Print a
>
> Public Function TestFunction(Byref x as Integer)
>  Inc x
> End
>
> Result:
> 0
>
> There are reasons why one design function to take parameters byref,
> and so, it should be default behavior.
> Need to pass byref argument byval is rare exception (I think).
> Maybe there are some technical restrictions why this is as it is.
> And maybe this is not good enough reason to change syntax anymore...
> What do you think?
>
>
> Jussi
>

The reason why ByRef must be specified both in function declaration and in 
function call is explained in the documentation wiki there:

http://gambasdoc.org/help/doc/byref

Regards,

-- 
Benoît




More information about the User mailing list