On Friday 09 June 2006 17:48, Geoffrey Young wrote:
> Geoffrey Young wrote:
> > I didn't realize there was a difference between this (preferred for eons)
> > syntax and the tied (essentially deprecated, never suggested on list)
> > syntax. that there is a difference constitutes a bug in and of itself.
>
> and just to make sure I wasn't making things up
>
> modperl-docs$ grep -r 'pnotes->{' * |grep -v svn|grep -v dst_html|wc -l
> 4
>
> modperl-docs$ grep -r 'pnotes(' * |grep -v svn|grep -v dst_html|wc -l
> 28
>
> that's mp1 and mp2 docs, and all 4 of those tied references are from the
> documentation explaing the thing we're talking about, so they don't count
> :)
This is said in the description of pnotes:
$hash_ref = $r->pnotes();
...
if no arguments are passed, a hash reference is returned, which can then be
directly accessed without going through the "pnotes()" interface.
Since a hash reference is returned it is clear that it is accessed as
pnotes->{key}.
Btw, this description does not mention a tied hash. Maybe because it is in
fact not tied. It is a normal perl hash only hidden in the C layer.
I think the behavior of $r->pnotes(key=>value) is buggy not because I want
something special. I want it to behave simply like an ordinary perl hash.
Further I really think it is buggy because it leads to very difficult
traceable bugs in applications using it. The docs says:
$r->pnotes(foo => [1..5]);
$val = $r->pnotes("foo");
If this example is changed into:
$var=[1..5];
$r->pnotes(foo => $var);
$var=[’a’..’c’]; # this changes the pnote behind the scene
$val = $r->pnotes("foo");
What would you expect $val to be? [1..5] or [’a’..’c’]?
I think every new programmer and even almost all experienced mod_perl users
would say it is [1..5].
And it would be true if the code is changed to:
$var=[1..5];
$r->pnotes->{foo} = $var;
$var=[’a’..’c’];
$val = $r->pnotes("foo");
Torsten
pgp6HNJRpBu4G.pgp
Description: PGP signature
