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

Regex missing from perlref #14922

Closed
p5pRT opened this issue Sep 24, 2015 · 22 comments
Closed

Regex missing from perlref #14922

p5pRT opened this issue Sep 24, 2015 · 22 comments

Comments

@p5pRT
Copy link

p5pRT commented Sep 24, 2015

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

Searchable as RT126150$

@p5pRT
Copy link
Author

p5pRT commented Sep 24, 2015

From perl-diddler@tlinx.org

Created by perl-diddler@tlinx.org

How long has Regex been a type returned by 'ref'?

Shouldn't it be mentioned in 'perlref'?

Note this is in perl-5.22(...perl-5.16.3 and maybe before)...

Perl Info

Flags:
    category=docs
    severity=low

Site configuration information for perl 5.22.0:

Configured by law at Wed Jan 22 12:58:58 PST 2014.

Summary of my perl5 (revision 5 version 22 subversion 3) configuration:
   
  Platform:
    osname=linux, osvers=3.12.0-isht-van, archname=x86_64-linux-thread-multi-ld
    uname='linux ishtar 3.12.0-isht-van #1 smp preempt wed nov 13 16:50:51 pst 2013 x86_64 x86_64 x86_64 gnulinux '
    config_args=''
    hint=previous, 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='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-g -O2',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    ccversion='', gccversion='4.8.1 20130909 [gcc-4_8-branch revision 202388]', 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='gcc', ldflags ='-g -fstack-protector -fPIC'
    libpth=/usr/lib64 /lib64
    libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc -lgdbm_compat
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=/lib/libc-2.18.so, so=so, useshrplib=true, libperl=libperl-5.22.0.so
    gnulibc_version='2.18'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/home/perl/perl-5.22.0/lib/x86_64-linux-thread-multi-ld/CORE'
    cccdlflags='-fPIC', lddlflags='-shared -g -O2 -fstack-protector -fPIC'

Locally applied patches:
    


@INC for perl 5.22.0:
    /home/law/bin/lib
    /home/perl/perl-5.22.0/lib/site/x86_64-linux-thread-multi-ld
    /home/perl/perl-5.22.0/lib/site
    /home/perl/perl-5.22.0/lib/x86_64-linux-thread-multi-ld
    /home/perl/perl-5.22.0/lib
    .


Environment for perl 5.22.0:
    HOME=/home/law
    LANG (unset)
    LANGUAGE (unset)
    LC_COLLATE=C
    LC_CTYPE=en_US.UTF-8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/sbin:.::/home/law/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/opt/kde3/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/usr/sbin:/etc/local/func_lib:/home/law/lib:/home/law/bin/lib
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Sep 24, 2015

From @jkeenan

On Wed Sep 23 17​:05​:51 2015, LAWalsh wrote​:

This is a bug report for perl from perl-diddler@​tlinx.org,
generated with the help of perlbug 1.39 running under perl 5.22.0.

-----------------------------------------------------------------
[Please describe your issue here]

How long has Regex been a type returned by 'ref'?

Shouldn't it be mentioned in 'perlref'?

Note this is in perl-5.22(...perl-5.16.3 and maybe before)...

The ref() built-in function is documented in 'perlfunc'. Calling 'perldoc -f ref' shows (excerpt)​:

#####
=item ref

=for Pod​::Functions find out the type of thing being referenced

Returns a non-empty string if EXPR is a reference, the empty
string otherwise. If EXPR is not specified, C<$_> will be used. The
value returned depends on the type of thing the reference is a reference to.

Builtin types include​:

  SCALAR
  ARRAY
  HASH
  CODE
  REF
  GLOB
  LVALUE
  FORMAT
  IO
  VSTRING
  Regexp
#####

The documentation goes on to say​:

#####
The result C<Regexp> indicates that the argument is a regular expression
resulting from C<qr//>.
#####

