Perl / perl5

šŸŖ The Perl programming language
https://dev.perl.org/perl5/
Other
1.96k stars 555 forks source link

Cannot use refalias with subroutine signatures #15919

Open p5pRT opened 7 years ago

p5pRT commented 7 years ago

Migrated from rt.perl.org#130971 (status was 'open')

Searchable as RT130971$

p5pRT commented 7 years ago

From pm@vrkosk.iki.fi

Created by pm@vrkosk.iki.fi

It would be very nice to be able to use the refalias feature in combination with subroutine signatures. On 5.24.1\, the following is a syntax error​:

  use feature 'refaliasing';   use feature 'signatures';   sub test ($scalar\, \@​array\, \%hash) {   }

The following of course works and has the same intended meaning​:

  use feature 'refaliasing';   sub test {   (my $scalar\, \my @​array\, \my %hash) = @​_;   }

Probably intimately related to refalias + signatures is that the following is also a syntax error​:

  use feature 'refaliasing';   sub test {   my ($scalar\, \@​array\, \%hash) = @​_;   }

Perl Info ``` Flags: category=core severity=wishlist Site configuration information for perl 5.24.1: Configured by villek at Thu Mar 9 10:29:14 GMT 2017. Summary of my perl5 (revision 5 version 24 subversion 1) configuration: Platform: osname=linux, osvers=4.4.49-16-default, archname=x86_64-linux-thread-multi uname='linux t440p-vrk 4.4.49-16-default #1 smp sun feb 19 17:40:35 utc 2017 (70e9954) x86_64 x86_64 x86_64 gnulinux ' config_args='-Dprefix=/home/villek/perldist/perl-5.24.1' hint=recommended, useposix=true, d_sigaction=define useithreads=define, usemultiplicity=define use64bitint=define, use64bitall=define, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2', optimize='-O2', cppflags='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include' ccversion='', gccversion='4.8.5', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678, doublekind=3 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16, longdblkind=3 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='cc', ldflags =' -fstack-protector -L/usr/local/lib' libpth=/usr/local/lib /usr/lib64/gcc/x86_64-suse-linux/4.8/include-fixed /usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/lib /usr/lib /lib/../lib64 /usr/lib/../lib64 /lib /lib64 /usr/lib64 /usr/local/lib64 libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc libc=libc-2.22.so, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='2.22' 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' @INC for perl 5.24.1: /home/villek/perldist/perl-5.24.1/lib/site_perl/5.24.1/x86_64-linux-thread-multi /home/villek/perldist/perl-5.24.1/lib/site_perl/5.24.1 /home/villek/perldist/perl-5.24.1/lib/5.24.1/x86_64-linux-thread-multi /home/villek/perldist/perl-5.24.1/lib/5.24.1 Environment for perl 5.24.1: HOME=/home/villek LANG=de_DE.UTF-8 LANGUAGE (unset) LD_LIBRARY_PATH=/usr/lib64/mpi/gcc/openmpi/lib64 LOGDIR (unset) PATH=/usr/lib64/mpi/gcc/openmpi/bin:/home/villek/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/opt/kde3/bin:/usr/lib/mit/bin PERL_BADLANG (unset) SHELL=/bin/bash ```
p5pRT commented 7 years ago

From @rjbs

I\, too\, would like to see refaliasing via subroutine signatures.

There is or was another ticket related to being able to put the \ on the inside of my declarations. I believe sprout did some work on that front.

-- rjbs

p5pRT commented 7 years ago

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

p5pRT commented 7 years ago

From @cpansprout

On Tue\, 21 Mar 2017 06​:08​:14 -0700\, rjbs wrote​:

I\, too\, would like to see refaliasing via subroutine signatures.

There is or was another ticket related to being able to put the \ on the inside of my declarations. I believe sprout did some work on that front.

In 5.26-to-be\, you can use the ā€˜declared_refsā€™ feature to allow my(\%foo). I honestly donā€™t remember whether I got as far as applying it to signatures. I donā€™t think so. I am too lazy to build blead to find out.

--

Father Chrysostomos

p5pRT commented 7 years ago

From @iabyn

On Tue\, Mar 21\, 2017 at 05​:43​:32PM -0700\, Father Chrysostomos via RT wrote​:

In 5.26-to-be\, you can use the ā€˜declared_refsā€™ feature to allow my(\%foo). I honestly donā€™t remember whether I got as far as applying it to signatures. I donā€™t think so. I am too lazy to build blead to find out.

I suggested holding off\, as I was working on signatures at the time\, and probably wanted to do things a bit differently.

-- I don't want to achieve immortality through my work... I want to achieve it through not dying.   -- Woody Allen

p5pRT commented 7 years ago

From pm@vrkosk.iki.fi

On Wed\, 22 Mar 2017\, at 00​:43\, Father Chrysostomos via RT wrote​:

In 5.26-to-be\, you can use the ā€˜declared_refsā€™ feature to allow my(\%foo). I honestly donā€™t remember whether I got as far as applying it to signatures. I donā€™t think so. I am too lazy to build blead to find out.

Oh\, that's fantastic! If declared_refs doesn't do it for signatures in 5.26\, I don't mind at all waiting for 5.28.

(For years at $work\, I've been documenting function return values using my (\@​foo\, \%bar) and so on. It's very nice to find it will be a real feature.)

Regards\, Ville Koskinen