[Gambas-user] Variables as functions

Jussi Lahtinen jussi.lahtinen at gmail.com
Thu Oct 21 02:25:16 CEST 2021


If you write a simple wrapper with C you can already do it like this:

dim funcList as pointer[] = [myfunc1, myfunc2, myfunc3]
dim state as integer = 1

.......
.......

dim y as integer = CWrapper(funcList[state], parm1, parm2)


Jussi

On Wed, Oct 20, 2021 at 7:01 PM Brian G <brian at westwoodsvcs.com> wrote:

> It would be useful if variables could also have a type of function. This
> would really be useful for some applications
>
> such as
>
> dim funcList as function[] = [myfunc1, myfunc2, myfunc3]
> dim state as integer = 1
>
> .......
> .......
>
> dim y as integer = funcList[state](parm1, parm2)
>
>
> "Failure is the key to success;
>  each mistake teaches us something"  .. Morihei Ueshiba
> Brian G
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20211021/9f5f901d/attachment.htm>


More information about the User mailing list