Re: finding common words

From: Uri Guttman (uri_at_stemsystems.com)
Date: 02/24/04


Date: Tue, 24 Feb 2004 19:41:36 GMT


>>>>> "HJ" == Hunter Johnson <hunter@hunterandlori.com> writes:

  HJ> Uri Guttman <uri@stemsystems.com> wrote in message news:<x74qth75vw.fsf@mail.sysarch.com>...
>> i was never really upset about the efficiency issue which has been
>> changed. i didn't like the semantic problem of throwing away the list
>> that map is supposed to make. now the docs will say there is no
>> generated list in void context so that may be harder to argue. but i
>> still say that map tells the reader a list is being made so look for
>> it.

  HJ> If the docs say there is no list generated, how is map going to tell
  HJ> the reader that the docs are wrong?

  HJ> If a reader reads something extra into what's written (like "here
  HJ> comes a list" when none is coming), how is that more the writer's
  HJ> problem than the reader's? Either the writer can write it
  HJ> differently (using 'for' in this case) or the reader can read it
  HJ> differently. I don't see how the former is the only right answer.

it is a semantic communication to the reader of the code. it is your
(the coder's) responsibility to convey as much accurate information to
the reader as possible. map in a void context is not as accurate as a
for modifier even with the optimization. sure the docs will say it won't
generate a list but its history has always been that way. map is clearer
for generating new stuff and for modifier is clearer for side effects.
remember map has the same signature as grep which also returns a
list which will confuse newbies about this issue. and just because
something works a certain way doesn't mean you have to use it. i choose
not to use map in void context and teach that as well.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


Relevant Pages

  • Re: finding common words
    ... > i was never really upset about the efficiency issue which has been ... i didn't like the semantic problem of throwing away the list ... > that map is supposed to make. ... the reader that the docs are wrong? ...
    (comp.lang.perl.misc)
  • Re: finding common words
    ... > HJ> If the docs say there is no list generated, how is map going to tell ... > it is a semantic communication to the reader of the code. ... > responsibility to convey as much accurate information to ... now -- no list in void context means that programmers can (and should, ...
    (comp.lang.perl.misc)
  • Re: Map Endpapers!
    ... How significant are map endpapers, ... I find it interesting when a publisher puts different map ... I think that much of the time when a dealer mentions "map endpapers", he/she is trying to make sure the reader understands which edition is on offer. ...
    (rec.collecting.books)
  • Re: converting a sed / grep / awk / . . . bash pipe line into python
    ... use of map() and just write: ... The potential unpack and conversion errors exist ... by the shared error handling. ... a reader of the code to follow what it's doing. ...
    (comp.lang.python)
  • Re: Style question: map versus foreach
    ... @@> But could you give an objective reason why foreach is "clearer" than ... it couldn't have been in void context. ... There are many Perl ...
    (comp.lang.perl.misc)