[perl6/specs] b08407: s/concatenated/appended/
Branch: refs/heads/master Home: https://github.com/perl6/specs Commit: b08407beaae81a63dd7fcbf565dad0fcd44b1b1f https://github.com/perl6/specs/commit/b08407beaae81a63dd7fcbf565dad0fcd44b1b1f Author: Elizabeth Mattijsen Date: 2018-05-22 (Tue, 22 May 2018) Changed paths: M S06-routines.pod Log Message: --- s/concatenated/appended/ Concatenation is generally used for strings only. Seems to me "appending" describes what happens better. **NOTE:** This service been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/ Functionality will be removed from GitHub.com on January 31st, 2019.
Re: What is my sub?
> On 22 May 2018, at 09:41, ToddAndMargo wrote: > > On 05/21/2018 11:21 PM, Siavash wrote: >> https://www.nntp.perl.org/group/perl.perl6.users/2017/03/msg3423.html >> On 2018-05-22 06:04:47 GMT, ToddAndMargo wrote: >>> Hi All, >>> >>> I need to know the name of the subroutine I am in. >>> >>> This is the way I use to do it in Perl 5: >>> >>> (my $Name = (caller(0))[3] ) ~~ s{.*::}{}; >>> >>> How do I do it in Perl 6? FWIW, for the CPAN Butterfly Plan I have made P5caller, a Perl 6 module that attempts to mimic the semantics of P5 caller() as much as possible: http://modules.perl6.org/dist/P5caller:cpan:ELIZABETH Liz
Re: What is my sub?
On 05/22/2018 09:34 AM, Elizabeth Mattijsen wrote: On 22 May 2018, at 09:41, ToddAndMargo wrote: On 05/21/2018 11:21 PM, Siavash wrote: https://www.nntp.perl.org/group/perl.perl6.users/2017/03/msg3423.html On 2018-05-22 06:04:47 GMT, ToddAndMargo wrote: Hi All, I need to know the name of the subroutine I am in. This is the way I use to do it in Perl 5: (my $Name = (caller(0))[3] ) ~~ s{.*::}{}; How do I do it in Perl 6? FWIW, for the CPAN Butterfly Plan I have made P5caller, a Perl 6 module that attempts to mimic the semantics of P5 caller() as much as possible: http://modules.perl6.org/dist/P5caller:cpan:ELIZABETH Liz Thank you!
Re: What is my sub?
On 05/22/2018 09:09 AM, yary wrote: Oh this works too sub my-name-is-Sue () { say "Hi, ", &?ROUTINE.name } my-name-is-Sue; -y Thank you!
Re: What is my sub?
> On 22 May 2018, at 09:41, ToddAndMargo wrote: > > On 05/21/2018 11:21 PM, Siavash wrote: >> https://www.nntp.perl.org/group/perl.perl6.users/2017/03/msg3423.html >> On 2018-05-22 06:04:47 GMT, ToddAndMargo wrote: >>> Hi All, >>> >>> I need to know the name of the subroutine I am in. >>> >>> This is the way I use to do it in Perl 5: >>> >>> (my $Name = (caller(0))[3] ) ~~ s{.*::}{}; >>> >>> How do I do it in Perl 6? FWIW, for the CPAN Butterfly Plan I have made P5caller, a Perl 6 module that attempts to mimic the semantics of P5 caller() as much as possible: http://modules.perl6.org/dist/P5caller:cpan:ELIZABETH Liz
Re: What is my sub?
Oh this works too sub my-name-is-Sue () { say "Hi, ", &?ROUTINE.name } my-name-is-Sue; -y On Tue, May 22, 2018 at 8:59 AM, yary wrote: > I was surprised there isn't a cleaner way to get a sub/method names, and > found https://docs.perl6.org/language/5to6-perlfunc#caller > > Try this tasty morsel > > who-am-i () { say "I'm ", callframe(0).code.name } > who-am-i; > > > -y > > On Tue, May 22, 2018 at 12:41 AM, ToddAndMargo > wrote: > >> On 05/21/2018 11:21 PM, Siavash wrote: >> >>> >>> https://www.nntp.perl.org/group/perl.perl6.users/2017/03/msg3423.html >>> >>> On 2018-05-22 06:04:47 GMT, ToddAndMargo wrote: >>> Hi All, I need to know the name of the subroutine I am in. This is the way I use to do it in Perl 5: (my $Name = (caller(0))[3] ) ~~ s{.*::}{}; How do I do it in Perl 6? Many thanks, -T >>> >> Hi Siavash, >> >> Oh now this is embarrassing. That was me! And I >> have a keeper file on it too. >> >> Wait, why am I wring you again? Is Sparky still >> in the navy? Is Teddy still president? You kids >> get off my lawn !!! I hate when this happens. >> I have a lawn? >> >> :'( >> >> -T >> >> My newly rediscovered notes: >> >> >> Perl 6: >>what is my program's name? >>what is my sub's name? >> >> >> #!/usr/bin/perl6 >> >> sub Test () { >> >>my $f = $?FILE; say " \$\?FILE=<$f>"; >>my $g = $?FILE.IO.basename; say " \$\?FILE.IO.basename=<$g>"; >>( my $IAm = $?FILE ) ~~ s|.*"/"||; say " Regex: \$IAm=<$IAm>\n"; >> >> >># sub Test () { #`(Sub|58588296) ... } >>my $h = &?ROUTINE.gist; >>say " \&\?ROUTINE.gist=<$h>"; >>$h ~~ m/' '(.*?)' '\(/; >>say " Regex: This sub\'s name is <$0>"; >> >>&?ROUTINE.gist ~~ m/' '(.*?)' '\(/; say " A more compact way =<$0>;" >> } >> >> >> Test(); >> >> abc >> >> >> >> #!/usr/bin/env perl6 >> >> sub f() { put &?ROUTINE.gist; }; >> >> sub abc () { >> say "This subroutine's ID is ", f; >> print "\n"; >> >> &?ROUTINE.gist ~~ m/' '(.*?)' '\(/; >> my $SubName = $0; >> say "This subroutine is called $SubName"; >> } >> >> >> >> >> $ WhoTest.pl6 >>$?FILE= >>$?FILE.IO.basename= >>Regex: $IAm= >> >>&?ROUTINE.gist= >>Regex: This sub's name is >> >>A more compact way =; >> >> Gist reference: >> https://docs.perl6.org/routine/gist#class_Mu >> > >
Re: What is my sub?
I was surprised there isn't a cleaner way to get a sub/method names, and found https://docs.perl6.org/language/5to6-perlfunc#caller Try this tasty morsel who-am-i () { say "I'm ", callframe(0).code.name } who-am-i; -y On Tue, May 22, 2018 at 12:41 AM, ToddAndMargo wrote: > On 05/21/2018 11:21 PM, Siavash wrote: > >> >> https://www.nntp.perl.org/group/perl.perl6.users/2017/03/msg3423.html >> >> On 2018-05-22 06:04:47 GMT, ToddAndMargo wrote: >> >>> Hi All, >>> >>> I need to know the name of the subroutine I am in. >>> >>> This is the way I use to do it in Perl 5: >>> >>> (my $Name = (caller(0))[3] ) ~~ s{.*::}{}; >>> >>> How do I do it in Perl 6? >>> >>> Many thanks, >>> -T >>> >> > Hi Siavash, > > Oh now this is embarrassing. That was me! And I > have a keeper file on it too. > > Wait, why am I wring you again? Is Sparky still > in the navy? Is Teddy still president? You kids > get off my lawn !!! I hate when this happens. > I have a lawn? > > :'( > > -T > > My newly rediscovered notes: > > > Perl 6: >what is my program's name? >what is my sub's name? > > > #!/usr/bin/perl6 > > sub Test () { > >my $f = $?FILE; say " \$\?FILE=<$f>"; >my $g = $?FILE.IO.basename; say " \$\?FILE.IO.basename=<$g>"; >( my $IAm = $?FILE ) ~~ s|.*"/"||; say " Regex: \$IAm=<$IAm>\n"; > > ># sub Test () { #`(Sub|58588296) ... } >my $h = &?ROUTINE.gist; >say " \&\?ROUTINE.gist=<$h>"; >$h ~~ m/' '(.*?)' '\(/; >say " Regex: This sub\'s name is <$0>"; > >&?ROUTINE.gist ~~ m/' '(.*?)' '\(/; say " A more compact way =<$0>;" > } > > > Test(); > > abc > > > > #!/usr/bin/env perl6 > > sub f() { put &?ROUTINE.gist; }; > > sub abc () { > say "This subroutine's ID is ", f; > print "\n"; > > &?ROUTINE.gist ~~ m/' '(.*?)' '\(/; > my $SubName = $0; > say "This subroutine is called $SubName"; > } > > > > > $ WhoTest.pl6 >$?FILE= >$?FILE.IO.basename= >Regex: $IAm= > >&?ROUTINE.gist= >Regex: This sub's name is > >A more compact way =; > > Gist reference: > https://docs.perl6.org/routine/gist#class_Mu >
Re: What is my sub?
On 05/21/2018 11:21 PM, Siavash wrote: https://www.nntp.perl.org/group/perl.perl6.users/2017/03/msg3423.html On 2018-05-22 06:04:47 GMT, ToddAndMargo wrote: Hi All, I need to know the name of the subroutine I am in. This is the way I use to do it in Perl 5: (my $Name = (caller(0))[3] ) ~~ s{.*::}{}; How do I do it in Perl 6? Many thanks, -T Hi Siavash, Oh now this is embarrassing. That was me! And I have a keeper file on it too. Wait, why am I wring you again? Is Sparky still in the navy? Is Teddy still president? You kids get off my lawn !!! I hate when this happens. I have a lawn? :'( -T My newly rediscovered notes: Perl 6: what is my program's name? what is my sub's name? #!/usr/bin/perl6 sub Test () { my $f = $?FILE; say " \$\?FILE=<$f>"; my $g = $?FILE.IO.basename; say " \$\?FILE.IO.basename=<$g>"; ( my $IAm = $?FILE ) ~~ s|.*"/"||; say " Regex: \$IAm=<$IAm>\n"; # sub Test () { #`(Sub|58588296) ... } my $h = &?ROUTINE.gist; say " \&\?ROUTINE.gist=<$h>"; $h ~~ m/' '(.*?)' '\(/; say " Regex: This sub\'s name is <$0>"; &?ROUTINE.gist ~~ m/' '(.*?)' '\(/; say " A more compact way =<$0>;" } Test(); abc #!/usr/bin/env perl6 sub f() { put &?ROUTINE.gist; }; sub abc () { say "This subroutine's ID is ", f; print "\n"; &?ROUTINE.gist ~~ m/' '(.*?)' '\(/; my $SubName = $0; say "This subroutine is called $SubName"; } $ WhoTest.pl6 $?FILE= $?FILE.IO.basename= Regex: $IAm= &?ROUTINE.gist= Regex: This sub's name is A more compact way =; Gist reference: https://docs.perl6.org/routine/gist#class_Mu