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

BEGIN GLOBAL::<name> assignment does not work in Rakudo #3531

Open
p6rt opened this issue Sep 24, 2014 · 4 comments
Open

BEGIN GLOBAL::<name> assignment does not work in Rakudo #3531

p6rt opened this issue Sep 24, 2014 · 4 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Sep 24, 2014

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

Searchable as RT122838$

@p6rt
Copy link
Author

p6rt commented Sep 24, 2014

From @masak

<nine> m​: BEGIN GLOBAL​::<Test> = class { }; Test.new;
<camelia> rakudo-moar 682e03​: OUTPUT«===SORRY!===␤Object of type
<anon> in QAST​::WVal, but not in SC␤»
<masak> nine​: looks like a bug.
<nine> masak​: any idea how I can create a class with a fully qualified
name from an EVAL that's deep in some other namespace?
<nine> masak​: as in Inline​::Perl5​::Perl6PackageCreator​::create runs an
EVAL that should create a class called Foo​::Bar​::Baz.
<lizmat> nine​: EVAL "class Foo​::Bar​::Baz {}" doesn't cut it ?
<lizmat> alternately EVAL "class Foo { class Bar { class Baz {}}}' ?
<lizmat> or actually, maybe both?
<nine> lizmat​: nope, that creates
Inline​::Perl5​::Perl6PackageCreator​::Foo​::Bar​::Baz (what a handy name
;)
<nine> m​: BEGIN GLOBAL​::<Test> := class { }; Test.new;
<camelia> rakudo-moar 682e03​: ( no output )
<nine> ah, := works, while = does not
<jnthn> nine​: Does class GLOBAL​::Foo​::Bar​::Baz { } not do it?
<nine> jnthn​: no, the GLOBAL​:: is pretty much ignored
<jnthn> ah
<jnthn> Maybe that wants fixing
<jnthn> But afer dinner
* masak submits rakudobug
<nine> jnthn​: according to S10, GLOBAL​:: should do it though
<jnthn> nine​: That's my feeling too

@p6rt
Copy link
Author

p6rt commented Dec 3, 2017

From @AlexDaniel

As of today (2017.11,HEAD(e5b660e)) it prints this​:

Cannot call method 'new' on a null object
  in block <unit> at -e line 1

Which is arguably reasonable, but I guess it's not good enough.

On 2014-09-24 04​:03​:12, masak wrote​:

<nine> m​: BEGIN GLOBAL​::<Test> = class { }; Test.new;
<camelia> rakudo-moar 682e03​: OUTPUT«===SORRY!===␤Object of type
<anon> in QAST​::WVal, but not in SC␤»
<masak> nine​: looks like a bug.
<nine> masak​: any idea how I can create a class with a fully qualified
name from an EVAL that's deep in some other namespace?
<nine> masak​: as in Inline​::Perl5​::Perl6PackageCreator​::create runs an
EVAL that should create a class called Foo​::Bar​::Baz.
<lizmat> nine​: EVAL "class Foo​::Bar​::Baz {}" doesn't cut it ?
<lizmat> alternately EVAL "class Foo { class Bar { class Baz {}}}' ?
<lizmat> or actually, maybe both?
<nine> lizmat​: nope, that creates
Inline​::Perl5​::Perl6PackageCreator​::Foo​::Bar​::Baz (what a handy name
;)
<nine> m​: BEGIN GLOBAL​::<Test> := class { }; Test.new;
<camelia> rakudo-moar 682e03​: ( no output )
<nine> ah, := works, while = does not
<jnthn> nine​: Does class GLOBAL​::Foo​::Bar​::Baz { } not do it?
<nine> jnthn​: no, the GLOBAL​:: is pretty much ignored
<jnthn> ah
<jnthn> Maybe that wants fixing
<jnthn> But afer dinner
* masak submits rakudobug
<nine> jnthn​: according to S10, GLOBAL​:: should do it though
<jnthn> nine​: That's my feeling too

@p6rt
Copy link
Author

p6rt commented Dec 3, 2017

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

@p6rt
Copy link
Author

p6rt commented Dec 3, 2017

From @lizmat

If you normally create a class, the entry in GLOBAL​:: is decontainerized​:

$ 6 'class Test {}; use nqp; dd nqp​::iscont(GLOBAL​::<Test>)’
0

However, if you just assign to a key in GLOBAL​::, the result *is* containerized​:

$ 6 'BEGIN GLOBAL​::<Test> = class { }; use nqp; dd nqp​::iscont(GLOBAL​::<Test>)’
1

So maybe you should just bind to the key in GLOBAL​:: ?

$ 6 'BEGIN GLOBAL​::<Test> := class { }; dd Test.new'
<anon|140404516236960>.new

Now, perhaps this can be fixed by having a nqp​::decont() somewhere deep in the bowels for every reference to something in GLOBAL​:: . But I fear that, even if it only a little bit of overhead, it’s overhead we don’t need.

An alternate option would be to create a Stash.ASSIGN-KEY that would not create a container, but instead would bind. But that also feels a bit too magical to me.

So I think we should mark this ticket as “DIHWIDT”, and point to the workaround of binding.

On 3 Dec 2017, at 11​:23, Aleks-Daniel Jakimenko-Aleksejev via RT <perl6-bugs-followup@​perl.org> wrote​:

As of today (2017.11,HEAD(e5b660e)) it prints this​:

Cannot call method 'new' on a null object
in block <unit> at -e line 1

Which is arguably reasonable, but I guess it's not good enough.

On 2014-09-24 04​:03​:12, masak wrote​:

<nine> m​: BEGIN GLOBAL​::<Test> = class { }; Test.new;
<camelia> rakudo-moar 682e03​: OUTPUT«===SORRY!===␤Object of type
<anon> in QAST​::WVal, but not in SC␤»
<masak> nine​: looks like a bug.
<nine> masak​: any idea how I can create a class with a fully qualified
name from an EVAL that's deep in some other namespace?
<nine> masak​: as in Inline​::Perl5​::Perl6PackageCreator​::create runs an
EVAL that should create a class called Foo​::Bar​::Baz.
<lizmat> nine​: EVAL "class Foo​::Bar​::Baz {}" doesn't cut it ?
<lizmat> alternately EVAL "class Foo { class Bar { class Baz {}}}' ?
<lizmat> or actually, maybe both?
<nine> lizmat​: nope, that creates
Inline​::Perl5​::Perl6PackageCreator​::Foo​::Bar​::Baz (what a handy name
;)
<nine> m​: BEGIN GLOBAL​::<Test> := class { }; Test.new;
<camelia> rakudo-moar 682e03​: ( no output )
<nine> ah, := works, while = does not
<jnthn> nine​: Does class GLOBAL​::Foo​::Bar​::Baz { } not do it?
<nine> jnthn​: no, the GLOBAL​:: is pretty much ignored
<jnthn> ah
<jnthn> Maybe that wants fixing
<jnthn> But afer dinner
* masak submits rakudobug
<nine> jnthn​: according to S10, GLOBAL​:: should do it though
<jnthn> nine​: That's my feeling too

@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