[Python-ideas] Syntax: 'return: ...' expressions

Yawar Amin yawar.amin at gmail.com
Sat Jan 10 01:48:57 CET 2015

Hi Andrew,

On 2015-01-08 10:32, Andrew Barnert wrote:
> [...]
> Haskell's do statement has a nice way out of that (if you really want
> to turn off Pythonistas by using the word "monad")....

> Another trick that might be worth playing with explicit native globals
> and locals for your functions (e.g., by constructing a new
> types.FunctionType),...

Thanks for the ideas. I have to admit I didn't really think deeply about
most of them, but the above two resonated and gave me a couple of ideas
myself. I was able to refine my continuations idea, using monadic
sequencing of effects and defining a new function-like type, so that at
this point I can do this:

    actions = {
        print_("Hello, World!", λ:

        import_("math", λ m:
        print_("The area of my circle is:", λ:
        print_(m.pi * 5 * 5)))),

        print_("Goodbye, Cruel World!", λ:

          1 / 0, λ:
          print_("Danger, Will Robinson!"))) }


For now, I'm satisfied that this is the best I can do towards resolving
the duality of statements and expressions. As you and others have
pointed out, this duality is intentional and is meant to guide the
programmer into a certain mindset, which is why fighting against it is
so hard.

But often when you're just trying to express the ideas in your head,
sometimes you just _have_ to get something out in a certain way. So I
think there's utility in my approach.

As you say, this isn't really a relevant 'Python idea' for this mailing
list, so this discussion isn't really going to go anywhere. Anyway,
thanks for your input, it's appreciated.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 834 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150109/c2173ce9/attachment.sig>

More information about the Python-ideas mailing list