$ perl -E '$rx = qr/^\d+$/; say ref($rx);'
Regexp

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Sep 24, 2015

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

@p5pRT
Copy link
Author

p5pRT commented Sep 24, 2015

From perl-diddler@tlinx.org

My question was about whether or not 'Regex' as a builtin type should
be included on the "perlref" manpage...

But for that matter, maybe REF, GLOB, FORMAT, LVALUE
and VSTRING should be mentioned there as well?

I.e. perlref states​:

"This is complete documentation about all aspects of references."

It seems, for it not to mention the types of references returned
for CORE types, by the builtin 'ref', to be a omission from
"complete documentation about all aspects of references".

@p5pRT
Copy link
Author

p5pRT commented Sep 24, 2015

From @rjbs

* Linda Walsh via RT <perlbug-followup@​perl.org> [2015-09-23T21​:11​:02]

My question was about whether or not 'Regex' as a builtin type should
be included on the "perlref" manpage...

But for that matter, maybe REF, GLOB, FORMAT, LVALUE
and VSTRING should be mentioned there as well?

Not to mention REGEXP, distinct from Regexp.

It seems like it could be worthwhile to document these, although for the most
part I think it's an unimportant omission.

--
rjbs

@p5pRT
Copy link
Author

p5pRT commented Sep 24, 2015

From perl-diddler@tlinx.org

On Wed Sep 23 18​:30​:40 2015, perl.p5p@​rjbs.manxome.org wrote​:

Not to mention REGEXP, distinct from Regexp.



???
  I get Regexp returned from a ref qr not REGEXP?? Given that Regexp was the omission I was trying to document, not an all caps version, REGEXP (is that a core type?) it does seem that having the perl documentation purporting to be a complete ref ref, wouldn't be out of place.

It seems like it could be worthwhile to document these,


You mean like someone filing a LOW priority doc bug ??

although for the most
part I think it's an unimportant omission.


  Doublespeak R US eh? Is that a worthwhile unimportant omission, or an unimportant, but worthwhile omission? ;-?

  In my own experience, if something in a project isn't documented, it isn't likely to get fixed, no matter how 'worthwhile' -- *especially* if it is unimportant.

@p5pRT
Copy link
Author

p5pRT commented Sep 24, 2015

From @rjbs

* Linda Walsh via RT <perlbug-followup@​perl.org> [2015-09-23T22​:04​:18]

On Wed Sep 23 18​:30​:40 2015, perl.p5p@​rjbs.manxome.org wrote​:

Not to mention REGEXP, distinct from Regexp.
---
---
???
I get Regexp returned from a ref qr not REGEXP?? Given that Regexp was
the omission I was trying to document, not an all caps version, REGEXP
(is that a core type?) it does seem that having the perl documentation
purporting to be a complete ref ref, wouldn't be out of place.

I was making it clear that both things exist. The qr// construct returns an
reference to an object blessed into the class Regexp. The reference is a
REGEXP type reference. Observe​:

  ~$ perl -MScalar​::Util=blessed,reftype \
  -E 'my $r = qr/x/; say $r; say blessed $r; say reftype $r'
  (?^u​:x)
  Regexp
  REGEXP

--
rjbs

@p5pRT
Copy link
Author

p5pRT commented Sep 24, 2015

From perl-diddler@tlinx.org

On Wed Sep 23 19​:38​:42 2015, perl.p5p@​rjbs.manxome.org wrote​:

~$ perl -MScalar​::Util=blessed,reftype \
-E 'my $r = qr/x/; say $r; say blessed $r; say reftype $r'
(?^u​:x)
Regexp
REGEXP


I was using 'ref' as it is a CORE builtin -- I didn't get into all the values you might get with various extensions. Never heard of REGEXP or a reftype -- seem a bit confusing as you have refs *to* type(s), but have never seen 'ref' return 'REGEXP'.

Is that the name of the internal class that implements regular expressions? I would have thought it was 'Regexp' -- else why would ref return 'Regexp'?

