[Gambas-user] Fwd: Gambas3 byref behavior

Jussi Lahtinen jussi.lahtinen at ...626...
Wed Feb 25 20:57:45 CET 2009


I forgot to mention about related bug...

IDE doesn't like this;

With someobject
TestFunction(ByRef .x)
End With

it renders to;

With someobject
TestFunction(ByRef.x) <-- Unknown identifier: ByRef
End With

Sorry about messy post...


Jussi


---------- Forwarded message ----------
From: Jussi Lahtinen <jussi.lahtinen at ...626...>
Date: Wed, Feb 25, 2009 at 9:41 PM
Subject: Gambas3 byref behavior
To: "Gambas mailing list for users." <Gambas-user at lists.sourceforge.net>


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




More information about the User mailing list