in reply to Re^3: Functional Perl 6/PUGS
in thread Functional Perl 6/PUGS
My motto is, "objects make good nouns, functions make good verbs". A common situation is to do something like this:
where %handler is a hash mapping specific cases to anonymous functions saying what to do for each case. (Some of those anonymous functions may be very similar to each other, and you factor those out into closures...) Look for opportunities to use that, and try it a few times. See how it looks. See whether the construct stands up under normal maintainance.$handler{$case}->(@arguments);
After a period of becoming comfortable with that, then you can try another technique. Such as setting up a mess of related functions to fill out a template. (I find myself doing that more often in JavaScript than Perl. I write a function that takes a group of related form elements and gives them closely related event handlers.)
Once it is comfortable, it will probably become useful. And vice versa.
|
|---|