According to Scalar​::Util, reftype should return "the basic Perl type of the variable referenced is returned as a plain string (such as "ARRAY" or "HASH"). Otherwise "undef" is returned."

Is REGEXP documented to be a basic Perl type somewhere? I know I'm not as knowledgeable about perl as you, but I don't know where REGEXP is documented to be a basic type...?

@p5pRT
Copy link
Author

p5pRT commented Sep 24, 2015

From @rjbs

* Linda Walsh via RT <perlbug-followup@​perl.org> [2015-09-23T23​:15​:22]

I was using 'ref' as it is a CORE builtin -- I didn't get into all the values
you might get with various extensions. Never heard of REGEXP or a reftype --
seem a bit confusing as you have refs *to* type(s), but have never seen 'ref'
return 'REGEXP'.

The problem with 'ref' is that it returns​:

  * the stash with which a blessed reference is associated, if a blessed ref
  * the type of the reference, if an unblessed ref
  * undef, otherwise

Unfortunately, the first response hides the second. If you have an arrayref
and a hashref both blessed into the class 'Insane​::Thing' and you need to know
whether to look in $obj->[0] or $obj->{0}, you need to know the underlying
reference's type. That's what reftype tells you. blessed, on the other hand,
only ever returns the stash name for blessed refs, nothing else.

Note that `perldoc -f ref` points out "ref" and "blessed"

Is that the name of the internal class that implements regular expressions?
I would have thought it was 'Regexp' -- else why would ref return 'Regexp'?

Regexp is the package into which qr// objects are blessed. Their underlying
ref type (analagous to an arrayref's ARRAY or hashref's HASH) is REGEXP.

You will "never" see an unblessed REGEXP in normal day to day code.

Is REGEXP documented to be a basic Perl type somewhere? I know I'm not as
knowledgeable about perl as you, but I don't know where REGEXP is documented
to be a basic type...?

Not really. It's documented in perl5120delta, which is a poor answer.
Similarly, REF is not. I'm not sure about VSTRING or a few others.

--
rjbs

@p5pRT
Copy link
Author

p5pRT commented Sep 24, 2015

From perl-diddler@tlinx.org

Ricardo Signes via RT wrote​:

Is REGEXP documented to be a basic Perl type somewhere? I know I'm not as
knowledgeable about perl as you, but I don't know where REGEXP is documented
to be a basic type...?

Not really. It's documented in perl5120delta, which is a poor answer.
Similarly, REF is not. I'm not sure about VSTRING or a few others.


  I find them referenced on the "perlfunc" man page as Builtin-types. Having
used 'ref' a bit, I've run into all of the builtin types, personally, except
maybe FORMAT. FWIW, from the perlfunc manpage under the 'ref' topic.
("Builtin types include​:

  SCALAR
  ARRAY
  HASH
  CODE
  REF
  GLOB
  LVALUE
  FORMAT
  IO
  VSTRING
  Regexp")

I.e. At least I'm acquainted with them by virtue of the standard
perl documentation -- but thought that 'perlref' should be updated
to mention the other types of reference as well -- thus the low
priority doc bug.

Not sure about the rest, but at least with a 'REF', one can usually
dereference it and get something useful (like it being a REF of
one of the above 'built-types').

Thanks for bringing the 'reftype' output to my attention. I would
only have expected its output to be one of the values listed
above (i.e. the unblessed-equiv of what is underlying a blessed-ref).

@p5pRT
Copy link
Author

p5pRT commented Sep 24, 2015

From zefram@fysh.org

Linda Walsh via RT wrote​:

Is REGEXP documented to be a basic Perl type somewhere?

It is a basic Perl type since 5.12, but it's not very documented.
You'll rarely get "REGEXP" out of ref() because core-created REGEXP
values are always blessed into the Regexp class. Scalar​::Util​::reftype()
ignores the blessing, which is why that's the most direct way to see
"REGEXP". You can also see it by copying a REGEXP value, which doesn't
copy the blessing​:

$ perl -lwe 'print ref \(my $z = ${qr/a/})'
REGEXP

-zefram

@p5pRT
Copy link
Author

p5pRT commented Sep 24, 2015

From @rjbs

* Linda Walsh via RT <perlbug-followup@​perl.org> [2015-09-24T00​:07​:41]

I find them referenced on the "perlfunc" man page as Builtin\-types\.
Having used 'ref' a bit\, I've run into all of the builtin types\,
personally\, except

maybe FORMAT.

How about INVLIST? :)

