On Thu, Aug 16, 2018 at 4:52 AM, Jacob Solinsky <jacobsolin...@gmail.com> wrote:
> -Jumping to a function as opposed to calling a function
>
> When a function is jumped to, it inherits the variables in the caller’s local 
> namespace and is free to modify them or add new local variables, unlike a 
> normal function call, wherein the caller’s namespace is inaccesible. At 
> present, the only way I know of to accomplish this is to bundle all variables 
> in the caller method’s namespace as properties of the method’s instance and 
> have the callee method modify those properties. Though it is easier to read 
> code written this way, it resulted in a great deal of redundancy in the code 
> I was writing.
>

> Let foo(a, b) be the syntax to call foo(a, b), and foo(a, b)% be the syntax 
> to jump to foo(a, b)
>
> def foo(a):
>         return a + c
>
> def bar(a, c):
>         return foo(a)
>
> def bazz(a, c):
>         return foo(a)%
>
> c = 5
>
> call = bar(1, 3)
>
> jump = bazz(1, 3)
>
>
> After execution, call in the above code would be 6 and jump in the above code 
> would be 4.

You're trying to shed encapsulation (by having the jumped-to function
operate in the "caller's" namespace), but also pass parameters to it.
That's going to cause a lot of confusion.

I'm sympathetic to the problem, but I don't think functions are the
solution here. You want some form of code block. There've been a
number of proposals along those lines, and so far, not one of them has
been really implementable. Check out some of the prior theories and
see if one of them will work for you.

ChrisA
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to