.sub 'main' :main
load_bytecode 'dumper.pir'
.local ResizablePMCArray fields
split fields, ",", "hey,you"
_dumper (fields)
.local pmc big
new big, .BigInt
_dumper (big)
set big, "1234567890987654321"
_dumper (big)
unshift fields, big
_dumper (fields)
.end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
./parrot mutate.pir
"VAR1" => ResizableStringArray (size:2) [
"hey",
"you"
]
"VAR1" => PMC 'BigInt' { ... }
"VAR1" => PMC 'BigInt' { ... }
"VAR1" => ResizableStringArray (size:3) [
"1234567890987654321",
"hey",
"you"
]
;;;;;;
what's puzzling is that "big" starts out as a BigInt, but seems to get
transformed into a string when I put it into the array. I wanted that
last dumped value to contain a BigInt followed by two strings, but
instead it's three strings. I would have thought that making my
"fields" variable be a ResizablePMCArray would have sufficed to ensure
that, but as far as I can tell, "fields" gets transformed from a
ResizablePMCArray to a ResizableStringArray after I assign the return
value of "split" from it. What must I do to get what I want?
Thanks
--
ハ ハ
ミ^・^ミ
`~~~´
AFAIK, symbols like fields can't be typed beyond int, num, string, or
pmc. So the ".local" statement above should read:
.local pmc fields
The 'split' opcode always returns a ResizableStringArray.
It might be easier to think of it as
fields = split ",", "hey,you"
(You can actually write it this way -- it's the same thing.)
So, when the BigInt is unshifted into the ResizableStringArray,
it's morphed into a string.
Hope this helps. :-)
Pm