From btilly at gmail.com Mon May 21 00:01:36 2007 From: btilly at gmail.com (Ben Tilly) Date: Mon, 21 May 2007 00:01:36 -0700 Subject: [Oc-pm] Random note about the website Message-ID: I don't know how active or inactive OC.pm is. (I just subscribed to the mailing list.) But I do know that it wouldn't hurt for http://oc.pm.org/#mailing_list to be updated to say that we should go to http://mail.pm.org/mailman/listinfo/oc-pm to subscribe rather than emailing a majordomo email address that no longer works. Cheers, Ben From david.romano at gmail.com Tue May 22 12:33:34 2007 From: david.romano at gmail.com (David Romano) Date: Tue, 22 May 2007 12:33:34 -0700 Subject: [Oc-pm] Meetup Message-ID: <20070522193334.GF480@www.unobe.com> Hi everyone, Does anyone want to meet up tomorrow night (Wednesday) or possibly some other night in the near future? Just to talk about Perl, how we're using it (if at all right now), and what we're interested in using it for. I don't know where anyone else is in OC, but I'm located in Orange (92867). Perhaps we can meet at a Panera, like San Diego PM does? Anyone interested? - David -- "I don't know why we are here, but I'm pretty sure that it is not in order to enjoy ourselves." -- Ludwig Wittgenstein From david.romano at gmail.com Tue May 22 19:03:45 2007 From: david.romano at gmail.com (David Romano) Date: Tue, 22 May 2007 19:03:45 -0700 Subject: [Oc-pm] Meetup In-Reply-To: <20070522193334.GF480@www.unobe.com> References: <20070522193334.GF480@www.unobe.com> Message-ID: <20070523020345.GI480@www.unobe.com> Just a follow-up, we're meeting up tomorrow night (Wednesday) at 7:30pm at the Panera located at: 2214 North Tustin Street Orange, CA 92865 Look for the Camel book. Hope to see you there! - David -- "Currently, I'm making paper airplanes out of resumes." -- Carol Freire From david.romano at gmail.com Thu May 24 23:26:45 2007 From: david.romano at gmail.com (David Romano) Date: Thu, 24 May 2007 23:26:45 -0700 Subject: [Oc-pm] Meeting Notes Message-ID: <20070525062645.GB27744@www.unobe.com> Last night's meet up went pretty well! Three people showed up and it lasted for about an hour and a half. Doug Wilson, Peter Wilson, and I introduced ourselves to one another and talked a bit about our education and work histories. (Turns out we're all UC grads.) Doug came from Laguna Hills, and Pete and I came from Orange. The following are some of the things we talked about for the hour and a half we met: - LotusNotes Doug had a problem at work where everyone had to to basic cut-and-paste from LotusNotes into the ticket request tracker. Doug wanted to be Lazy, so he decided to figure out how to use Perl to interact with the database and extract the information they were supposed to cut-and-paste. He said the hardest part was sifting through the Perl docs and OLE information provided by IBM for LotusNotes to figure out how to correctly call the database. When he finished the program, it made a light bulb go on in one of the manager's brains, and now he's thinking of all sort of automation tasks they can now do with his program. Yay Doug! Yay Perl! http://perlmonks.org/?node_id=617131 - Parse::FixedLength At work Pete has built some scripts (Perl and C++) to process the data (some that's binary) that he's given. Doug said that Parse::FixedLength might help him when dealing with information that has a lot of columns. While Parse::FixedLength is just a glorified wrapper around pack/unpack, it does make it easier to manage a lot of data separated into columns that would otherwise be a pain to work with when just looking at the pack/unpack template. Pete fired up his laptop, and we looked at the module on CPAN. Pete says he might be able to use it, which we'll probably hear at the next meeting, if not sooner. http://search.cpan.org/~dougw/Parse-FixedLength-5.37/ - How to fix the website We talked briefly about Tilly's posting a few days ago, which brought to mind how out-of-date it was. Doug has been the maintainer for the website over the past few years, and he confessed that he dropped the ball in maintaining it, especially after accessing content on the server changed. It used to be you could just SSH in, but now it's something to do with WebDAV. The next step is to find out the passwords to access the site again, and change the content. Doug believes the passwords are somewhere in his mail archives, and will try to scrounge them up sometime before the next meeting. - HOP & the Y Combinator I brought HOP along with Programming Perl, and we discussed the great ideas it contains, but lack of abstraction that the Iterator* modules provide. We agreed that we usually just used bits and pieces of what was described in the book, and morphed it to suit the problem at hand. Doug mentioned that if you use iterators and streams too much, you'll start to get memory leaks because the new anonymous subs that it generates won't always be destroyed properly by perl. This then segued into Pete's understanding of the Y Combinator: an recursive anonymous function generator that properly destroys the functions it generates. Pete even said that he had implemented the Y Combinator in a language that's not Lisp (IIRC, Perl). http://en.wikipedia.org/wiki/Y_combinator - Moose We talked about it being a way to do Perl 6 object-oriented stuff in Perl 5. None of us really had much experience with it. I used it for a couple projects (one of them on CPAN), but hadn't used many of its neat tricks. I told them the nice thing I liked about it was that it had type constraints, which I found very helpful. http://search.cpan.org/~stevan/Moose-0.21/ - Project for the group I brought up the possibility of coming up with a project that the group can work on together when we meet. Alternatively, we can work on parts separately, and talk a bit about our parts of the project when we do meet up. I guess the first step is to find out a project to do. I really only have two ideas so far: - Play with Catalyst to work on the OC PM website. Maybe even use Mojomojo for our PM wiki. This would also help us get more experience working with databases, which Pete said he'd be interested in doing (as would I). http://www.catalystframework.org/ - Help out with the Pugs or Parrot projects. Right now I know that they're both pining for someone(s) to fill the role of kudra in writing thread summaries every week. If some of us are willing to set aside an half an hour here, half an hour there, we can summarize maybe just a thread or two, and combine them to send to the list. This would also help us learn more about the status of each project, too. http://www.parrotcode.org/ http://www.pugscode.org/ - David -- "The Romans would never have found time to conquer the world if they had been obliged first to learn Latin." -- Heinrich Heine From btilly at gmail.com Fri May 25 08:13:11 2007 From: btilly at gmail.com (Ben Tilly) Date: Fri, 25 May 2007 08:13:11 -0700 Subject: [Oc-pm] Meeting Notes In-Reply-To: <20070525062645.GB27744@www.unobe.com> References: <20070525062645.GB27744@www.unobe.com> Message-ID: On 5/24/07, David Romano wrote: > Last night's meet up went pretty well! Three people showed up and it > lasted for about an hour and a half. Doug Wilson, Peter Wilson, and I > introduced ourselves to one another and talked a bit about our education > and work histories. (Turns out we're all UC grads.) Doug came from > Laguna Hills, and Pete and I came from Orange. The following are some of > the things we talked about for the hour and a half we met: I may sporadically be able to make these, but not until after my new job starts next month. [...] > - How to fix the website > We talked briefly about Tilly's posting a few days ago, which > brought to mind how out-of-date it was. Doug has been the > maintainer for the website over the past few years, and he > confessed that he dropped the ball in maintaining it, especially > after accessing content on the server changed. It used to be > you could just SSH in, but now it's something to do with WebDAV. > The next step is to find out the passwords to access the site > again, and change the content. Doug believes the passwords are > somewhere in his mail archives, and will try to scrounge them up > sometime before the next meeting. I'll be glad to see that. > - HOP & the Y Combinator > I brought HOP along with Programming Perl, and we discussed the > great ideas it contains, but lack of abstraction that the > Iterator* modules provide. We agreed that we usually just used > bits and pieces of what was described in the book, and morphed > it to suit the problem at hand. Doug mentioned that if you use > iterators and streams too much, you'll start to get memory leaks > because the new anonymous subs that it generates won't always be > destroyed properly by perl. This then segued into Pete's > understanding of the Y Combinator: an recursive anonymous > function generator that properly destroys the functions it > generates. Pete even said that he had implemented the Y > Combinator in a language that's not Lisp (IIRC, Perl). > http://en.wikipedia.org/wiki/Y_combinator You can't really do the Y Combinator in Perl because one of the key points of the combinator is that you should not need any form of assignment, and Perl can't process function arguments without using assignment. That said, http://www.mail-archive.com/boston-pm at mail.pm.org/msg02716.html walks through what the Y Combinator is and how one might arrive at it. I did it there in JavaScript, which is a language that many will find fairly easy to read. [...] Cheers, Ben From mnagel at willingminds.com Fri May 25 09:16:55 2007 From: mnagel at willingminds.com (Mark D. Nagel) Date: Fri, 25 May 2007 09:16:55 -0700 Subject: [Oc-pm] Meeting Notes In-Reply-To: References: <20070525062645.GB27744@www.unobe.com> Message-ID: <46570BF7.1030108@willingminds.com> Ben Tilly wrote: > You can't really do the Y Combinator in Perl because one of the key > points of the combinator is that you should not need any form of > assignment, and Perl can't process function arguments without using > assignment. I'm not familiar with all the details on this one, but is the problem that when you use function arguments without assignment that they are passed by reference? Because I know you can process arguments without assignment as long as they are not altered (unless that is the intent) and you don't mind line noise :). Regards, Mark -- Mark D. Nagel, CCIE #3177 Principal Consultant, Willing Minds LLC (http://www.willingminds.com) cell: 949-279-5817, desk: 714-630-4772, fax: 949-623-9854 From chris at chrisgrau.com Fri May 25 09:41:39 2007 From: chris at chrisgrau.com (Chris Grau) Date: Fri, 25 May 2007 09:41:39 -0700 Subject: [Oc-pm] Meeting Notes In-Reply-To: <20070525062645.GB27744@www.unobe.com> References: <20070525062645.GB27744@www.unobe.com> Message-ID: <20070525164139.GO12834@chrisgrau.com> On Thu, May 24, 2007 at 11:26:45PM -0700, David Romano wrote: > Last night's meet up went pretty well! Three people showed up and it > lasted for about an hour and a half. It's great to hear that OC.pm is getting some new life to it. Sounds like you guys have some big and fun plans. If I happen to be in the area at the same time as one of your meetings, I'll be sure to drop in. -- Chris Grau -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://mail.pm.org/pipermail/oc-pm/attachments/20070525/4d71ee7c/attachment.bin From btilly at gmail.com Fri May 25 10:53:57 2007 From: btilly at gmail.com (Ben Tilly) Date: Fri, 25 May 2007 10:53:57 -0700 Subject: [Oc-pm] Meeting Notes In-Reply-To: <46570BF7.1030108@willingminds.com> References: <20070525062645.GB27744@www.unobe.com> <46570BF7.1030108@willingminds.com> Message-ID: On 5/25/07, Mark D. Nagel wrote: > Ben Tilly wrote: > > You can't really do the Y Combinator in Perl because one of the key > > points of the combinator is that you should not need any form of > > assignment, and Perl can't process function arguments without using > > assignment. > > I'm not familiar with all the details on this one, but is the problem > that when you use function arguments without assignment that they are > passed by reference? Because I know you can process arguments without > assignment as long as they are not altered (unless that is the intent) > and you don't mind line noise :). Passed by reference is not the problem. Dynamic scoping is. To make the Y Combinator work you need to use currying, and currying requires lexically scoped variables. Currying is turning things like F = function (i, j) { ... }; F(i,j); into things like F = function (i) { return function (j) { ... }}; F(i)(j); but that only works if the anonymous function returned by the second version of F actually has i lexically scoped. Cheers, Ben From peter.t.wilson at gmail.com Fri May 25 14:47:03 2007 From: peter.t.wilson at gmail.com (Pete Wilson) Date: Fri, 25 May 2007 14:47:03 -0700 Subject: [Oc-pm] Meeting Notes In-Reply-To: References: <20070525062645.GB27744@www.unobe.com> <46570BF7.1030108@willingminds.com> Message-ID: <4c3ca8c50705251447v48d145abv524cbe90faca3d03@mail.gmail.com> Hi all, It is true that the only way to bind function arguments to lexically scoped variables in Perl is to use the "=" operator. But, I just used assignment to bind function arguments to lexical variable. No changing a variables value in a given scope/environment once it is set. My rationalization for this actually comes from previous experience with C++. C++ uses the "=" operator for both assignment and initialization. For example, "int I = 0;" is considered an initialization statement where as "I = 1;" is considered an assignment statement. This doesn't map 1 to 1 with what I did in perl. I'm not doing initialization I'm binding lexicaly scoped function arguments, but all the assignments I do in my Y combinator implementation are to variables immediately preceded by "my". What I currently have is a derivation of the Y combinator using the factorial function as an example recursive function. The Perl file is currently about 200 lines; although the final combinator it's self is only 11 lines. I'm currently tweaking it to make sure I understand what I did. I will try to post what I have in about half an hour. -Pete On 5/25/07, Ben Tilly wrote: > On 5/25/07, Mark D. Nagel wrote: > > Ben Tilly wrote: > > > You can't really do the Y Combinator in Perl because one of the key > > > points of the combinator is that you should not need any form of > > > assignment, and Perl can't process function arguments without using > > > assignment. > > > > I'm not familiar with all the details on this one, but is the problem > > that when you use function arguments without assignment that they are > > passed by reference? Because I know you can process arguments without > > assignment as long as they are not altered (unless that is the intent) > > and you don't mind line noise :). > > Passed by reference is not the problem. Dynamic scoping is. > > To make the Y Combinator work you need to use currying, and currying > requires lexically scoped variables. Currying is turning things like > > F = function (i, j) { > ... > }; > F(i,j); > > into things like > > F = function (i) { return function (j) { > ... > }}; > F(i)(j); > > but that only works if the anonymous function returned by the second > version of F actually has i lexically scoped. > > Cheers, > Ben > _______________________________________________ > Oc-pm mailing list > Oc-pm at pm.org > http://mail.pm.org/mailman/listinfo/oc-pm > From peter.t.wilson at gmail.com Fri May 25 16:35:59 2007 From: peter.t.wilson at gmail.com (Pete Wilson) Date: Fri, 25 May 2007 16:35:59 -0700 Subject: [Oc-pm] A derivation of the Y combinator implemented in perl Message-ID: <4c3ca8c50705251635v24572483xa64b7936fcc3d277@mail.gmail.com> #! /usr/bin/perl use warnings; use strict; # This was created after reading # http://weblog.raganwald.com/2007/02/but-y-would-i-want-to-do-thing-like.html # which encouraged us to read "The Why of Y" by Richard Gabriel, which # is available at http://www.dreamsongs.com/NewFiles/WhyOfY.pdf, and # implement a Y combinator in our favorite language. I have been # messing around with scheme for about a year now and I though I could # translate Richard Gabriel's code to Perl. This is my attempt. It # baby steps through the same derivation Richard uses. # Start with the canonical recursive function, factorial. sub fact { my $n = shift; return 1 if $n < 2; return $n * fact( $n - 1 ); } # Here is a baseline check. Hopefully the result will stay the same while # we mess with the implementation. print fact( 10 ), "\n"; # Here is an factorial implementation that maintains an explicit # reference to the recursive function. sub fact1 { my $f = shift; my $n = shift; return 1 if $n < 2; return $n * $f->( $f, $n - 1 ); } # We have to call it with a reference to itself. print fact1( \&fact1, 10 ), "\n"; # Result check # We can separate the handling of the function reference from the # arguments to the function using a technique called currying. Currying # converts a function of two arguments into a function of one argument # that returns a function of one argument that returns the result. sub fact2 { my $f = shift; return sub { my $n = shift; return 1 if $n < 2; return $n * $f->($f)->( $n - 1 ); }; } # I still have to use a reference to the function itself. print fact2( \&fact2 )->( 10 ), "\n"; # Result check # Notice the in fifth line of fact2 where $f is called with $f as it's # argument. This is why the Y combinator is call a fixed point # operator. I don't understand all the theoretical implications of # this, but I think it is the key to the Y combinator's theoretical # power. Note also that this only works when we kick the whole # process off with fact2( \&fact2 )->( * ). At this point calling the # function and the functions implementation are tightly coupled # together. I try to clean that up by making things more complicated. # We create an anonymous subroutine that encapsulates most of the work # in the inner subroutine in fact2. We name this subroutine $h # before calling it because we will want a handle on it in a few # steps. sub fact3 { my $f = shift; return sub { my $m = shift; my $h = sub { my $n = shift; return 1 if $n < 2; return $n * $f->($f)->( $n - 1 ); }; $h->( $m ); }; } # The call mechanism remains the same. print fact3( \&fact3 )->( 10 ), "\n"; # Result check # Now we apply a transformation to $h similar to the one used to create # fact1 from fact. sub fact4 { my $f = shift; return sub { my $m = shift; my $h = sub { my $q = shift; my $n = shift; return 1 if $n < 2; return $n * $q->( $n - 1 ); }; $h->( $f->( $f ), $m ); } } # Notice that the fixed point application $f->($f) has been moved out # of $h by the introduction of the function reference $q, which # receives the result of $f->($f) when $h is called. # The call mechanism remains the same. print fact4( \&fact4 )->( 10 ), "\n"; # Result check # Now re-apply the transformation from fact1 to fact2 on the innermost # subroutine of fact4, i.e. separate the handling of the anonymous # function argument from the argument to the recursive function using # currying. sub fact5 { my $f = shift; return sub { my $n = shift; my $h = sub { my $q = shift; return sub { my $n = shift; return 1 if $n < 2; return $n * $q->( $n - 1 ); }; }; $h->( $f->( $f ))->( $n ); } } # The call mechanism remains the same. print fact5( \&fact5 )->( 10 ), "\n"; # There are a couple of things to notice here. First, notice that the # subroutine returned from $h contains all the "factorial logic". It # looks almost exactly like our original factorial function except # instead of recursing on a named function it recurses on $q which # fact5 arranges to be the function returned from $h. Second, notice # that $h does not have to be defined nested inside the anonymous # function returned from fact5. fact6 moves it all the way out. my $h = sub { my $q = shift; return sub { my $n = shift; return 1 if $n < 2; return $n * $q->( $n - 1 ); }; }; sub fact6 { my $f = shift; return sub { my $n = shift; $h->( $f->( $f ) )->( $n ); } } # The same external interface. print fact6( \&fact6 )->( 10 ), "\n"; # Now we wrap a function around fact6 and the recursive application of # fact6 to a reference of itself, convert fact6 to an anonymous # function which we store in a variable named $g, and voila, we end # up with the Y combinator. sub Y { my $h = shift; my $g = sub { my $f = shift; return sub { my $n = shift; $h->( $f->( $f ) )->( $n ); }; }; $g->( $g ); } # We pass the function we used to have in $h as the argument to Y, and # it gets bound as a function parameter. my $fact = Y( sub { my $q = shift; sub { my $n = shift; return 1 if $n < 2; return $n * $q->( $n - 1 ); } } ); # Since $g->( $g ) is now encapsulated in Y we no longer need it in # the calling syntax. print $fact->( 10 ), "\n"; # While factorial is the most common recursive example it is easily # and efficiently implemented iteratively, so it isn't the best # demonstration of the power of recursive functions. Enumerating tree # structure elements is a great example of a problem that recursive # algorithms solve easily. This example shows how to use Y to # recursively enumerate the contents of a directory tree. my $files = Y( sub { my $f = shift; sub { my $file = shift; return $file unless -d $file; return () if( $file =~ qr{\.{1,2}} ); opendir DIR, $file or die "unable to open dir $file"; return $file, map { $f->( "$file\\$_" ) } readdir DIR; } } ); # This requires a path to a directory with some sub directories in it. # It recusivly lists files and directories under it. print join "\n", $files->( 'D:\pub\src\perl\ycombinator' ); From btilly at gmail.com Fri May 25 16:35:32 2007 From: btilly at gmail.com (Ben Tilly) Date: Fri, 25 May 2007 16:35:32 -0700 Subject: [Oc-pm] Meeting Notes In-Reply-To: <4c3ca8c50705251447v48d145abv524cbe90faca3d03@mail.gmail.com> References: <20070525062645.GB27744@www.unobe.com> <46570BF7.1030108@willingminds.com> <4c3ca8c50705251447v48d145abv524cbe90faca3d03@mail.gmail.com> Message-ID: On 5/25/07, Pete Wilson wrote: > Hi all, > > It is true that the only way to bind function arguments to lexically > scoped variables in Perl is to use the "=" operator. But, I just used > assignment to bind function arguments to lexical variable. No > changing a variables value in a given scope/environment once it is > set. If you're willing to consider that, then sure, you can do it in Perl. > My rationalization for this actually comes from previous experience > with C++. C++ uses the "=" operator for both assignment and > initialization. For example, "int I = 0;" is considered an > initialization statement where as "I = 1;" is considered an assignment > statement. This doesn't map 1 to 1 with what I did in perl. I'm not > doing initialization I'm binding lexicaly scoped function arguments, > but all the assignments I do in my Y combinator implementation are to > variables immediately preceded by "my". > > What I currently have is a derivation of the Y combinator using the > factorial function as an example recursive function. The Perl file is > currently about 200 lines; although the final combinator it's self is > only 11 lines. I'm currently tweaking it to make sure I understand > what I did. I will try to post what I have in about half an hour. 200 lines? Seems excessive. The following computes 5!: sub { my $builder = shift; sub { my $n = shift; $builder->($builder)->($n); } }->( sub { my $recurse = shift; sub { my $n = shift; (0 == $n) ? 1 : $n * $recurse->($recurse)->($n - 1); } } )->(5); Generalizing this would take more code, but it is all a question of how you want to generalize it. Ben From dgwilson1 at cox.net Sun May 27 12:00:00 2007 From: dgwilson1 at cox.net (Douglas Wilson) Date: Sun, 27 May 2007 11:00:00 -0800 Subject: [Oc-pm] Meeting Notes In-Reply-To: <20070525062645.GB27744@www.unobe.com> References: <20070525062645.GB27744@www.unobe.com> Message-ID: <4659D530.9050702@cox.net> David Romano wrote: > > - Parse::FixedLength Also, Simon Cozen's module I was trying to remember is: Parse::Binary::Iterative and the Audrey's module that it was based on is: Parse::Binary. > - How to fix the website I signed up for the bitcard account back when they changed servers, but never had my account associated with the 'oc' website, so I've just now emailed support to do that. If anyone else wants access, let me know. > - HOP & the Y Combinator There was a good discussion about this on use.perl: http://use.perl.org/~Aristotle/journal/30896 It's been sort of a fascination/obsession for me. I also agree that although perl can't strictly do the Y-combinator, I'd cut it some slack and not really count the initial argument assignments from @_ as 'assignments' (though Perl 6 will probably be changing that) :-) > > - Play with Catalyst to work on the OC PM website. Maybe even > use Mojomojo for our PM wiki. This would also help us get > more experience working with databases, which Pete said he'd > be interested in doing (as would I). > http://www.catalystframework.org/ The current setup does not allow dynamic content, only static pages. Someone would need to host the site on their own servers (or some server that allows that sort of thing). And many thanks to David for just saying "Hey, let's get together", and for putting together these notes! -Doug From dgwilson1 at cox.net Sun May 27 12:03:09 2007 From: dgwilson1 at cox.net (Douglas Wilson) Date: Sun, 27 May 2007 11:03:09 -0800 Subject: [Oc-pm] Meeting Notes In-Reply-To: <20070525062645.GB27744@www.unobe.com> References: <20070525062645.GB27744@www.unobe.com> Message-ID: <4659D5ED.1010609@cox.net> David Romano wrote: > > - Parse::FixedLength Parse::Binary::Iterative Oh, and the post I first learned about Simon Cozen's module which discussed figuring out an unknown binary format was here: http://blog.simon-cozens.org/post/view/1195