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

Re: [MacPerl] Coding style



At 12.01 -0500 1999.02.04, Raffael Cavallaro wrote:
>>From: "Emmanuel. M. Decarie" <emm@cam.org>
>
>> what we call in French "effet de bord"
>
>"Effet de bord" == "side effect"
>
>Programming by side effects is generally considered bad style in anglophone
>countries as well.

Well, not necessarily in Perl.  Side effects are kinda part of Perl.
Consider this:

  #!perl -wl
  $a = {};
  print 1 if exists $a->{A};
  print 2 if defined $a->{A}{B};
  print 3 if exists $a->{A};

$a->{A} now exists due to autovivification.

Then there are all the regex side effects, which cause variable values to
spring into existence.

And then there is the side effect that the context of a function call
determines the context of return:

  sub foo {return @_}
  @a = ('a'..'j');
  @b = foo(@a);
  $b = foo(@a);
  print @b;
  print $b;

There are more, but just these to note that side effects are a part of what
programming Perl is about.  That doesn't mean these are always good, but
they are almost always there.

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch