[Gambas-user] Possible suggestion/question

Benoît Minisini gambas at ...1...
Fri Mar 2 03:31:12 CET 2012


Le 25/02/2012 19:18, nando a écrit :
> Benoit,
>
> I came across the need to call many different common small pieces of code multiple times.
> Naturally, we tend to make a SUB just for all of them.
>
> I wondered if you'd consider resurrecting GOSUB {label}
> which is in the same sub.
>
> It would be in the same scope, no parameters allowed and
> acts just like a leaf subroutine with only return on the stack
> and no formal stack frame.  It's also part compromise to embedded SUBs
>
> Would overal execution run faster ?
>
> ??
> -Fernando
>

It may be a little bit faster. You can check that by simulate the GOSUB 
with some GOTOs and compare the speed with a similar function call.

Anyway, there is a syntax problem. In Basic, GOSUB is ended by a RETURN 
instruction, but RETURN is already used to exit the all function. Or 
maybe RETURN will return from the function only if there is no pending 
GOSUB.

Can you test if there is any speed gain I as said above? I don't have 
the time to do that now. If the speed gain is worth it, then I may 
implement GOSUB!

Regards,

-- 
Benoît Minisini




More information about the User mailing list