Sorry buddy - thought I was replying to the whole group :(

-- Jim

On 3/23/07, Jim Wilson <[EMAIL PROTECTED]> wrote:

> Lexical anonymous functions would be enough for me. If these proposed
> lexical anonymous functions could automagically bind themselves
> to an instance's $this when called from within an object's scope (so as
to act
> as virtual methods), that would be grand.

I agree - I don't need closures, but anonymous functions would be great.

Perhaps a very minor point, but using create_function requires that the
code is an executable string.  From a maintainability standpoint, this is a
little weird since it won't be syntax-highlighted etc. (Again, very very
minor).

Question: If lexical anonymous functions were added, could this be used
with preg_replace and the 'e' modifier?

So instead of:
    preg_replace('/some_pattern/e', 'base64_encode($0)', $someVar);

We could use:
    preg_replace('/some_pattern/e', function ($matches) {
        return base64_encode($matches[0]);
    }, $someVar);

I'd love this.

-- Jim R. Wilson (jimbojw)

On 3/23/07, boots <[EMAIL PROTECTED]> wrote:
>
> --- Richard Lynch <[EMAIL PROTECTED]> wrote:
> > On Thu, March 22, 2007 8:09 am, Christian Schneider wrote:
> > >> Plain old google brought up:
> > >>  
http://groovy.codehaus.org/Martin+Fowler's+closure+examples+in+Groovy<http://groovy.codehaus.org/Martin+Fowler%27s+closure+examples+in+Groovy>
> > >> among other hits (Groovy syntax should be easy enough to follow).
> > >
> > > He said real-life examples (-:C
> >
> > I said real-life NEED, as in, "I can't do X in a clean/decent way
> > without a closure"
> >
> > Wanting to write obfuscated natural-language-looking code is not a
> NEED.
> > :-) :-) :-)
> >
> > The only programmers I ever met in 25 years who NEEDED closures were
> > AI Researchers (and I was one).  And, yes, there IS a need for them in
> > that kind of work.
>
> Hi. I usually just lurk this list but I wanted to express my support for
> the
> idea of anonymous functions as a lexical construct. I think that would
> be a
> dandy addition. That said, I don't think that there is any need to
> support
> closures, which in my mind represent a rather fundamental language view
> which
> is at odds with PHP's traditional variable scoping. I think closures are
> fantastic but only in languages which take that particular variable
> scoping
> view from the outset. Lexical anonymous functions would be enough for
> me. If
> these proposed lexical anonymous functions could automagically bind
> themselves
> to an instance's $this when called from within an object's scope (so as
> to act
> as virtual methods), that would be grand.
>
> Sorry for the noise,
> boots
>
> > How many AI researchers have turned to PHP as their language of
> choice?
> >
> > 0.5, counting the guy who wrote that neural network thingie in PHP as
> > his idea of a Good Time is all I know of...
>
>
>
>
>
> 
____________________________________________________________________________________
> Looking for earth-friendly autos?
> Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.
> http://autos.yahoo.com/green_center/
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Reply via email to