develooper Front page | perl.perl5.porters | Postings from February 2004

Re: [possible PATCH] (was: Returning a typeglob from FETCH a tied hash - broken as of 5.8.1)

Thread Previous | Thread Next
From:
Tassilo von Parseval
Date:
February 10, 2004 13:06
Subject:
Re: [possible PATCH] (was: Returning a typeglob from FETCH a tied hash - broken as of 5.8.1)
Message ID:
20040210210640.GB936@ethan
On Tue, Feb 10, 2004 at 08:47:45PM +0100 Rafael Garcia-Suarez wrote:

> Also sprach Tassilo :
> > The attached patch against blead (actually against @22297) should again
> > allow to assign a GLOB to a an element of a tied hash or array. There
> > are several ways of fixing it and I am not sure mine is the best.
> > 
> > Since a SVt_PVLV thing cannot be upgraded to hold a GV, there had to be
> > another way to squeeze the glob into the tied thingy. My patch abuses
> > the PV slot for that. Later, in Perl_magic_setpack where the STORE is
> > triggered, it checks whether the PV slot is non-NULL and whether it
> > contains a GV. The test for a proper GV had to be added since there
> > appear to be cases in which the PV slot holds an HV (and possibly other
> > things; I couldn't find out where these assignments happen). In this
> > case, there was no glob-assignment and the whole scalar can be passed as
> > is to S_magic_methcall.
> 
> Scary. Have you tried to trace what the LvTYPE is ? Have you tried to
> add a new LvTYPE for your hacked GV/PVLV ? This would probably be
> cleaner.

I didn't look at the LvTYPE at all (I suspect it was either 't' or 'T').
Making the distinction by adding a new type would make it less fragile,
maybe 'G' for indicating that there's a glob in the PV slot.

> > This is not a very clean way of doing it. A more thorough approach
> > would be introducing a new type that is large enough to hold the magic
> > plus anything that was assigned. This would have required some
> > significant changes to the core so I took the other route.
> 
> I'd not withdraw this a priori. Do not trade maintainability for thrift :)
> (I don't consider your patch to be applicable as-is.)

No problem. One other reason why I abandonded the idea of a new scalar
type is because on the whole I felt uneasy about it. These perl types
seem to have a strange inheritance hierarchy between each other so I was
afraid of violating some unwritten conventions. I didn't look into it
too closely. If I were to design a new type for a tied element, three
slots (two pointers to SVs and one MG*) would be my spontaneous guess.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About