A replacement for lambda

James Richards rootrot at govtabuse.com
Sat Jul 30 00:38:36 EDT 2005


On 2005-07-30, Scott David Daniels <Scott.Daniels at Acm.Org> wrote:
> Christopher Subich wrote:
>> g = <x**2 with (x)>
>> g(1) == 1
>> 
>> Basically, I'd rewrite the Python grammar such that:
>> lambda_form ::= "<" expression "with" parameter_list ">"
>> 
>> Biggest change is that parameter_list is no longer optional, so 
>> zero-argument expr-comps would be written as <expr with ()>, which makes 
>> a bit more sense than <expr with>.
>> 
>> Since "<" and ">" aren't ambiguous inside the "expression" state, this 
>> shouldn't make the grammar ambiguous.  The "with" magic word does 
>> conflict with PEP-343 (semantically, not syntactically), so "for" might 
>> be appropriate if less precise in meaning.
>
> What kind of shenanigans must a parser go through to translate:
>      <x**2 with(x)><<x**3 with(x)>
>
> this is the comparison of two functions, but it looks like a left-
> shift on a function until the second with is encountered.  Then
> you need to backtrack to the shift and convert it to a pair of
> less-thans before you can successfully translate it.

I'm just worming my way into learning Lisp, but this seems to be a
perfect example of everything I'm seeing so far.  The compiler should
do all sorts of gymnastics and contortions.  Make the compiler/interpreter
as complex as possible, to handle any freaky thing a programmer can
invent.

Which does not, in the least, imply that the same attitude should apply toward
python.

I read this thread and my brain hurts.  Python code should *never* do this.

Tim Peters (let's all bow down, we're not worthy <g>) might write some code that
I can't quite follow.  But at least it's obvious.  He doesn't suddenly introduce
an entirely new syntax for the sake of "hey, this would be cool." Or maybe
"It'd be much more simple if we made everyone use more C-like syntax." Or...
wherever you were going with this.  This
>
>      <x**2 with(x)><<x**3 with(x)>
is precisely the kind of code that I got into python to avoid.

I happen to like nice, simple, readable code.  Maybe I'm just old and grumpy.  
Looking at that line, I get the same "This is just ugly" feel that I get when 
I at perl.  Some note from other pieces in this thread.  Things about $_ or 
what-not.


Personally, I can't recall any decent programmer I know who objects to actually
writing out a variable name.  In fact, I don't know a single "real" programmer
(this is one who writes programs he intends to look at again in, say, 3 weeks) 
who doesn't insist on writing "real" variable names.

(Heh. I'll probably read through some Guido code next week that totally proves 
me wrong <g>...such is life).

> --Scott David Daniels
> Scott.Daniels at Acm.Org


-- 
Liberty means responsibility. That is why most men dread it.
- George Bernard Shaw




More information about the Python-list mailing list