On PEP 312: simple implicit lambda

Stuart D. Gathman stuart at bmsi.com
Wed Feb 19 21:46:44 EST 2003


On Wed, 19 Feb 2003 19:29:38 -0500, Greg Ewing (using news.cis.dfn.de)
wrote:


> Maybe our ideas could be combined by substituting "doing" and "gives"
> for your "when" and "then". Your example would then become
> 
>    if (btcb.flag & (BTCB.MWA | BTCB.MOV)) != 0:
>      btbuf(btcb.node,None)
>    elif (btcb.flag & BTCB.MOV) != 0 or doing:
>      dispose()
>      btcb.abuf = node = getblk(btcb.node)
>    gives btroot != btcb.root or btson > 0 or doing:
>      r4 = btcount
>      if r4 == 0: raise EOFException
>      r7 = btcb.slot
>    gives r7 <= 0 or r7 > r4 or doing:
>      rc = chkkey()
>    gives rc:
>      bttrace(btcb.klen)

Yes, this does indeed capture the principle.  I'm not going to quibble
over keywords.  Your keywords are perfectly understandable.  If this is
ever added to python, we can all vote on the keywords.

Another advantage of when/then/doing/gives is that break and continue are
no longer needed.  (Although labeled break/continue ala Java can do still
more.)  I'm not suggesting that we remove break and continue.  I haven't
tried to prove it yet, but I suspect that doing/gives and break/continue
provide exactly the same power to control loops and conditionals without
duplicating code. (Assuming that an infinite loop doesn't count as
duplicate code.  Is while 1: the most efficient Python infinite loop?)  I
find that doing/gives (I'm starting to like it better than when/then) is
easier to construct from real world conditions.  I can then translate to
break/continue forms for conventional languages.  (And a mechanical
translation is, of course, where a proof of equivalence would start.)

A disadvantage of doing/gives is that by deeply nesting additional control
structures within a doing clause (yes, you can put loops, with their own
doing/gives clause within a doing clause), the art of obfuscation reaches new
heights. :-)

-- 
	      Stuart D. Gathman <stuart at bmsi.com>
Business Management Systems Inc.  Phone: 703 591-0911 Fax: 703 591-6154
"Confutatis maledictis, flamis acribus addictis" - background song for
a Microsoft sponsored "Where do you want to go from here?" commercial.




More information about the Python-list mailing list