home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!doc.ic.ac.uk!uknet!mcsun!sunic!seunet!enea!sommar
- From: sommar@enea.se (Erland Sommarskog)
- Newsgroups: comp.lang.perl
- Subject: TMF
- Message-ID: <1992Nov9.130634.12712@enea.se>
- Date: 9 Nov 92 13:06:34 GMT
- Organization: Enea Data AB
- Lines: 39
-
- When I read the Perl book I said too myself: hey, what a fun
- langauge, it's got too many features. Well, I have never advocated
- minimalism for its own sake, so why not?
-
- Nevertheless here are two things which have bitten me recently,
- which I might be prepared to put on the list of unnecessary features.
-
- 1) Saying &Sub2 means that Sub2 does not get its own copy of @_, which
- means that if called from Sub1, Sub2 gets Sub1's @_. In the case
- Sub2 takes parameters which all can be omitted, this may give un-
- exepected results.
- OK, there are some effeciency reasons for this arrangement, and
- it could probably be functionally useful as well.
- Actually, what confused me was a comment to a code example on
- page 100 in the camel book, which says "pass no list at all--
- more efficient". OK, I thought, one shall not put superfluous ()
- in parameterless call. And, since I do not come from the C or
- Fortran camp, that was the natural thing for me to do anyway.
- So, the suggestion is only that the risk with passing no list at
- all should be highlighted in future editions of the Camel book.
-
- 2) @array returns the number of elements in a scalar context, but
- @array[1,2,3] or @array{'a', 'b', 'c'} returns the last element.
- I haven't found it now, but I dimly recall haveing read something
- of the kind which would explain the result.
- Nevertheless, admit that it's quite confusing, and can lead to
- errors which are difficult find during test. I had:
-
- if (@result{"changed", "new", "deleted"})
-
- As "deleted" was empty, but the others not, I immediately got
- suspicious. But had I put "changed" at the end instead, I might
- not have discovered the error until much later when I thought
- the program to be working.
- I would prefer if scalar on a list, no matter which one, always
- return the number of elements to get consistency, but I suspect
- that it would not be compatible with other people's code, so...
- --
- Erland Sommarskog - ENEA Data, Stockholm - sommar@enea.se
-