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

.wrap on an is export sub doesn't affect it for scopes that already imported it #2608

Open
p6rt opened this issue Jan 10, 2012 · 3 comments
Open
Labels

Comments

@p6rt
Copy link

p6rt commented Jan 10, 2012

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

Searchable as RT107844$

@p6rt
Copy link
Author

p6rt commented Jan 10, 2012

From @masak

<tadzik> about wrap again​: https://gist.github.com/1585730

Included here for completeness​:

┌─[tadzik@​yavin4]─[~/src/perl/bailador] (master)*
└─[%]─> cat lib/Bailador.pm
module Bailador;

our sub our_template {
  return "(our template)"
}

sub exp_template is export {
  return "(exp template)"
}

sub hook is export {
  &our_template.wrap​: { "wrapped {callsame()}" };
  &exp_template.wrap​: { "wrapped {callsame()}" };
}
┌─[tadzik@​yavin4]─[~/src/perl/bailador] (master)*
└─[%]─> cat examples/app.pl
use Bailador;

sub foo {
  say Bailador​::our_template();
  say exp_template();
}

hook();

foo();
┌─[tadzik@​yavin4]─[~/src/perl/bailador] (master)*
└─[%]─> perl6 examples/app.pl
wrapped (our template)
(exp template)

<masak> tadzik​: looks like a bug to me.
<tadzik> S11 uses the word "binding" when it comes to exportation,
this looks more like copying
<masak> tadzik​: haven't read what S11 says about it, but binding makes
a lot of sense and copying doesn't.

S11​:137​:

Importing via C<use> binds into the current lexical scope by default

<masak> tadzik​: will you submit a rakudobug, or shall I?
<tadzik> masak​: go on
* masak submits rakudobug

@p6rt
Copy link
Author

p6rt commented Sep 10, 2017

From @smls

On Tue, 10 Jan 2012 02​:16​:07 -0800, masak wrote​:

<tadzik> about wrap again​: https://gist.github.com/1585730

Included here for completeness​:

┌─[tadzik@​yavin4]─[~/src/perl/bailador] (master)*
└─[%]─> cat lib/Bailador.pm
module Bailador;

our sub our_template {
return "(our template)"
}

sub exp_template is export {
return "(exp template)"
}

sub hook is export {
&our_template.wrap​: { "wrapped {callsame()}" };
&exp_template.wrap​: { "wrapped {callsame()}" };
}
┌─[tadzik@​yavin4]─[~/src/perl/bailador] (master)*
└─[%]─> cat examples/app.pl
use Bailador;

sub foo {
say Bailador​::our_template();
say exp_template();
}

hook();

foo();
┌─[tadzik@​yavin4]─[~/src/perl/bailador] (master)*
└─[%]─> perl6 examples/app.pl
wrapped (our template)
(exp template)

This bug is still present in current Rakudo​:

  This is Rakudo version 2017.08-104-g76f1d8970
  built on MoarVM version 2017.08.1-148-g1059eed1
  implementing Perl 6.c.

(Test script now needs s/module/unit module/ to run, but then produces the same result.)

Calling `&exp_template.WHICH` also confirms that the one in the module and the one in the mainline scope are different objects.

@p6rt
Copy link
Author

p6rt commented Sep 10, 2017

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

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant