[Gambas-user] Variables as functions
Brian G
brian at westwoodsvcs.com
Thu Oct 21 15:24:46 CEST 2021
Yes I understand this can easily be a c wrapper, but we already have on x gosub, which can be used to implement a very fast State or Event driven application.
It would be nice if some context information could be passed as well in those situations...
Yes I know there are plenty of work around..
Also adding a c wrapper also raises the issue of having to include an external c lib to the distribution.
I do use plenty of C externs in my applications where it is expedient, but always well established Linux/BSD/Unix libraries...
I thought this would be a very powerful and useful extension to the language.
I am not sure if others do this sort of thing, but there you have a couple of reasons I was asking about it.
"Failure is the key to success;
each mistake teaches us something" .. Morihei Ueshiba
Brian G
----- On Oct 20, 2021, at 5:25 PM, Jussi Lahtinen <jussi.lahtinen at gmail.com> wrote:
> 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 < [ mailto:brian at westwoodsvcs.com |
> 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 |
>> http://gambaswiki.org/wiki/doc/netiquette ] ]----
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20211021/5c5478db/attachment.htm>
More information about the User
mailing list