how are variables passed from functions?

Peter Haworth pete at lcsql.com
Fri Nov 14 13:05:45 EST 2014


Hi Tiemo,
That seems like an unexpected behavior to me but definitely good to know.
I've christened this behavior "the point of no return"!

I'm triyng to wrap my head around what might happen in this scenario with a
recursive function.

Pete
lcSQL Software <http://www.lcsql.com>
Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>

On Fri, Nov 14, 2014 at 12:47 AM, Tiemo Hollmann TB <toolbook at kestner.de>
wrote:

> By accident I noticed that I don't have a return at a certain point of a
> function but nevertheless the value was passed back without a return to the
> calling handler.
>
> I can reproduce the issue to this scenario:
>
>
>
> --Btn script
>
> on mouseUp
>
>     put foo1() into myVar1 -- I get the value "Test"
>
> end mouseUp
>
>
>
> --script in stack
>
> function foo1
>
>    put foo2() into myVar2 -- no return in this function
>
> end foo1
>
>
>
> function foo2
>
>    return "Test" -- return here in second level
>
> end foo2
>
>
>
> Up to now I thought that every function has to have a return statement if
> you want anything getting back.
>
> Can somebody explain to me what is going on here? How is the value from
> function foo2 passed back to the mouseup handler, even with different var
> names?
>
> Is this a bug or just an accident or even wanted?
>
> Thanks for enlightening
>
> Tiemo
>
>
>
>
>
>
>
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list