sub-hashes don't autovivify. #51

Closed
coke opened this Issue Sep 7, 2012 · 2 comments

Comments

Projects
None yet
3 participants
Contributor

coke commented Sep 7, 2012

$ cat err.pm 
my %hash;
%hash<a><b> := 1;
$ nqp err.pm 
SixModelObject does not implement set_pmc_keyed_str
current instr.: '' pc 72 ((file unknown):48) (err.pm:1)
called from Sub '' pc 29439 (src/stage2/gen/NQPHLL.pir:11153) (src/stage2/gen/NQPHLL.pm:1224)
called from Sub 'eval' pc 29291 (src/stage2/gen/NQPHLL.pir:11092) (src/stage2/gen/NQPHLL.pm:1211)
called from Sub 'evalfiles' pc 31756 (src/stage2/gen/NQPHLL.pir:12102) (src/stage2/gen/NQPHLL.pm:1424)
called from Sub 'command_eval' pc 30711 (src/stage2/gen/NQPHLL.pir:11694) (src/stage2/gen/NQPHLL.pm:1359)
called from Sub 'command_line' pc 30013 (src/stage2/gen/NQPHLL.pir:11433) (src/stage2/gen/NQPHLL.pm:1309)
called from Sub 'MAIN' pc 760 (src/stage2/gen/NQP.pir:250) (src/stage2/gen/NQP.pm:3085)
called from Sub '' pc 443 (src/stage2/gen/NQP.pir:155) (src/stage2/gen/NQP.pm:1475)
Owner

jnthn commented Sep 15, 2012

NQP is a subset of Perl 6. Hash autoviv like this is something that took some effort and complexity to get right in Rakudo, where we are implementing all of Perl 6. While it's convenient, considering how we provide it in Rakudo and not being able to see an easy mapping of it back into NQP, I think it's beyond the scope of NQP to provide this.

@jnthn jnthn closed this Sep 15, 2012

Owner

pmichaud commented Sep 15, 2012

On Sat, Sep 15, 2012 at 01:21:18PM -0700, Jonathan Worthington wrote:

NQP is a subset of Perl 6. Hash autoviv like this is something
that took some effort and complexity to get right in Rakudo,
where we are implementing all of Perl 6. While it's convenient,
considering how we provide it in Rakudo and not being able to
see an easy mapping of it back into NQP, I think it's beyond
the scope of NQP to provide this.

Autoviv is difficult in Perl 6 because of the potential of rw
arguments and dealing with assignment. Since NQP has neither
of these, it ought to be possible to detect at least the simple
lvalue forms for binding and provide autoviv in that situation,
which is by far the most common. Indeed, this is how autoviv
was handled was handled in nqp-rx.

I'm not saying we should provide autoviv; we may still decide
not to do it, but Rakudo has constraints that NQP (and other languages)
won't have. But if we intend NQP to be useful for implementing
languages other than Perl 6, we definitely want a reasonable
autoviv answer, and if we have that, it definitely seems plausible
for NQP itself to have a way to do it.

Pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment