[Gambas-user] Method overloading in Gambas
David Paleino
d.paleino at ...626...
Thu Feb 5 16:13:03 CET 2009
Hello,
other languages (C# and Java can do this, possibly also others) have the
ability to "overload" methods. Quick example:
---8<---
PUBLIC SUB Method()
' Arg1 and Arg2 are properties, which could be set with Arg*_Write()
' methods, or can be default values, or ...
Method(Arg1, Arg2)
END SUB
PUBLIC SUB Method(Arg1 AS Variant, Arg2 AS Variant)
[..]
END SUB
--->8---
(obviously, if one calls Method(), he should've set Arg1 and Arg2 already)
This is easily doable using a "helper" sub, like:
---8<---
PUBLIC SUB Method()
Arg1 = [..] ' get these from somewhere
Arg2 = [..]
DoStuff(Arg1, Arg2)
END SUB
PUBLIC SUB Method(Arg1 AS Variant, Arg2 AS Variant)
DoStuff(Arg1, Arg2)
END SUB
PRIVATE SUB DoStuff(Arg1 AS Variant, Arg2 AS Variant)
[..]
END SUB
--->8---
(note the redundancy in method signatures...)
Benoit, is it possible to have this feature in gambas3?
Ciao,
David
--
. ''`. Debian maintainer | http://wiki.debian.org/DavidPaleino
: :' : Linuxer #334216 --|-- http://www.hanskalabs.net/
`. `'` GPG: 1392B174 ----|---- http://snipr.com/qa_page
`- 2BAB C625 4E66 E7B8 450A C3E1 E6AA 9017 1392 B174
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20090205/7910359b/attachment.sig>
More information about the User
mailing list