Ticket #538 (closed bug: invalid)

Opened 13 years ago

Last modified 12 years ago

NQP list initializers

Reported by: bsdz Owned by:
Priority: normal Milestone:
Component: nqp Version: trunk
Severity: medium Keywords:
Cc: pmichaud Language:
Patch status: Platform: all


When a list is declared in NQP with only one element a scalar is created.

i.e, the following nqp script: -


my @my_list := (10);
_dumper(@my_list, 'my_list');

displays: -

"my_list" => 10

when it should show: -

"my_list" => ResizablePMCArray (size:1) [

A workaround is to place a dummy element and shift it. i.e.

my @my_list := ('dummy', 10);
_dumper(@my_list, 'my_list');

Change History

Changed 12 years ago by jkeenan

  • cc pmichaud added


Can you comment on the issues raised in this ticket?

Thank you very much.

Changed 12 years ago by pmichaud

  • status changed from new to closed
  • resolution set to invalid

Short answer: Parens are not used to create lists or arrays in NQP (or Perl 6) -- that's the role of the comma.

In nqp-rx (the new version of NQP), one can force array creation by using square brackets, as in

my @list := [10];

Closing ticket,


Note: See TracTickets for help on using tickets.