Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Re: A Design Pattern Question for Functional Programers

Reply
Thread Tools

Re: A Design Pattern Question for Functional Programers

 
 
Jürgen Exner
Guest
Posts: n/a
 
      04-20-2012
siva kkolundu <(E-Mail Removed)> wrote:
>http:/[...]


Do you mind explaining how you got the idea that Perl is a functional
programming language?
After you do I may even click on that link which you dumped into this
NG.

jue
 
Reply With Quote
 
 
 
 
ccc31807
Guest
Posts: n/a
 
      04-20-2012
On Apr 20, 7:59*am, Jürgen Exner <(E-Mail Removed)> wrote:
> Do you mind explaining how you got the idea that Perl is a functional
> programming language?
> After you do I may even click on that link which you dumped into this
> NG.


'Higher Order Perl' by Mark Jason Dominus.

This is available free as a PDF, but I bought a dead-tree version to
encourage the author, and I would encourage you to do the same.

CC.
 
Reply With Quote
 
 
 
 
Randal L. Schwartz
Guest
Posts: n/a
 
      04-24-2012
>>>>> "Ted" == Ted Zlatanov <(E-Mail Removed)> writes:

Ted> You can program Perl with FP idioms and enjoy it, but Perl is definitely
Ted> not a FP language. It doesn't have proper closures, for instance.

OK, I'm curious. What's a "proper closure", compared to Perl? Perl
certainly has more-proper closures than Python does.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<(E-Mail Removed)> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.posterous.com/ for Smalltalk discussion
 
Reply With Quote
 
Ted Zlatanov
Guest
Posts: n/a
 
      04-24-2012
On Tue, 24 Apr 2012 08:05:09 -0700 http://www.velocityreviews.com/forums/(E-Mail Removed) (Randal L. Schwartz) wrote:

>>>>>> "Ted" == Ted Zlatanov <(E-Mail Removed)> writes:

Ted> You can program Perl with FP idioms and enjoy it, but Perl is definitely
Ted> not a FP language. It doesn't have proper closures, for instance.

RLS> OK, I'm curious. What's a "proper closure", compared to Perl? Perl
RLS> certainly has more-proper closures than Python does.

Never mind Python, even Java claims it has closures. Compared to them,
Perl is a FP jewel.

IMO, the main non-FP trait in Perl is that it's an imperative language
by design and lots of its built-in functions have side effects,
especially on $_. That's not a bad thing, just not what you'd expect in
an FP environment. Also, I think proper FP languages require good
language support for passing, manipulating, and introspecting functions.
Perl doesn't really have that at the top level IMHO.

Beyond what's in perlfaq7 on closures... Perl has closure support, but
not enough to make it pleasant. The way $_ is handled (you have to say
"my $_"), for instance, is weird because $_ is the most stateful
variable in Perl and should IMO be automatically closed over. But that
would break a lot of code Also you can't be specific about which
variables you want to include in the closure, it's all lexicals, period.

Ted
 
Reply With Quote
 
Xah Lee
Guest
Posts: n/a
 
      04-27-2012
On Apr 26, 1:39*pm, (E-Mail Removed) (Greg Bacon) wrote:
> Ted Zlatanov wrote:
>
> : Never mind Python, even Java claims it has closures. *Compared to them,
> : Perl is a FP jewel.
>
> w00t!
>
> : IMO, the main non-FP trait in Perl is that it's an imperative language
> : by design and lots of its built-in functions have side effects,
> : especially on $_. *That's not a bad thing, just not what you'd expectin
> : an FP environment.
>
> The claim wasn't that Perl is a functional language but that
> functional idioms are comfortable in Perl.
>
> : * * * * * * * * * * Also, I think proper FP languages require good
> : language support for passing, manipulating, and introspecting functions..
> : Perl doesn't really have that at the top level IMHO.
>
> Please provide specific examples that demonstrate the deficiencies
> you have in mind. Perl isn't Haskell, but it gets along in passing,
> manipulating, and introspecting functions.
>
> Have you seen Higher Order Perl by Mark Dominus?
>
> http://hop.perl.plover.com/
>
> : Beyond what's in perlfaq7 on closures... *Perl has closure support, but
> : not enough to make it pleasant. *The way $_ is handled (you have to say
> : "my $_"), for instance, is weird because $_ is the most stateful
> : variable in Perl and should IMO be automatically closed over. *But that
> : would break a lot of code *Also you can't be specific about which
> : variables you want to include in the closure, it's all lexicals, period..
>
> When is this distinction meaningful? With
>
> * sub generate {
> * * my($foo,$bar,$baz) = qw/ quux potrzebie w00t /;
>
> * * # ...
>
> * * return sub { $foo . $_[0] . $bar };
> * }
>
> the runtime closes over $foo and $bar but not $baz.
>
> Greg


functional programing in perl is like using chopsticks at McDonalds:
Best done at home.

Xah
 
Reply With Quote
 
Ted Zlatanov
Guest
Posts: n/a
 
      04-27-2012
On Thu, 26 Apr 2012 15:39:44 -0500 (E-Mail Removed) (Greg Bacon) wrote:

GB> Ted Zlatanov wrote:

GB> : IMO, the main non-FP trait in Perl is that it's an imperative language
GB> : by design and lots of its built-in functions have side effects,
GB> : especially on $_. That's not a bad thing, just not what you'd expect in
GB> : an FP environment.

GB> The claim wasn't that Perl is a functional language but that
GB> functional idioms are comfortable in Perl.

OK. They are not, because *applying a function* was not a priority when
the language was designed, and because you must work around syntactic
inconsistencies.

GB> : Also, I think proper FP languages require good
GB> : language support for passing, manipulating, and introspecting functions.
GB> : Perl doesn't really have that at the top level IMHO.

GB> Please provide specific examples that demonstrate the deficiencies
GB> you have in mind. Perl isn't Haskell, but it gets along in passing,
GB> manipulating, and introspecting functions.

For instance, currying or partial application are not easy with an
anonymous subroutine. Function parameters are not named (it's just a
list, you do whatever you want with it). You can accomplish these
yourself or with modules, sure, but it's a stretch to call it a
comfortable situation.

GB> Have you seen Higher Order Perl by Mark Dominus?

GB> http://hop.perl.plover.com/

I wrote a review of it and recommend it highly every chance I get.

Ted
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ and design Pattern (Composite design Pattern ) Pallav singh C++ 1 01-22-2012 10:48 PM
C++ and design Pattern (Composite design Pattern ) Pallav singh C++ 0 01-22-2012 10:26 PM
C++ and design Pattern (Composite design Pattern ) Pallav singh C++ 0 01-22-2012 10:25 PM
May I have a example of design pattern of "composite", I still feel fuzzy after reading book of Addison-Wesley's"design pattern " jones9413@yahoo.com C++ 1 08-31-2007 04:09 AM
documents related to factory design pattern and Abstract foctory pattern. sunny C++ 1 12-07-2006 04:26 AM



Advertisments