Thanks for bringing the 'reftype' output to my attention. I would
only have expected its output to be one of the values listed
above (i.e. the unblessed-equiv of what is underlying a blessed-ref).

That's just what it is.

--
rjbs

@p5pRT
Copy link
Author

p5pRT commented Sep 24, 2015

From perl-diddler@tlinx.org

James E Keenan via RT wrote​:

The ref() built-in function is documented in 'perlfunc'. Calling 'perldoc -f ref' shows (excerpt)​:

My question was about whether or not 'Regex' as a builtin type should
be included on the "perlref" manpage...

But for that matter, maybe REF, GLOB, FORMAT, LVALUE
and VSTRING should be mentioned there as well?

I.e. perlref states​:

"This is complete documentation about all aspects of references."

It seems, for it not to mention the types of references returned
for CORE types, by the builtin 'ref', to be a omission from
"complete documentation about all aspects of references".

@p5pRT
Copy link
Author

p5pRT commented Sep 24, 2015

From perl-diddler@tlinx.org

Zefram via RT wrote​:

Linda Walsh via RT wrote​:

Is REGEXP documented to be a basic Perl type somewhere?

It is a basic Perl type since 5.12, but it's not very documented.


  Well -- the initial request was for perlref to be updated, but it seems perlfunc ('ref') needs updating as well -- as well as whatever other docs would cover that.

  The docs in 'ref' handled it by equating (for the user-docs, anyway) Regexp with an underlying, non-blessed type like HASH/ARRAY...etc.

But I would gather REGEXP should be the type, while Regexp is the Class that handles it -- which is **fine** with me -- but the documentation is a "bit" (@​5.22, changed in 5.12?) out of date... no?

It's fine that these things grow -- but having the docs >= 10 versions *behind* the binary, could be a bit confusing for people trying to make use of the binary (now I'm seeing some more reasons why I'm still working w/5.16.x...)

*sigh*

@p5pRT
Copy link
Author

p5pRT commented Sep 24, 2015

From [Unknown Contact. See original ticket]

Zefram via RT wrote​:

Linda Walsh via RT wrote​:

Is REGEXP documented to be a basic Perl type somewhere?

It is a basic Perl type since 5.12, but it's not very documented.


  Well -- the initial request was for perlref to be updated, but it seems perlfunc ('ref') needs updating as well -- as well as whatever other docs would cover that.

  The docs in 'ref' handled it by equating (for the user-docs, anyway) Regexp with an underlying, non-blessed type like HASH/ARRAY...etc.

But I would gather REGEXP should be the type, while Regexp is the Class that handles it -- which is **fine** with me -- but the documentation is a "bit" (@​5.22, changed in 5.12?) out of date... no?

It's fine that these things grow -- but having the docs >= 10 versions *behind* the binary, could be a bit confusing for people trying to make use of the binary (now I'm seeing some more reasons why I'm still working w/5.16.x...)

*sigh*

@p5pRT
Copy link
Author

p5pRT commented Dec 15, 2017

From zefram@fysh.org

I have clarified L<perlfunc/ref> in commit
f3c710f, as a result of the tangential
discussion here. However, the request on this ticket is mistaken.
"Regexp" is returned from "ref" for the perfectly regular reason that
it is a class name. L<perlref> has no business listing every class into
which an object might be blessed. This ticket should be closed.

