[Python-Dev] A Hygienic Macro System in Python?

Duncan Booth duncan@rcp.co.uk
2002年3月20日 09:38:01 +0000


On 20 Mar 2002, barry@zope.com (Barry A. Warsaw) wrote:
> In the following example, imagine that
>> using <expr>:
> suite()
>> is syntactic sugar for:
>> using(<expr>, suite)
>>
How about imagining:
 	using <expr>:
 	 suite
is syntactic sugar for:
 anon1 = <expr>
 for anon2 in anon1:
 try:
 suite
 except:
 anon1.throw() # Assuming PEP279 part 3
def WithLock():
 print "Acquiring lock"
 try:
 yield None
 finally:
 print "Releasing lock"
using WithLock():
 doSomethingCritical()
-- 
Duncan Booth duncan@rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["5円\x83円"
"6円7円\xb1円\x9\xa2円0円4円"];} // Who said my code was obscure?

AltStyle によって変換されたページ (->オリジナル) /