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

Bleadperl 8752206e27 breaks a test in MLEHMANN/Coro-5.25.tar.gz #10841

Closed
p5pRT opened this issue Nov 21, 2010 · 21 comments
Closed

Bleadperl 8752206e27 breaks a test in MLEHMANN/Coro-5.25.tar.gz #10841

p5pRT opened this issue Nov 21, 2010 · 21 comments

Comments

@p5pRT
Copy link

p5pRT commented Nov 21, 2010

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

Searchable as RT79528$

@p5pRT
Copy link
Author

p5pRT commented Nov 21, 2010

From @andk

OMG, this is 27 days late.

Example fail report​:


  http​://www.cpantesters.org/cpan/report/b78773ba-eddc-11df-8f7c-368b0c7e6507

Cutting & pasting from there​:


  Can't locate object method "TIESCALAR" via package "Coro​::Handle​::FH" at /home/sand/.cpan/build/Coro-5.25-XSKMQd/blib/lib/Coro/Handle.pm line 65.
  t/19_handle.t .....
  Dubious, test returned 29 (wstat 7424, 0x1d00)
  Failed 4/4 subtests

git bisect​:


  commit 8752206
  Author​: Father Chrysostomos <sprout@​cpan.org>
  Date​: Sun Oct 24 18​:14​:47 2010 -0700

  [perl #77496] tied gets scalars and globs confused

perl -V​:


  Summary of my perl5 (revision 5 version 13 subversion 6) configuration​:
  Commit id​: 8752206
  Platform​:
  osname=linux, osvers=2.6.32-5-amd64, archname=x86_64-linux-thread-multi-ld
  uname='linux k81 2.6.32-5-amd64 #1 smp sat oct 30 14​:18​:21 utc 2010 x86_64 gnulinux '
  config_args='-Dprefix=/home/src/perl/repoperls/installed-perls/perl/v5.13.6-112-g8752206 -Dinstallusrbinperl=n -Uversiononly -Dusedevel -des -Ui_db -Duseithreads -Duselongdouble'
  hint=recommended, useposix=true, d_sigaction=define
  useithreads=define, usemultiplicity=define
  useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
  use64bitint=define, use64bitall=define, uselongdouble=define
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
  optimize='-O2',
  cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
  ccversion='', gccversion='4.4.5', gccosandvers=''
  intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
  ivtype='long', ivsize=8, nvtype='long double', nvsize=16, Off_t='off_t', lseeksize=8
  alignbytes=16, prototype=define
  Linker and Libraries​:
  ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
  libpth=/usr/local/lib /lib /usr/lib /lib64 /usr/lib64
  libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc -lgdbm_compat
  perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
  libc=/lib/libc-2.11.2.so, so=so, useshrplib=false, libperl=libperl.a
  gnulibc_version='2.11.2'
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
  cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector'

  Characteristics of this binary (from libperl)​:
  Compile-time options​: MULTIPLICITY PERL_DONT_CREATE_GVSV
  PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP PERL_USE_DEVEL
  USE_64_BIT_ALL USE_64_BIT_INT USE_ITHREADS
  USE_LARGE_FILES USE_LONG_DOUBLE USE_PERLIO
  USE_PERL_ATOF USE_REENTRANT_API
  Built under linux
  Compiled at Nov 21 2010 19​:44​:05
  @​INC​:
  /home/src/perl/repoperls/installed-perls/perl/v5.13.6-112-g8752206/lib/site_perl/5.13.6/x86_64-linux-thread-multi-ld
  /home/src/perl/repoperls/installed-perls/perl/v5.13.6-112-g8752206/lib/site_perl/5.13.6
  /home/src/perl/repoperls/installed-perls/perl/v5.13.6-112-g8752206/lib/5.13.6/x86_64-linux-thread-multi-ld
  /home/src/perl/repoperls/installed-perls/perl/v5.13.6-112-g8752206/lib/5.13.6
  .

--
andreas

@p5pRT
Copy link
Author

p5pRT commented Nov 21, 2010

From @cpansprout

On Sun Nov 21 12​:58​:44 2010, andreas.koenig.7os6VVqR@​franz.ak.mind.de wrote​:

OMG, this is 27 days late.

Example fail report​:
--------------------

http&#8203;://www\.cpantesters\.org/cpan/report/b78773ba\-eddc\-11df\-8f7c\-

368b0c7e6507

Cutting & pasting from there​:
-----------------------------

Can't locate object method "TIESCALAR" via package

"Coro​::Handle​::FH" at /home/sand/.cpan/build/Coro-5.25-
XSKMQd/blib/lib/Coro/Handle.pm line 65.
t/19_handle.t .....
Dubious, test returned 29 (wstat 7424, 0x1d00)
Failed 4/4 subtests

See my recent message to ticket #79302.

This would require 27 lines in Coro/Handle.pm to change (everything with
tie or tied).

Maybe those changes to (un)tie(d) should be reverted. What do Jesse
Vincent and Marc Lehmann think?

@p5pRT
Copy link
Author

p5pRT commented Nov 21, 2010

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Nov 22, 2010

From schmorp@schmorp.de

On Sun, Nov 21, 2010 at 01​:17​:28PM -0800, Father Chrysostomos via RT <perlbug-followup@​perl.org> wrote​:

Cutting & pasting from there​:
-----------------------------

Can't locate object method "TIESCALAR" via package

"Coro​::Handle​::FH" at /home/sand/.cpan/build/Coro-5.25-
XSKMQd/blib/lib/Coro/Handle.pm line 65.
t/19_handle.t .....
Dubious, test returned 29 (wstat 7424, 0x1d00)
Failed 4/4 subtests

See my recent message to ticket #79302.

This would require 27 lines in Coro/Handle.pm to change (everything with
tie or tied).

The docs I have didn't seem to indicate what Coro​::Handle does wrong, or
what to change. I actually saw this a while ago and thought it's simply a
perl bug.

27 lines sounds extensive - since this is an incompatible change in perl,
will these 27 lines work in old perls as well?

Maybe those changes to (un)tie(d) should be reverted. What do Jesse
Vincent and Marc Lehmann think?

The code seems to match available documentation. If the code is buggy
I'd be happy to hear about it (and even more about the supposed fix),
otherwise it seems this is simply a perl bug.

--
  The choice of a Deliantra, the free code+content MORPG
  -----==- _GNU_ http​://www.deliantra.net
  ----==-- _ generation
  ---==---(_)__ __ ____ __ Marc Lehmann
  --==---/ / _ \/ // /\ \/ / schmorp@​schmorp.de
  -=====/_/_//_/\_,_/ /_/\_\

@p5pRT
Copy link
Author

p5pRT commented Nov 22, 2010

From @cpansprout

On Sun Nov 21 18​:14​:49 2010, schmorp@​schmorp.de wrote​:

On Sun, Nov 21, 2010 at 01​:17​:28PM -0800, Father Chrysostomos via RT
<perlbug-followup@​perl.org> wrote​:

Cutting & pasting from there​:
-----------------------------

Can't locate object method "TIESCALAR" via package

"Coro​::Handle​::FH" at /home/sand/.cpan/build/Coro-5.25-
XSKMQd/blib/lib/Coro/Handle.pm line 65.
t/19_handle.t .....
Dubious, test returned 29 (wstat 7424, 0x1d00)
Failed 4/4 subtests

See my recent message to ticket #79302.

This would require 27 lines in Coro/Handle.pm to change (everything
with
tie or tied).

The docs I have didn't seem to indicate what Coro​::Handle does wrong,
or
what to change. I actually saw this a while ago and thought it's
simply a
perl bug.

27 lines sounds extensive - since this is an incompatible change in
perl,
will these 27 lines work in old perls as well?

Maybe those changes to (un)tie(d) should be reverted. What do Jesse
Vincent and Marc Lehmann think?

The code seems to match available documentation. If the code is buggy
I'd be happy to hear about it (and even more about the supposed fix),
otherwise it seems this is simply a perl bug.

Sorry, I was not clear enough. If tie $self is changed to tie *$self and
tied ${...} is changed to tied *{...}, it will work in blead and in
older perls.

The problem is that in older perls there is no way to see whether a
scalar is tied if a glob has been assigned to it. I thought that was a
bug, so I ‘fixed’ it.

I’m hoping you will consider it a bug, too.

See perlfunc​:

tied VARIABLE

That’s not very clear, but it sounds to me that whatever variable is
what will be looked at. So tied $foo should see whether $foo is tied,
not *$foo{IO}.

@p5pRT
Copy link
Author

p5pRT commented Nov 22, 2010

From @cpansprout

On Sun Nov 21 18​:38​:20 2010, sprout wrote​:

That’s not very clear, but it sounds to me that whatever variable is
what will be looked at.

whatever variable is *named* is what will be looked at.

@p5pRT
Copy link
Author

p5pRT commented Nov 22, 2010

From schmorp@schmorp.de

On Sun, Nov 21, 2010 at 06​:38​:20PM -0800, Father Chrysostomos via RT <perlbug-followup@​perl.org> wrote​:

Sorry, I was not clear enough. If tie $self is changed to tie *$self and
tied ${...} is changed to tied *{...}, it will work in blead and in
older perls.

The problem is that in older perls there is no way to see whether a
scalar is tied if a glob has been assigned to it. I thought that was a
bug, so I ‘fixed’ it.

I’m hoping you will consider it a bug, too.

Well, whether that is a bug or not doesn't really have anything to do with
the code, as the code doesn't rely on that bug directly.

The important question for me would be how much code breaks, and whether
this change in behaviour warrants a depreciation.

Maybe I am a burned child, but it seems every major perl release breaks
some of my modules (and often even when following documentation), so I'd
appreciate if perl gave more choice and more (not longer) depreciation
periods.

--
  The choice of a Deliantra, the free code+content MORPG
  -----==- _GNU_ http​://www.deliantra.net
  ----==-- _ generation
  ---==---(_)__ __ ____ __ Marc Lehmann
  --==---/ / _ \/ // /\ \/ / schmorp@​schmorp.de
  -=====/_/_//_/\_,_/ /_/\_\

@p5pRT
Copy link
Author

p5pRT commented Nov 22, 2010

From @cpansprout

On Sun Nov 21 18​:50​:56 2010, schmorp@​schmorp.de wrote​:

On Sun, Nov 21, 2010 at 06​:38​:20PM -0800, Father Chrysostomos via RT
<perlbug-followup@​perl.org> wrote​:

Sorry, I was not clear enough. If tie $self is changed to tie *$self
and
tied ${...} is changed to tied *{...}, it will work in blead and in
older perls.

The problem is that in older perls there is no way to see whether a
scalar is tied if a glob has been assigned to it. I thought that was
a
bug, so I ‘fixed’ it.

I’m hoping you will consider it a bug, too.

Well, whether that is a bug or not doesn't really have anything to do
with
the code, as the code doesn't rely on that bug directly.

The important question for me would be how much code breaks, and
whether
this change in behaviour warrants a depreciation.

Maybe I am a burned child, but it seems every major perl release
breaks
some of my modules (and often even when following documentation), so
I'd
appreciate if perl gave more choice and more (not longer) depreciation
periods.

How about I revert it and add a ‘Use of tie on a handle without * is
deprecated’ warning?

@p5pRT
Copy link
Author

p5pRT commented Nov 28, 2010

From @cpansprout

On Sun Nov 21 22​:25​:19 2010, sprout wrote​:

On Sun Nov 21 18​:50​:56 2010, schmorp@​schmorp.de wrote​:

On Sun, Nov 21, 2010 at 06​:38​:20PM -0800, Father Chrysostomos via RT
<perlbug-followup@​perl.org> wrote​:

Sorry, I was not clear enough. If tie $self is changed to tie *$self
and
tied ${...} is changed to tied *{...}, it will work in blead and in
older perls.

The problem is that in older perls there is no way to see whether a
scalar is tied if a glob has been assigned to it. I thought that was
a
bug, so I ‘fixed’ it.

I’m hoping you will consider it a bug, too.

Well, whether that is a bug or not doesn't really have anything to do
with
the code, as the code doesn't rely on that bug directly.

The important question for me would be how much code breaks, and
whether
this change in behaviour warrants a depreciation.

Maybe I am a burned child, but it seems every major perl release
breaks
some of my modules (and often even when following documentation), so
I'd
appreciate if perl gave more choice and more (not longer) depreciation
periods.

How about I revert it and add a ‘Use of tie on a handle without * is
deprecated’ warning?

How about this patch (plus a perldiag entry)? These three commits will
need to be reverted first​:

8307480
9aa8b00
8752206

Since this is a run-time check, I could not make it warn once per op. So
it warns once per GV.

@p5pRT
Copy link
Author

p5pRT commented Nov 28, 2010

From @cpansprout

Inline Patch
diff --git a/gv.h b/gv.h
index c61f2e6..be371f1 100644
--- a/gv.h
+++ b/gv.h
@@ -138,6 +138,9 @@ Return the SV from the GV.
 #define GVf_IMPORTED_HV	  0x40
 #define GVf_IMPORTED_CV	  0x80
 
+/* Temporary flag for the tie deprecation warnings. */
+#define GVf_TIEWARNED	0x100
+
 #define GvINTRO(gv)		(GvFLAGS(gv) & GVf_INTRO)
 #define GvINTRO_on(gv)		(GvFLAGS(gv) |= GVf_INTRO)
 #define GvINTRO_off(gv)		(GvFLAGS(gv) &= ~GVf_INTRO)
diff --git a/pp_sys.c b/pp_sys.c
index e068ec6..d27bde6 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -827,6 +827,10 @@ PP(pp_tie)
 	case SVt_PVGV:
 	case SVt_PVLV:
 	    if (isGV_with_GP(varsv)) {
+		if (SvFAKE(varsv) && !(GvFLAGS(varsv) & GVf_TIEWARNED)) {
+		    deprecate("tie on a handle without *");
+		    GvFLAGS(varsv) |= GVf_TIEWARNED;
+		}
 		methname = "TIEHANDLE";
 		how = PERL_MAGIC_tiedscalar;
 		/* For tied filehandles, we apply tiedscalar magic to the IO
@@ -903,8 +907,14 @@ PP(pp_untie)
     const char how = (SvTYPE(sv) == SVt_PVHV || SvTYPE(sv) == SVt_PVAV)
 		? PERL_MAGIC_tied : PERL_MAGIC_tiedscalar;
 
-    if (isGV_with_GP(sv) && !(sv = MUTABLE_SV(GvIOp(sv))))
+    if (isGV_with_GP(sv)) {
+      if (SvFAKE(sv) && !(GvFLAGS(sv) & GVf_TIEWARNED)) {
+	deprecate("untie on a handle without *");
+	GvFLAGS(sv) |= GVf_TIEWARNED;
+      }
+      if (!(sv = MUTABLE_SV(GvIOp(sv))))
 	RETPUSHYES;
+    }
 
     if ((mg = SvTIED_mg(sv, how))) {
 	SV * const obj = SvRV(SvTIED_obj(sv, mg));
@@ -941,8 +951,14 @@ PP(pp_tied)
     const char how = (SvTYPE(sv) == SVt_PVHV || SvTYPE(sv) == SVt_PVAV)
 		? PERL_MAGIC_tied : PERL_MAGIC_tiedscalar;
 
-    if (isGV_with_GP(sv) && !(sv = MUTABLE_SV(GvIOp(sv))))
+    if (isGV_with_GP(sv)) {
+      if (SvFAKE(sv) && !(GvFLAGS(sv) & GVf_TIEWARNED)) {
+	deprecate("tied on a handle without *");
+	GvFLAGS(sv) |= GVf_TIEWARNED;
+      }
+      if (!(sv = MUTABLE_SV(GvIOp(sv))))
 	RETPUSHUNDEF;
+    }
 
     if ((mg = SvTIED_mg(sv, how))) {
 	SV *osv = SvTIED_obj(sv, mg);
diff --git a/t/op/gmagic.t b/t/op/gmagic.t
index bc8a926..850f50d 100644
--- a/t/op/gmagic.t
+++ b/t/op/gmagic.t
@@ -10,10 +10,11 @@ print "1..24\n";
 
 my $t = 1;
 tie my $c => 'Tie::Monitor';
+my $tied_to;
 
 sub ok {
     my($ok, $got, $exp, $rexp, $wexp) = @_;
-    my($rgot, $wgot) = (tied $c)->init(0);
+    my($rgot, $wgot) = ($tied_to || tied $c)->init(0);
     print $ok ? "ok $t\n" : "# expected $exp, got $got\nnot ok $t\n";
     ++$t;
     if ($rexp == $rgot && $wexp == $wgot) {
@@ -56,9 +57,11 @@ ok_string($s, '0', 1, 1);
 
 # Assignment should not ignore magic when the last thing assigned
 # was a glob
+$tied_to = tied $c;
 $c = *strat;
 $s = $c;
 ok_string $s, *strat, 1, 1;
+$tied_to = undef;
 
 # A plain *foo should not call get-magic on *foo.
 # This method of scalar-tying an immutable glob relies on details of the
diff --git a/t/op/gv.t b/t/op/gv.t
index 862a0cf..e9fde9d 100644
--- a/t/op/gv.t
+++ b/t/op/gv.t
@@ -825,6 +825,7 @@ pass('Can assign strings to typeglobs');
   tie my $a, "thrext";
   () = "$a"; # do a fetch; now $a holds a glob
   eval { *$a = sub{} };
+  eval { $a = undef }; # workaround for untie($handle) bug
   untie $a;
   eval { $a = "bar" };
   ::is $a, "bar",
diff --git a/t/op/tie.t b/t/op/tie.t
index 6e52a6e..b68102e 100644
--- a/t/op/tie.t
+++ b/t/op/tie.t
@@ -939,3 +939,26 @@ sub IO::File::TIEARRAY {
 fileno FOO; tie @a, "FOO"
 EXPECT
 Can't locate object method "TIEARRAY" via package "FOO" at - line 5.
+########
+
+# Deprecation warnings for tie $handle
+
+use warnings 'deprecated';
+$SIG{__WARN__} = sub { $w = shift };
+$handle = *foo;
+eval { tie $handle, "" };
+print $w =~ /^Use of tie on a handle without \* is deprecated/
+  ? "ok tie\n" : "$w\n";
+$handle = *bar;
+tied $handle;
+print $w =~ /^Use of tied on a handle without \* is deprecated/
+  ? "ok tied\n" : "$w\n";
+$handle = *baz;
+untie $handle;
+print $w =~ /^Use of untie on a handle without \* is deprecated/
+  ? "ok untie\n" : "$w\n";
+
+EXPECT
+ok tie
+ok tied
+ok untie

@p5pRT
Copy link
Author

p5pRT commented Nov 29, 2010

From @andk

On Sun, 28 Nov 2010 12​:15​:13 -0800, "Father Chrysostomos via RT" <perlbug-followup@​perl.org> said​:

  > +print $w =~ /^Use of tie on a handle without \* is deprecated/
  > +print $w =~ /^Use of tied on a handle without \* is deprecated/
  > +print $w =~ /^Use of untie on a handle without \* is deprecated/

The problem with any such approach is that it is completely new to me
that the argument to tie must be written with a star sigil. That feels
to me as if somebody would alter perl so that the filehandle argument to
print must always be written with a star sigil.

In the past it was completely idiomatic perl to write

  foo(*STDOUT);

  sub foo {
  my($handle) = @​_;
  tie $handle, ...

So this style is going to be verboten?

I was wondering why only Marc Lehmann and Abe Timmerman have triggered
BBC postings so far on this. I yesterday found the third one, it is
Test​::Base which was shadowed until yesterday because of another BBC.
We'll probably find more when all the currently untestable modules get
patched. But maybe it's just that not many people tie filehandles in
modules?

I don't mind the change if it helps fixing otherwise unfixable bugs but
where are the docs that demand the * sigil on the argument to tie in the
first place?

Or what am I missing?

--
andreas

@p5pRT
Copy link
Author

p5pRT commented Nov 29, 2010

From @Leont

On Mon, Nov 29, 2010 at 10​:51 PM, Andreas J. Koenig
<andreas.koenig.7os6VVqR@​franz.ak.mind.de> wrote​:

The problem with any such approach is that it is completely new to me
that the argument to tie must be written with a star sigil.

It is completely new to me that the argument to tie may be written
without a star sigil for a glob.

That feels
to me as if somebody would alter perl so that the filehandle argument to
print must always be written with a star sigil.

print isn't polymorphic the way tie is, it doesn't need any extra
information to know what to do.

But maybe it's just that not many people tie filehandles in modules?

I have used it one or two modules, but I have always used the sigiled
form. Quickly looking through CPAN I only see modules that do the
same.

I don't mind the change if it helps fixing otherwise unfixable bugs but
where are the docs that demand the * sigil on the argument to tie in the
first place?

Where are the docs that say it is allowed to omit them? When I see
`tie $foo, @​whatever´ I expect it to do call TIESCALAR, not TIEHANDLE
under any circumstances. I personally would consider this a historical
accident and a bug.

Leon

@p5pRT
Copy link
Author

p5pRT commented Nov 29, 2010

From @Tux

On Mon, 29 Nov 2010 23​:47​:22 +0100, Leon Timmermans <fawaka@​gmail.com>
wrote​:

On Mon, Nov 29, 2010 at 10​:51 PM, Andreas J. Koenig
<andreas.koenig.7os6VVqR@​franz.ak.mind.de> wrote​:

The problem with any such approach is that it is completely new to me
that the argument to tie must be written with a star sigil.

It is completely new to me that the argument to tie may be written
without a star sigil for a glob.

That feels to me as if somebody would alter perl so that the filehandle
argument to print must always be written with a star sigil.

print isn't polymorphic the way tie is, it doesn't need any extra
information to know what to do.

But maybe it's just that not many people tie filehandles in modules?

I have used it one or two modules, but I have always used the sigiled
form. Quickly looking through CPAN I only see modules that do the
same.

http​://search.cpan.org/dist/Text-OutputFilter/ is of my hand, ant ties
filehandles. I always use the star-ed form and also documented it that
way.

I don't mind the change if it helps fixing otherwise unfixable bugs but
where are the docs that demand the * sigil on the argument to tie in the
first place?

Where are the docs that say it is allowed to omit them? When I see
`tie $foo, @​whatever´ I expect it to do call TIESCALAR, not TIEHANDLE
under any circumstances. I personally would consider this a historical
accident and a bug.

--
H.Merijn Brand http​://tux.nl Perl Monger http​://amsterdam.pm.org/
using 5.00307 through 5.12 and porting perl5.13.x on HP-UX 10.20, 11.00,
11.11, 11.23 and 11.31, OpenSuSE 10.1, 11.0 .. 11.3 and AIX 5.2 and 5.3.
http​://mirrors.develooper.com/hpux/ http​://www.test-smoke.org/
http​://qa.perl.org http​://www.goldmark.org/jeff/stupid-disclaimers/

@p5pRT
Copy link
Author

p5pRT commented Nov 29, 2010

From @demerphq

On 29 November 2010 23​:47, Leon Timmermans <fawaka@​gmail.com> wrote​:

On Mon, Nov 29, 2010 at 10​:51 PM, Andreas J. Koenig
<andreas.koenig.7os6VVqR@​franz.ak.mind.de> wrote​:

The problem with any such approach is that it is completely new to me
that the argument to tie must be written with a star sigil.

It is completely new to me that the argument to tie may be written
without a star sigil for a glob.

That feels
to me as if somebody would alter perl so that the filehandle argument to
print must always be written with a star sigil.

print isn't polymorphic the way tie is, it doesn't need any extra
information to know what to do.

But maybe it's just that not many people tie filehandles in modules?

I have used it one or two modules, but I have always used the sigiled
form. Quickly looking through CPAN I only see modules that do the
same.

I don't mind the change if it helps fixing otherwise unfixable bugs but
where are the docs that demand the * sigil on the argument to tie in the
first place?

Where are the docs that say it is allowed to omit them? When I see
`tie $foo, @​whatever´ I expect it to do call TIESCALAR, not TIEHANDLE
under any circumstances. I personally would consider this a historical
accident and a bug.

I agree. And perltie clearly shows a * sigil on the tie example for filehandles.

http​://perldoc.perl.org/perltie.html#Tying-FileHandles

<quote>
Here's how to use our little example​:

  1. tie(*FOO,'Shout');
  2. print FOO "hello\n";
  3. $a = 4; $b = 6;
  4. print FOO $a, " plus ", $b, " equals ", $a + $b, "\n";
  5. print <FOO>;
</quote>

yves

--
perl -Mre=debug -e "/just|another|perl|hacker/"

@p5pRT
Copy link
Author

p5pRT commented Nov 30, 2010

From @andk

On Mon, 29 Nov 2010 23​:47​:22 +0100, Leon Timmermans <fawaka@​gmail.com> said​:

  > On Mon, Nov 29, 2010 at 10​:51 PM, Andreas J. Koenig
  > <andreas.koenig.7os6VVqR@​franz.ak.mind.de> wrote​:

The problem with any such approach is that it is completely new to me
that the argument to tie must be written with a star sigil.

  > It is completely new to me that the argument to tie may be written
  > without a star sigil for a glob.

Good to hear different experiences.

That feels
to me as if somebody would alter perl so that the filehandle argument to
print must always be written with a star sigil.

  > print isn't polymorphic the way tie is, it doesn't need any extra
  > information to know what to do.

While I understand the argument I find this isn't documented.

But maybe it's just that not many people tie filehandles in modules?

  > I have used it one or two modules, but I have always used the sigiled
  > form. Quickly looking through CPAN I only see modules that do the
  > same.

Please, just read the ticket. The modules that use it without the star
sigil are

MLEHMANN/Coro-5.25.tar.gz
INGY/Test-Base-0.59.tar.gz
ABELTJE/Test-Smoke-1.44.tar.gz

Not three especially unexperienced people.

I don't mind the change if it helps fixing otherwise unfixable bugs but
where are the docs that demand the * sigil on the argument to tie in the
first place?

  > Where are the docs that say it is allowed to omit them?

The word VARIABLE in documentations does not specify which sigil has to
be attached to the VARIABLE. So at least it leaves room open for
misunderstandings.

  > When I see
  > `tie $foo, @​whatever´ I expect it to do call TIESCALAR, not TIEHANDLE
  > under any circumstances. I personally would consider this a historical
  > accident and a bug.

Fine with me but I still think the documentation ought to make this
clearer.

--
andreas

@p5pRT
Copy link
Author

p5pRT commented Nov 30, 2010

From @demerphq

On 30 November 2010 07​:08, Andreas J. Koenig
<andreas.koenig.7os6VVqR@​franz.ak.mind.de> wrote​:

On Mon, 29 Nov 2010 23​:47​:22 +0100, Leon Timmermans <fawaka@​gmail.com> said​:

 > On Mon, Nov 29, 2010 at 10​:51 PM, Andreas J. Koenig
 > <andreas.koenig.7os6VVqR@​franz.ak.mind.de> wrote​:
 >> The problem with any such approach is that it is completely new to me
 >> that the argument to tie must be written with a star sigil.

 > It is completely new to me that the argument to tie may be written
 > without a star sigil for a glob.

Good to hear different experiences.

 >> That feels
 >> to me as if somebody would alter perl so that the filehandle argument to
 >> print must always be written with a star sigil.

 > print isn't polymorphic the way tie is, it doesn't need any extra
 > information to know what to do.

While I understand the argument I find this isn't documented.

 >> But maybe it's just that not many people tie filehandles in modules?

 > I have used it one or two modules, but I have always used the sigiled
 > form. Quickly looking through CPAN I only see modules that do the
 > same.

Please, just read the ticket. The modules that use it without the star
sigil are

MLEHMANN/Coro-5.25.tar.gz
INGY/Test-Base-0.59.tar.gz
ABELTJE/Test-Smoke-1.44.tar.gz

Not three especially unexperienced people.

No. But ones with a very long history. Maybe this is a hold over of
people that learned their perl on really early versions.

 >> I don't mind the change if it helps fixing otherwise unfixable bugs but
 >> where are the docs that demand the * sigil on the argument to tie in the
 >> first place?

 > Where are the docs that say it is allowed to omit them?

The word VARIABLE in documentations does not specify which sigil has to
be attached to the VARIABLE. So at least it leaves room open for
misunderstandings.

I am not convinced this is a sound argument. Where _else_ do we
mention VARIABLE, and ALSO mention sigils?

 > When I see
 > `tie $foo, @​whatever´ I expect it to do call TIESCALAR, not TIEHANDLE
 > under any circumstances. I personally would consider this a historical
 > accident and a bug.

Fine with me but I still think the documentation ought to make this
clearer.

As I said elsewhere perltie doesnt show any use of tieing a filehandle
without using the * sigil syntax, but does show the opposite.

Sure it should be *better* documented, but I think one *can* argue
that *is* documented.

cheers,
Yves

--
perl -Mre=debug -e "/just|another|perl|hacker/"

@p5pRT
Copy link
Author

p5pRT commented Nov 30, 2010

From @ikegami

On Tue, Nov 30, 2010 at 4​:22 AM, demerphq <demerphq@​gmail.com> wrote​:

Sure it should be *better* documented, but I think one *can* argue
that *is* documented.

Maybe, but not very convincingly. It's not like you can change

tie(*FH, ...)

to

my $fh = FH; # XXX strict error.
tie(*$fh, ...)

someone could naturally assume one has to do one the following, since it's
how it's done elsewhere​:

my $fh = *FH;
tie($fh, ...)

my $fh = \*FH;
tie($fh, ...)

And given that the first currently works...

I'm not saying it shouldn't be changed. I'm saying it's a stretch to say
that tie(*$fh, ...) is documented.

- Eric

@p5pRT
Copy link
Author

p5pRT commented Nov 30, 2010

From @demerphq

On 30 November 2010 20​:49, Eric Brine <ikegami@​adaelis.com> wrote​:

On Tue, Nov 30, 2010 at 4​:22 AM, demerphq <demerphq@​gmail.com> wrote​:

Sure it should be *better* documented, but I think one *can* argue
that *is* documented.

Maybe, but not very convincingly. It's not like you can change

tie(*FH, ...)

to

my $fh = FH;  # XXX strict error.
tie(*$fh, ...)

someone could naturally assume one has to do one the following, since it's
how it's done elsewhere​:

my $fh = *FH;
tie($fh, ...)

Umm... I dont know about that. That would tie the variable $fh to some
package. Not the contents of the variable $fh to some package.

If it works, its an accident.

This is a container/value problem. Tie acts on a container. Not on a
value. In most places in perl you can sort of merge the concepts, as
perl does the right thing normally, but there is a very clear
distinction between a container and its contents.

my $fh = \*FH;
tie($fh, ...)

Again no, this is wrong. for the same reasons i stated above. (And it
doesnt matter if it "works" - arguably it was a bug in the first
place).

And given that the first currently works...

I'm not saying it shouldn't be changed. I'm saying it's a stretch to say
that tie(*$fh, ...) is documented.

Well, in perltie the only tied filehandle is written as

tie *HANDLE, ...

That is, WITH the * sigil.

So, while you might be right in saying that tie(*$fh, ...) is not
explicitly documented, the fact is the that the use of the start sigil
IS documented, and the normal way of dereferencing something in a
scalar is to put the correct sigil in front, so IMO its not that much
of a stretch to say that it is implicitly documented.

Certainly it is better documented than

tie FH, ....;

Of which i can find no example at all.

cheers,
Yves

--
perl -Mre=debug -e "/just|another|perl|hacker/"

@p5pRT
Copy link
Author

p5pRT commented Nov 30, 2010

From @Leont

On Tue, Nov 30, 2010 at 8​:49 PM, Eric Brine <ikegami@​adaelis.com> wrote​:

And given that the first currently works...

I'm not saying it shouldn't be changed. I'm saying it's a stretch to say
that tie(*$fh, ...) is documented.

It's ordinary syntax for a dereference of a globref. That's perfectly
well documented and defined. The real issue is that fake globs aren't
documented. Hell, the only way for me to get proper information on how
they work is using Devel​::Peek.

Leon

@p5pRT
Copy link
Author

p5pRT commented Dec 3, 2010

From @cpansprout

On Sun Nov 28 12​:15​:12 2010, sprout wrote​:

On Sun Nov 21 22​:25​:19 2010, sprout wrote​:

On Sun Nov 21 18​:50​:56 2010, schmorp@​schmorp.de wrote​:

On Sun, Nov 21, 2010 at 06​:38​:20PM -0800, Father Chrysostomos via RT
<perlbug-followup@​perl.org> wrote​:

Sorry, I was not clear enough. If tie $self is changed to tie *$self
and
tied ${...} is changed to tied *{...}, it will work in blead and in
older perls.

The problem is that in older perls there is no way to see whether a
scalar is tied if a glob has been assigned to it. I thought that was
a
bug, so I ‘fixed’ it.

I’m hoping you will consider it a bug, too.

Well, whether that is a bug or not doesn't really have anything to do
with
the code, as the code doesn't rely on that bug directly.

The important question for me would be how much code breaks, and
whether
this change in behaviour warrants a depreciation.

Maybe I am a burned child, but it seems every major perl release
breaks
some of my modules (and often even when following documentation), so
I'd
appreciate if perl gave more choice and more (not longer) depreciation
periods.

How about I revert it and add a ‘Use of tie on a handle without * is
deprecated’ warning?

How about this patch (plus a perldiag entry)? These three commits will
need to be reverted first​:

8307480
9aa8b00
8752206

Since this is a run-time check, I could not make it warn once per op. So
it warns once per GV.

Now done as​:

84b9ac8
7850f4d
b029825
6cd32d3
7c7df81
5609d5f

@p5pRT
Copy link
Author

p5pRT commented Dec 3, 2010

@cpansprout - 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
Development

No branches or pull requests

1 participant