On Mon, 09 Oct 1995 11:46:48 MDT, Tom Christiansen wrote:
>
>> By the way, your new Perl Data Structures manual (or whatever it's called)
>> is VERY HELPFUL.
>
>Glad you like it. I now have both the general tips and the
>lists of lists docs expanded into full form. I encourage feedback,
>although I sure haven't gotten much -- I guess it's all obvious stuff
>to folks on this list.
>
Obvious to us or not, these (esp. the expanded versions of the cookbook) are
real gems. I suspect Randall is gonna have to settle for selling only half
what would have been sold of the Camel-yet-unborn (not even counting the
effects of the pun with the Schwarztian Transforms bit on the popular Perl
populace ;-) I'd even suggest having two sections of each recipe:
THE EASY WAY vs. THE HARD WAY
for $a (@a) { grep map { ..etc..
for $b (@b) { ..etc..
Now, calling which as being easy and which hard is open to a raging debate,
I suppose :-)
It's safe to say I haven't seen manpages that rival Perl's--period.
Here is some stuff that might be mentioned in the recursive data structures
page that's not yet there:
* Perl4-ers might still be tempted to go the typeglob way. Typeglobs are a
polymorphic reference structure that have much magic attached to them
in special cases (eg. filehandles). Typeglobs can also be subverted to
do truly strange things. Use straightforward references in preference
to typeglobs wherever you can.
This both makes it easy to understand what's going on and avoids some
mysteries of typeglob handling. (When the concept of references and
lexical scoping has been uniformly extended to FORMATs, FILEHANDLEs and
the rest of the types, maybe we won't need to use typeglobs at all).
* We usually need more than one statement to construct a self-referential
structure. i.e.,
$b = { a => { b => $b }}; # not legal
will have to be written as:
$b = { a => {} };
$b->{b} = $b;
* Not directly relevant to recursive data structs, but $a = $a->{b} will
cause a coredump in 5.001m without the patches.
Other general comments (more in the nature of traps) that can be mentioned
in appropriate places:
* Hashes-of-Hashes are humungous memory hogs (well, at least for
now). Unless its is a small application, using list of lists is to be
preferred. Never use HoH-es in objects that might get instantiated in
the 1000s. In fact, converting a hash-based class implementation to a
array-based one is a useful optimization with current Perl, and this
will also save on all those duplicate literal keys (duh) in them hashes.
* 'my($a) ; $a->[0] = 1;' does not work yet. The lexical has to pre-defined
like in 'my($a) = ""; $a->[0] = 1;'.
* The precedence of indirect object syntax just doesn't mix with the
dereferencing of data structures. Guess what this is:
meth $a->{foo} # calls meth($a) and derefs result: (meth($a))->{foo}
If you are predisposed to using indirect object syntax, this can be a
really hard one to trace, because it does not produce a warning (yet).
I think there may be more, but those are the ones that have bitten me.
Keep up the amazing work on c.l.p.m, Tom.
- Sarathy.
gsar@engin.umich.edu
>
>> By the way, your new Perl Data Structures manual (or whatever it's called)
>> is VERY HELPFUL.
>
>Glad you like it. I now have both the general tips and the
>lists of lists docs expanded into full form. I encourage feedback,
>although I sure haven't gotten much -- I guess it's all obvious stuff
>to folks on this list.
>
Obvious to us or not, these (esp. the expanded versions of the cookbook) are
real gems. I suspect Randall is gonna have to settle for selling only half
what would have been sold of the Camel-yet-unborn (not even counting the
effects of the pun with the Schwarztian Transforms bit on the popular Perl
populace ;-) I'd even suggest having two sections of each recipe:
THE EASY WAY vs. THE HARD WAY
for $a (@a) { grep map { ..etc..
for $b (@b) { ..etc..
Now, calling which as being easy and which hard is open to a raging debate,
I suppose :-)
It's safe to say I haven't seen manpages that rival Perl's--period.
Here is some stuff that might be mentioned in the recursive data structures
page that's not yet there:
* Perl4-ers might still be tempted to go the typeglob way. Typeglobs are a
polymorphic reference structure that have much magic attached to them
in special cases (eg. filehandles). Typeglobs can also be subverted to
do truly strange things. Use straightforward references in preference
to typeglobs wherever you can.
This both makes it easy to understand what's going on and avoids some
mysteries of typeglob handling. (When the concept of references and
lexical scoping has been uniformly extended to FORMATs, FILEHANDLEs and
the rest of the types, maybe we won't need to use typeglobs at all).
* We usually need more than one statement to construct a self-referential
structure. i.e.,
$b = { a => { b => $b }}; # not legal
will have to be written as:
$b = { a => {} };
$b->{b} = $b;
* Not directly relevant to recursive data structs, but $a = $a->{b} will
cause a coredump in 5.001m without the patches.
Other general comments (more in the nature of traps) that can be mentioned
in appropriate places:
* Hashes-of-Hashes are humungous memory hogs (well, at least for
now). Unless its is a small application, using list of lists is to be
preferred. Never use HoH-es in objects that might get instantiated in
the 1000s. In fact, converting a hash-based class implementation to a
array-based one is a useful optimization with current Perl, and this
will also save on all those duplicate literal keys (duh) in them hashes.
* 'my($a) ; $a->[0] = 1;' does not work yet. The lexical has to pre-defined
like in 'my($a) = ""; $a->[0] = 1;'.
* The precedence of indirect object syntax just doesn't mix with the
dereferencing of data structures. Guess what this is:
meth $a->{foo} # calls meth($a) and derefs result: (meth($a))->{foo}
If you are predisposed to using indirect object syntax, this can be a
really hard one to trace, because it does not produce a warning (yet).
I think there may be more, but those are the ones that have bitten me.
Keep up the amazing work on c.l.p.m, Tom.
- Sarathy.
gsar@engin.umich.edu