[Gambas-user] Possible suggestion/question

Jussi Lahtinen jussi.lahtinen at ...626...
Fri Mar 2 20:03:56 CET 2012


I made quick effort to try to simulate gosub with goto,
and noticed that jumping back inside loops is not possible (as the
documentation says...).

I understand that when it's For ... Next, but shouldn't that be possible
with Do ... Loop Until x?

Anyway, I'm not sure my simulation does accurately compare speed of Sub to
Gosub... if it does,
then gosub would be 2 to 3 times faster.

Jussi

PS. Try to change last line "End" to "EndEnd" and then try to compile!




2012/3/2 Benoît Minisini <gambas at ...1...>

> 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
>
>
> ------------------------------------------------------------------------------
> Virtualization & Cloud Management Using Capacity Planning
> Cloud computing makes use of virtualization - but cloud computing
> also focuses on allowing computing to be delivered as a service.
> http://www.accelacomm.com/jaw/sfnl/114/51521223/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GosubTest-0.0.1.tar.gz
Type: application/x-gzip
Size: 4866 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20120302/5807c678/attachment.bin>


More information about the User mailing list