Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Functional Programming & method rewriting

by Velaki (Chaplain)
on Oct 29, 2004 at 04:24 UTC ( [id://403592]=note: print w/replies, xml ) Need Help??


in reply to Functional Programming & method rewriting

I like the FP style, but would a double-closure be an application of the factory design pattern; and if so, would a generalized closure generator be an implemented abstract factory?

Musing,
-v
"Perl. There is no substitute."

Replies are listed 'Best First'.
Re^2: Functional Programming & method rewriting
by revdiablo (Prior) on Oct 29, 2004 at 16:25 UTC
    would a double-closure be an application of the factory design pattern

    I am sorry to pick nits, but this is something that seems to be confused a lot. I wouldn't really call this a double closure. It's just a closure that uses anonymous subroutines. The inner subroutines are not stored anywhere, so they don't have a chance to close around their lexical environment.

      Nope, they close very briefly around @args, as wrong as that is, they do. Whether they are used once or twice or thrice is indifferent to the fact that @args is lexically picked up.

        That's true, but if you used that as the definition of "closure", then every subroutine that is in a lexical environment is a closure. That makes the term practically useless.

        I think it's more useful to consider a closure to be a subroutine that closes around its lexical environment, and uses it to maintain state between invocations. It may not be as technically accurate, but it captures the meaning I think is most common, and definitely more useful.

Re^2: Functional Programming & method rewriting
by SpanishInquisition (Pilgrim) on Oct 29, 2004 at 12:51 UTC
    maybe it's a factory factory.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://403592]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-03-28 11:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found