Skip Menu |
Report information
Id: 130533
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: melezhik [at] gmail.com
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



To: rakudobug [...] perl.org
Date: Mon, 9 Jan 2017 15:54:56 +0300
From: Alexey Melezhik <melezhik [...] gmail.com>
Subject: how to export alias to module function?
Download (untitled) / with headers
text/plain 992b
HI! Probably I I miss the syntax, but I am trying to make an alias for exported module function and have this alias exported either. $ cat lib/Foo.pm6 use v6; unit module Foo; sub foo is export { say "hi there" } $ perl6 -Ilib -e 'use Foo; foo()' hi there /// $ cat lib/Foo.pm6 use v6; unit module Foo; sub foo is export { say "hi there" } constant &foo-alias = &foo; perl6 -Ilib -e 'use Foo; Foo::foo-alias()' hi there /// But last one does not compile: use v6; unit module Foo; sub foo is export { say "hi there" } constant &foo-alias is export = &foo; $ perl6 -c lib/Foo.pm6 ===SORRY!=== Error while compiling /home/melezhik/projects/tmp/lib/Foo.pm6 Can't use unknown trait 'is export' in a sub declaration. at /home/melezhik/projects/tmp/lib/Foo.pm6:7 expecting any of: rw raw hidden-from-backtrace hidden-from-USAGE pure default DEPRECATED inlinable nodal prec equiv tighter looser assoc leading_docs trailing_docs Regards. Alexey
To: perl6-compiler [...] perl.org, bugs-bitbucket [...] rt.perl.org
Date: Tue, 10 Jan 2017 11:34:30 +0000
From: Lloyd Fournier <lloyd.fourn [...] gmail.com>
Subject: Re: [perl #130533] how to export alias to module function?
Download (untitled) / with headers
text/plain 1.4k
Looks like a bug to me. Seems to be it bugs out if you put "is export" on a constant decl where the RHS is a &sub.

You could do this until it's fixed:

sub foo is export { }
BEGIN EXPORT::DEFAULT::{'&foo-alias'} = &foo;

On Tue, Jan 10, 2017 at 1:21 AM Alexey Melezhik <perl6-bugs-followup@perl.org> wrote:
Show quoted text
# New Ticket Created by  Alexey Melezhik
# Please include the string:  [perl #130533]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=130533 >


HI!

Probably I  I miss the syntax, but I am trying to make an alias for
exported module function and have this alias exported either.

$ cat lib/Foo.pm6
use v6;

unit module Foo;

sub foo is export { say "hi there" }


$ perl6 -Ilib  -e 'use Foo; foo()'
hi there


///

$ cat lib/Foo.pm6
use v6;

unit module Foo;

sub foo is export { say "hi there" }

constant &foo-alias = &foo;

perl6 -Ilib  -e 'use Foo; Foo::foo-alias()'
hi there

///

But last one does not compile:

use v6;

unit module Foo;

sub foo is export { say "hi there" }

constant &foo-alias is export = &foo;


$ perl6  -c lib/Foo.pm6
===SORRY!=== Error while compiling /home/melezhik/projects/tmp/lib/Foo.pm6
Can't use unknown trait 'is export' in a sub declaration.
at /home/melezhik/projects/tmp/lib/Foo.pm6:7
    expecting any of:
        rw raw hidden-from-backtrace hidden-from-USAGE
        pure default DEPRECATED inlinable nodal
        prec equiv tighter looser assoc leading_docs trailing_docs


Regards.

Alexey
Subject: Re: [perl #130533] how to export alias to module function?
From: Alexey Melezhik <melezhik [...] gmail.com>
Date: Tue, 10 Jan 2017 14:46:29 +0300
To: perl6-bugs-followup [...] perl.org
Download (untitled) / with headers
text/plain 1.9k
Hi Lloyd! Show quoted text
> Seems to be it bugs out if you put "is export" on a
constant decl where the RHS is a &sub. Exactly. Meanwhile I just do something like this: sub foo-alias is export { foo } This works for me two. I will be waiting till bug is fixed so to rely on better Perl6 syntax. SO, no hurry. Thanks 2017-01-10 14:35 GMT+03:00 Lloyd Fournier via RT <perl6-bugs-followup@perl.org>: Show quoted text
> Looks like a bug to me. Seems to be it bugs out if you put "is export" on a > constant decl where the RHS is a &sub. > > You could do this until it's fixed: > > sub foo is export { } > BEGIN EXPORT::DEFAULT::{'&foo-alias'} = &foo; > > On Tue, Jan 10, 2017 at 1:21 AM Alexey Melezhik < > perl6-bugs-followup@perl.org> wrote: > > # New Ticket Created by Alexey Melezhik > # Please include the string: [perl #130533] > # in the subject line of all future correspondence about this issue. > # <URL: https://rt.perl.org/Ticket/Display.html?id=130533 > > > > HI! > > Probably I I miss the syntax, but I am trying to make an alias for > exported module function and have this alias exported either. > > $ cat lib/Foo.pm6 > use v6; > > unit module Foo; > > sub foo is export { say "hi there" } > > > $ perl6 -Ilib -e 'use Foo; foo()' > hi there > > > /// > > $ cat lib/Foo.pm6 > use v6; > > unit module Foo; > > sub foo is export { say "hi there" } > > constant &foo-alias = &foo; > > perl6 -Ilib -e 'use Foo; Foo::foo-alias()' > hi there > > /// > > But last one does not compile: > > use v6; > > unit module Foo; > > sub foo is export { say "hi there" } > > constant &foo-alias is export = &foo; > > > $ perl6 -c lib/Foo.pm6 > ===SORRY!=== Error while compiling /home/melezhik/projects/tmp/lib/Foo.pm6 > Can't use unknown trait 'is export' in a sub declaration. > at /home/melezhik/projects/tmp/lib/Foo.pm6:7 > expecting any of: > rw raw hidden-from-backtrace hidden-from-USAGE > pure default DEPRECATED inlinable nodal > prec equiv tighter looser assoc leading_docs trailing_docs > > > Regards. > > Alexey >


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org