-zefram

@p5pRT p5pRT closed this as completed Dec 15, 2017
@p5pRT
Copy link
Author

p5pRT commented Dec 15, 2017

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

@p5pRT
Copy link
Author

p5pRT commented Dec 17, 2017

From @xsawyerx

On Thu, 14 Dec 2017 23​:06​:54 -0800, zefram@​fysh.org wrote​:

I have clarified L<perlfunc/ref> in commit
f3c710f, as a result of the tangential
discussion here. However, the request on this ticket is mistaken.
"Regexp" is returned from "ref" for the perfectly regular reason that
it is a class name. L<perlref> has no business listing every class into
which an object might be blessed. This ticket should be closed.

In general, I would agree. However, in this particular case, I think there's value in adding it unlike other classes, since this is a first class citizen in the language, which differs from objects you would create with bless or new or would receive from a module.

@p5pRT
Copy link
Author

p5pRT commented Dec 17, 2017

From zefram@fysh.org

Sawyer X via RT wrote​:

since this is a first class citizen in the language,

No it's not. The blessing into "Regexp" is perfectly regular blessing;
anything else can be blessed into "Regexp" just the same, and a regexp
scalar can be blessed into any other class.

-zefram

@p5pRT
Copy link
Author

p5pRT commented Dec 17, 2017

From @xsawyerx

On Sun, 17 Dec 2017 04​:20​:55 -0800, zefram@​fysh.org wrote​:

Sawyer X via RT wrote​:

since this is a first class citizen in the language,

No it's not. The blessing into "Regexp" is perfectly regular blessing;
anything else can be blessed into "Regexp" just the same, and a regexp
scalar can be blessed into any other class.

My intention is that you get a Regexp object via qr(). Since this is a pitfall to many people, there is little harm in adding a particular documentaiton for that.

(As for any possible slipper slope argument, I would be in favor of adding other such cases if there were, but this is luckily the only one.)

@p5pRT
Copy link
Author

p5pRT commented Dec 17, 2017

From @cpansprout

On Sun, 17 Dec 2017 05​:24​:07 -0800, xsawyerx@​cpan.org wrote​:

On Sun, 17 Dec 2017 04​:20​:55 -0800, zefram@​fysh.org wrote​:

Sawyer X via RT wrote​:

since this is a first class citizen in the language,

No it's not. The blessing into "Regexp" is perfectly regular
blessing;
anything else can be blessed into "Regexp" just the same, and a
regexp
scalar can be blessed into any other class.

My intention is that you get a Regexp object via qr(). Since this is a
pitfall to many people, there is little harm in adding a particular
documentaiton for that.

(As for any possible slipper slope argument, I would be in favor of
adding other such cases if there were, but this is luckily the only
one.)

The other one is IO​::File.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Dec 17, 2017

From @cpansprout

On Sun, 17 Dec 2017 12​:12​:56 -0800, sprout wrote​:

On Sun, 17 Dec 2017 05​:24​:07 -0800, xsawyerx@​cpan.org wrote​:

On Sun, 17 Dec 2017 04​:20​:55 -0800, zefram@​fysh.org wrote​:

Sawyer X via RT wrote​:

since this is a first class citizen in the language,

No it's not. The blessing into "Regexp" is perfectly regular
blessing;
anything else can be blessed into "Regexp" just the same, and a
regexp
scalar can be blessed into any other class.

My intention is that you get a Regexp object via qr(). Since this is a
pitfall to many people, there is little harm in adding a particular
documentaiton for that.

(As for any possible slipper slope argument, I would be in favor of
adding other such cases if there were, but this is luckily the only
one.)

The other one is IO​::File.

But I agree, ref(qr//) is quite common, whereas ref(*STDOUT{IO}) is only for gurus.

--

Father Chrysostomos

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