Skip to content
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

Pseudohashes confuse tie() #867

Closed
p5pRT opened this issue Nov 18, 1999 · 4 comments
Closed

Pseudohashes confuse tie() #867

p5pRT opened this issue Nov 18, 1999 · 4 comments

Comments

@p5pRT
Copy link

@p5pRT p5pRT commented Nov 18, 1999

Migrated from rt.perl.org#1797 (status was 'resolved')

Searchable as RT1797$

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Nov 18, 1999

From mjtg@cus.cam.ac.uk

gives the appropriate error
  Not a SCALAR reference at -e line 1.

but
  perl -we 'my $x = []; tie %$x, "Junk"'

does something silly
  Can't locate object method "TIEARRAY" via package "Junk" at -e line 1.

Presumably it is being confused by the pseudo-hash logic.

And should tie() on pseudo-hashes Do The Right Thing anyway?

Mike Guy

% ./perl -V
Summary of my perl5 (revision 5.0 version 5 subversion 62) configuration​:
  Platform​:
  osname=sunos, osvers=4.1.3, archname=sun4-sunos
  uname='sunos nmg1.csi. 4.1.3 1 sun4c '
  config_args='-Doptimise=-O -Uusethreads -des'
  hint=previous, useposix=true, d_sigaction=define
  usethreads=undef useperlio=undef d_sfio=undef
  use64bits=undef usemultiplicity=undef
  Compiler​:
  cc='gcc', optimize='-O', gccversion=2.7.2.3
  cppflags='-I/usr/local/include'
  ccflags ='-I/usr/local/include'
  stdchar='unsigned char', d_stdstdio=define, usevfork=true
  intsize=4, longsize=4, ptrsize=4, doublesize=8
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
  alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries​:
  ld='ld', ldflags =' -L/usr/local/lib'
  libpth=/usr/local/lib /lib /usr/lib /usr/ucblib
  libs=-ldbm -ldl -lm -lc -lposix
  libc=/lib/libc.so.1.8, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
  cccdlflags='-fpic', lddlflags='-assert nodefinitions -L/usr/local/lib'

Characteristics of this binary (from libperl)​:
  Locally applied patches​:
  perldoc.temp
  install.w
  Built under sunos
  Compiled at Oct 27 1999 01​:31​:39
  @​INC​:
  /home/mjtg/perl5.005_62a/lib
  /home/mjtg/perl5.005_62a/lib
  /home/mjtg/perl5.005_62a/lib/site_perl
  .

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Nov 18, 1999

From [Unknown Contact. See original ticket]

M . J . T . Guy <mjtg@​cus.cam.ac.uk> writes​:

Presumably it is being confused by the pseudo-hash logic.

And should tie() on pseudo-hashes Do The Right Thing anyway?

Treating a tied ARRAY as a hash should trigger the pseudo hash code.
(I gave this a passing thought when doing TIEARRAY fixes.)

Likewise a tied HASH should be usable as the index hash.
Now whether either _works_ is a different story - anyone want to
write a t/*.t type testcase?

--
Nick Ing-Simmons

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Nov 19, 1999

From [Unknown Contact. See original ticket]

Nick Ing-Simmons <nick@​ing-simmons.net> wrote

Treating a tied ARRAY as a hash should trigger the pseudo hash code.
(I gave this a passing thought when doing TIEARRAY fixes.)

But that doesn't work, as my original example showed. The problem is
that TIEARRAY gets called instead of TIEHASH.

What I presume is happening, without having done much research, is that
when you do

  tie %$avhv, ...

the % dereference correctly understands about the pseudo-hash case,
and stacks the AV instead of an HV. But it leaves no indication
that this reference should "really" be thought of as a hash. So
the tie code just tests the reference type and calls TIEARRAY.

Likewise a tied HASH should be usable as the index hash.
Now whether either _works_ is a different story - anyone want to
write a t/*.t type testcase?

The latter already has a test case in t/op/avhv.t, presumably by yours
truly. I only discovered this after writing my own test. :-(

Mike Guy

@p5pRT
Copy link
Author

@p5pRT p5pRT commented May 9, 2003

@cwest - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant