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

how to export alias to module function? #5995

Open
p6rt opened this issue Jan 9, 2017 · 4 comments
Open

how to export alias to module function? #5995

p6rt opened this issue Jan 9, 2017 · 4 comments

Comments

@p6rt
Copy link

p6rt commented Jan 9, 2017

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

Searchable as RT130533$

@p6rt
Copy link
Author

p6rt commented Jan 9, 2017

From melezhik@gmail.com

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

@p6rt
Copy link
Author

p6rt commented Jan 10, 2017

From @LLFourn

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-archive.perl.org/perl6/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

@p6rt
Copy link
Author

p6rt commented Jan 10, 2017

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

@p6rt
Copy link
Author

p6rt commented Jan 10, 2017

From melezhik@gmail.com

Hi Lloyd!

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>​:

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-archive.perl.org/perl6/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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant