[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Goal oriented programming



"Edward M. Perry" wrote:
> Conditions following statements are (IMO) lame.
> I wish I had a script to undo them.
> 
> I'm glad the real world doesn't give instuctions like this:
> 
> Put jelly on bread, but first, toast bread.
> 
> Perl statements like those sound just as ridiculous as just
> as out of order. I must be missing out on a lot of fun...

Yes, you are missing the real fun in perl...

The option of putting the conditional *behind* the action
allows to make the code more understandable. 

The purpose of putting the conditional *behind* the action
is to direct the reader's attention to the action. So if 
I say:

  die unless $ok;

it tells the reader that some error checking took place
and that the program won't continue after this point if
an error was found.

Especially in receipts, the condition is put after the action
to allow an experienced cook (for whom the receipt is just
a reminder of the essential steps) to skip reading it.

To use your example:

  toast ($bread);
  put ($butter => $bread) if $you->like($butter);
  put ($jelly  => $bread);

IMHO, writing programs that read like receipts (or even
like poetry) is the real fun that perl can provide...

Roland
--
# Of course, Obfuscated Perl is where the *deep* fun starts...
perl -e '@_=@ARGV;$_="@_[-3,-2,-1]";s{([@{[$_[-1]]}])}#($0=$1.
${[qw[>$%, ()%{&", &"=, |}+&" *]]}[$@++])=~y/*=->$%&"(-){-}+,/
lusternohack /,$0#eg; print; '        -- Roland Giersig, JAPH.

==== Want to unsubscribe from Fun With Perl?
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org