Invoking return through a function?
Rhodri James
rhodri at kynesim.co.uk
Mon Oct 30 10:27:04 EDT 2017
More information about the Python-list mailing list
Mon Oct 30 10:27:04 EDT 2017
- Previous message (by thread): Invoking return through a function?
- Next message (by thread): Invoking return through a function?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 29/10/17 16:45, Alberto Riva wrote: > On 10/29/2017 11:13 AM, bartc wrote: >> >> (What the OP wants was also proposed a few weeks back in comp.lang.c. >> But that was only within nested functions, so if H is inside G, and G >> is inside F, then a 'returnall' from H would return directly directly >> from F. Apparently Lisp allows this...) > > Well, not directly, but it can be simulated with the condition system > (equivalent to try/except) or with throw/catch, which is similar but > doesn't use exceptions. > > But my point was that in Lisp you don't need to do this, because you can > write a macro that expands into a return *in place*, without calling a > separate function, and this eliminates the problem entirely. Since > Python doesn't have macros I was looking for the next-best solution, but > there doesn't seem to be one. Oh, well... You can do the same in C. I've had the displeasure of trying to maintain such code. It was near-unreadable, because it constantly broke your expectations of what the code flow *could* be. The fact that something that could return from the middle of your function without the slightest indication was a rich source of bugs. (I didn't have to tell my boss to up our rates for dealing with this code. It took several days to do the work anyway, which was punishment enough at our rates.) -- Rhodri James *-* Kynesim Ltd
- Previous message (by thread): Invoking return through a function?
- Next message (by thread): Invoking return through a function?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list