Re: A replacement for lambda



Stefan Rank wrote:
> on 30.07.2005 10:20 Paolino said the following:
>> why (x**2 with(x))<(x**3 with(x)) is not taken in consideration?
>>
>> If 'with' must be there (and substitue 'lambda:') then at least the
>> syntax is clear.IMO Ruby syntax is also clear.
>>
>
> I am sorry if this has already been proposed (I am sure it has).
>
> Why not substitue python-lambdas with degenerated generator expressions::
>
> (lambda x: func(x)) == (func(x) for x)
>
> i.e. a one time callable generator expression (missing the `in` part).
> The arguments get passed into the generator, I am sure that can be
> combined with the PEP about passing args and Exceptions into a generator.

It's hard to spot, and it's too different to a genexp to have such a similar
syntax.

Reinhold
.



Relevant Pages

  • Re: The problem with "as" [was "Re: PEP 318"]
    ... By "modified syntax" I mean an extension of the current standard ... comment characters depending on which external tool the command was ... differences being the use of a special symbol, ... function into a generator. ...
    (comp.lang.python)
  • Re: Callable generators (PEP 288: Generator Attributes, again)
    ... > I'm suggesting the PEP's functionality, not its syntax and semantics. ... > iterator is called, behaving like a state-persistent callable function. ... do think an iterator as something which it obtained by "instantiating" ... > Here's an efficient reversable generator: ...
    (comp.lang.python)
  • Re: Callable generators (PEP 288: Generator Attributes, again)
    ... >> I'm suggesting the PEP's functionality, not its syntax and semantics. ... >> yield x ... of the generator (which would in general require suspending a stack of frames, ... factory function name again to pass values into the generator, ...
    (comp.lang.python)
  • Re: foreach enhancement
    ... >> for two sequences which happen to share an endpoint, ... Consider each 1...n expression to be a generator, ... When wrapped in the syntax, ... warning like "List on line XXX generates duplicate values", ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: design and lisp
    ... > Me, I like sexpr syntax and Lisp syntax in general, so I have never ... > gone hole hog and created an embedded language, ... For instance a parser generator ... call it "Lisp". ...
    (comp.lang.lisp)