Re: [Pyobjc-dev] Objective-P?
Brought to you by:
ronaldoussoren
From: Anders H. <bo...@ki...> - 2009-11-12 11:00:21
|
On Thu, Nov 12, 2009 at 10:59 AM, Ronald Oussoren <ron...@ma...>wrote: > > On 12 Nov, 2009, at 0:01, Anders Hovmöller wrote: > > [ .... ] > > > Find attached the source for the custom importer. > > > While this is a nice trick I'd be much more interested in a syntax-change > that at least has a chance of getting accepted into the Python core. Your > syntax for calling a method is ambiguous, at least for the parser using in > CPython and possibly in general: > > 10 <foo + bar> baz > > Python's parser needs to know if the '<' token is the start of a method > call or a comparison operator (and so do humans, it's far from clear what's > going on here when I look at the code). > Yea, I know. I just chose <> instead of [] to finish my quick and dirty prototype in the two hours I had alloted :P As for trying to get something that can be accepted into Python proper, I think that's a dead end. Python already has a syntax for named parameters. I think this calls for a domain specific extension, not something you'd necessarily want to push up to CPython. > > I've been thinking about syntax enhancements during the summer, the best I > could think of was the introduction of a new operator: > > class MyObject (NSObject): > def $[setValue: value]: > pass > > $[myObject setValue:42] > > In this code '$[' would be a new operator, which should be unambigous > w.r.t. existing code. Better yet, one could use a simular trick for > anonymous functions: > > Hmm, yea that's probably a nicer way of doing it. Changing from < and > to $[ and ] should be a rather trivial change in the hack I wrote. Best regards, Anders |