New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tieing stashes #6983
Comments
From tassilo.parseval@post.rwth-aachen.deCreated by tassilo.parseval@post.rwth-aachen.deI noticed that perl wont stop you from tieing a stash: ethan@ethan:~$ perl5.8.2 -MTie::Hash -MPOSIX=_exit -e 'tie %:: => "Tie::StdHash"; _exit(1)' When a proper shutdown via END happens, a seemingly unrelated message appears: ethan@ethan:~$ perl5.8.2 -MTie::Hash -e 'tie %:: => "Tie::StdHash"' Should these ties make perl croak when they happen? I can't yet see what Also not bad: ethan@ethan:~$ perl5.8.2 -MTie::Hash Tassilo Perl Info
|
From tassilo.parseval@post.rwth-aachen.deOn Fri, Dec 12, 2003 at 07:50:04PM +0000 Tassilo v.Parseval (via RT) wrote:
[...]
[...] Well, in case croaking turns out to be an acceptable solution, the Tassilo PS: Should patch-submitters also modify perldelta.pod accordingly or |
From tassilo.parseval@post.rwth-aachen.deInline Patch--- pp_sys.c~ 2003-10-21 09:01:45.000000000 +0200
+++ pp_sys.c 2003-12-13 09:09:26.000000000 +0100
@@ -787,6 +787,8 @@ PP(pp_tie)
varsv = *++MARK;
switch(SvTYPE(varsv)) {
case SVt_PVHV:
+ if (HvNAME((HV*)varsv))
+ Perl_croak(aTHX_ "Can't tie symbol table of package '%s'", HvNAME((HV*)varsv));
methname = "TIEHASH";
HvEITER((HV *)varsv) = Null(HE *);
break;
--- pod/perldiag.pod~ 2003-12-12 01:02:52.000000000 +0100
+++ pod/perldiag.pod 2003-12-13 09:09:36.000000000 +0100
@@ -1004,6 +1004,12 @@ negative numbers.
negative number. There's a Math::Complex package that comes standard
with Perl, though, if you really want to do that.
+=item Can't tie symbol table of package '%s'
+
+(F) You tried to tie the symbol table of the mentioned package.
+Your script would stop working very soon if perl allowed such an
+operation.
+
=item Can't undef active subroutine
(F) You can't undefine a routine that's currently running. You can, |
From @rgsTassilo von Parseval wrote:
It seems to be good idea, to prevent doing strange things with stashes. (PS - perldelta.pod patches are traditionally not considered necessary.) |
From tassilo.parseval@post.rwth-aachen.deOn Sat, Dec 13, 2003 at 09:58:51AM +0100 Rafael Garcia-Suarez wrote:
The whole stash or just the keys? When I use the lock_hash() routine ethan@ethan:~$ perl5.8.2 -MHash::Util=lock_hash At run-time: Making stashes read-only (or alternatively make the core ignore Tassilo |
From enache@rdslink.roOn Sat, Dec 13, 2003 a.d., Rafael Garcia-Suarez wrote:
Is the only benefit of this preventing bold and/or naive users from doing Regards, |
From @rgsEnache Adrian wrote:
Replace strange by broken if you want. Marking stashes readonly, OTOH, |
From tassilo.parseval@post.rwth-aachen.deOn Sat, Dec 13, 2003 at 12:44:16PM +0000 Adrian Enache via RT wrote:
This goes beyond strange. No matter how hard I try, I can't make a tied The second route seems to be the easier one. As for read-onliness: I don't quite understand how this is going to Tassilo |
From @rgsTassilo von Parseval wrote:
I'd like to understand what kind of scalar cuoldn't be upgraded.
As symbols are stored in stashes like values in regular hashes, I don't |
From enache@rdslink.roOn Sat, Dec 13, 2003 a.d., Tassilo von Parseval wrote:
That message is there since the the tied hash elems were changed to LVs. Regards, |
From tassilo.parseval@post.rwth-aachen.deOn Sat, Dec 13, 2003 at 01:44:17PM +0000 Rafael Garcia-Suarez via RT wrote:
Hmmh, this one: SV = PVLV(0x818c830) at 0x8149a68 I don't understand where it comes from.
The stash can be changed during the runtime of a script. This will then eval 'sub bla { ... }'; So anything that adds something to the hash at runtime (most AUTOLOADers Tassilo |
From @iabynOn Sat, Dec 13, 2003 at 04:56:27PM +0100, Tassilo von Parseval wrote:
That's the tempoary proxy SV used when accessing tied aggregrates (arrays svp = av_fetch(av,3,lval=>1); the only way to make tie work in this environment is for av_fetch() to -- |
From @scottwaltersEnough rope to let typesafety.pm do method overloading on -scott On 0, Rafael Garcia-Suarez <rgarciasuarez@free.fr> wrote:
|
From nick@ing-simmons.netTassilo Parseval <tassilo.parseval@post.rwth-aachen.de> writes:
As the readonly stuff is much closer to the guts of HVs than tie
Seems reasonable message.
Less so.
|
From nick@ing-simmons.netTassilo Parseval <tassilo.parseval@post.rwth-aachen.de> writes:
I can imagine marking at least a sub-stash as READONLY at (say) CHECK
|
From tassilo.parseval@post.rwth-aachen.deOn Sat, Dec 13, 2003 at 07:06:11PM +0000 Dave Mitchell wrote:
Thanks for the explanation. I didn't know any of the above yet. I still Furthermore, we should try to come to a conclusion as to what should Tassilo |
From @lizmatAt 21:02 +0000 12/13/03, Nick Ing-Simmons wrote:
How would that work with e.g. mod_perl? When CHECK and INIT have This is less an issue with read-onlyness (which I like by itself) and Liz |
From nick@ing-simmons.netElizabeth Mattijsen <liz@dijkmat.nl> writes:
It wouldn't - but as you note this is an issue with CHECK rather
|
From @ysthOn Sat, Dec 13, 2003 at 07:06:11PM +0000, Dave Mitchell <davem@fdgroup.com> wrote:
Not good. You can't store a fake glob in a tied hash anymore: $ perl -we'use Tie::Hash; tie %h, "Tie::StdHash"; $h{foo} = *STDOUT; use Devel: |
From rick@bort.caOn Sat, Dec 13, 2003 at 04:17:06PM +0200, Enache Adrian wrote:
Aside from tuits, is there any reason why this couldn't be done now? http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2001-11/msg00203.html which provides an alternative to tie. It doesn't support all the ops -- |
From tassilo.parseval@post.rwth-aachen.deOn Sun, Dec 14, 2003 at 11:27:38PM -0500 Rick Delaney wrote:
This sounds a little like old wine in new containers. As I see it, the What I'd like to see (for tied hashes) is this: EXT MGVTBL_EXTENDED PL_vtbl_tiedhash = { This would also solve the problem of implementing a tied hash in XS Right now this is impossible because the majority of the tied If we are really considering to reimplement the innards of tied hashes Tassilo |
From @lizmatAt 08:28 +0100 12/15/03, Tassilo von Parseval wrote:
What you describe here, is called "Ponie" to a large extent (the way Liz |
From tassilo.parseval@post.rwth-aachen.deOn Mon, Dec 15, 2003 at 08:40:22AM +0100 Elizabeth Mattijsen wrote:
I hope this isn't used as an argument against extending the virtual Just for fun, I am right now adding MGVTBLX to the core. That's going to Tassilo |
From @lizmatAt 09:26 +0100 12/15/03, Tassilo von Parseval wrote:
Yes and no. One the one hand, I wouldn't dream about telling anybody On the other hand, when Ponie comes around, your work may not be Personally, I always try to find solace in the fact that with any Liz |
From @hvdsRafael Garcia-Suarez <rgarciasuarez@free.fr> wrote: I agree: attempting to tie a stash should croak at least until we can Hugo |
From rick@bort.caOn Mon, Dec 15, 2003 at 08:28:23AM +0100, Tassilo von Parseval wrote:
I don't think I suggested Doug's patch would solve any of the recently Anyway, as I see it the bigger problem with tie is not the current
Sure, whatever. I'll ask again:
I ask because I don't know enough about this area of the internals to know -- |
From nick.ing-simmons@elixent.comRick Delaney <rick@bort.ca> writes:
It _is_ being done now. This kind of tidy up is exactly what perl6 is about. Re-doing tie in perl5 another way is I suppose possible, but perl5 needs |
From @iabynOn Sun, Dec 14, 2003 at 01:28:22PM -0800, Yitzchak Scott-Thoennes wrote:
You can get a similar effect without tiedness (but with lvalues): $ perl5.8.0 -wle 'sub f { $_[0] = *STDOUT } my %h; f($h{a})' So should lvlaues be fixed in some way, or was it plain wrong to use LVs -- |
From tassilo.parseval@post.rwth-aachen.deOn Mon, Dec 15, 2003 at 10:31:13AM +0000 hv@crypt.org wrote:
So far all my attempts in finding out how a read-only stash could sub AUTOLOAD { ? Aren't those additions to the stash happening at run-time? Tassilo |
From tassilo.parseval@post.rwth-aachen.deOn Mon, Dec 15, 2003 at 05:51:19PM +0000 Nick Ing-Simmons wrote:
I think a new implementation would only expose those code to All the above however leads us astray. I don't think it's very likely Tassilo |
From @lizmatAt 22:24 +0100 12/15/03, Tassilo von Parseval wrote:
Indeed. That's something you can't do then. The same would Liz |
From @scottwaltersLet me be more clear - if you nice folks make stashes tieable with Again, I've wanted that feature for a while (as do a lot of people) Cheers! On 0, Elizabeth Mattijsen <liz@dijkmat.nl> wrote:
|
From nick.ing-simmons@elixent.comTassilo Parseval <tassilo.parseval@post.rwth-aachen.de> writes:
Well you can count me as arguing that way. Existing XS modules which MGVTBL TkGlue_vtab = { ... } and similar - those need to continue to work.
I quick grep of perltie.pod shows 25 method names not counting =item CLEAR this
|
From nick.ing-simmons@elixent.comTassilo Parseval <tassilo.parseval@post.rwth-aachen.de> writes:
Yes. That is just the kind of thing a readonly stash could be used
|
From nick.ing-simmons@elixent.comTassilo Parseval <tassilo.parseval@post.rwth-aachen.de> writes:
It isn't rare - my guess is that most XS modules that use MAGIC
Which are the ones that XS uses and '~' magic in particular
|
From tassilo.parseval@post.rwth-aachen.deOn Tue, Dec 16, 2003 at 04:22:11PM +0000 Nick Ing-Simmons wrote:
As long as they are not of type PERL_MAGIC_tied, they should. :-) To make it fully backwards-compatible (even with tied variables), it PERL_MAGIC_tied would remain what it is now for those extension that
Oups, forgot FIRSTKEY and NEXTKEY. Not a big deal since so far The other ones that are missing are all methods of a tied handle since I Tassilo |
From tassilo.parseval@post.rwth-aachen.deOn Tue, Dec 16, 2003 at 04:38:24PM +0000 Nick Ing-Simmons wrote:
I don't think we want to disallow anything that works perfectly well. The read-onlyness can already be done now, namely by turning a stash Tassilo |
From @lizmatAt 18:06 +0100 12/16/03, Tassilo von Parseval wrote:
But, as I already tried to point out, CHECK is pretty useless for that. Suppose I'm an author of a CPAN module who wants to make sure that Liz |
From nick.ing-simmons@elixent.comTassilo Parseval <tassilo.parseval@post.rwth-aachen.de> writes:
What I meant is that the MAIN use I can see for a readonly stash is
|
@rspier - Status changed from 'new' to 'open' |
From @doyThe examples given in the original post no longer cause that warning, BEGIN { -doy |
From @rurbanOn Thu, Jul 5, 2012 at 3:03 PM, Jesse Luehrs via RT
1. To tie a stash should either fail (best compile-time), or we need 2. The whole readonly-stash discussion in 2003 was a bit odd. There is just no sanctioned syntax for it. Damian thought of |
From @LeontOn Sun, Jul 8, 2012 at 7:35 PM, Reini Urban <rurban@x-ray.at> wrote:
Right now we don't even have proper read-only hashes IMHO. The Leon |
Migrated from rt.perl.org#24652 (status was 'open')
Searchable as RT24652$
The text was updated successfully, but these errors were encountered: