[Python-ideas] Inline Functions - idea

Alex Rodrigues lemiant at hotmail.com
Wed Feb 5 16:15:08 CET 2014


Hi guys,
A couple more thoughtsAs to why I didn't use an "or" in the original example. I am aware that the example doesn't actually need an inline function, but it demonstrates the concept in a simple way (so that it would fit in an email). Most use-cases are more complicated, often the spots where you want to execute the same code are buried inside long, branching logic statements where other things are going on, making restructuring the code much less trivial, if not impossible.I had never really considered using closures that way (I haven't really used them much at all), that is extremely cool! It does exactly what I was envisioning as long as you only need it in one spot. If inline function got implemented I'm sure they would steal a lot of code from closures.The remaining use cases for inline functions are times when you would need the same capabilities in multiple functions (calling in multiple methods of a class for example), or when you wish to define what is essentially a closure at the first level of execution, since closures are not possible when you are not in a function.I always knew you could do it the way skip showed, but I feel like that is a bit clunky. This would allow you to do that in a more straight-forward way.
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140205/44463a44/attachment.html>


More information about the Python-ideas mailing list