Reading a large data structure

1 view
Skip to first unread message

Amir Karger

unread,
Aug 4, 2005, 8:59:45 AM8/4/05
to parrot
Is there a way to declare an array of, say, 300 strings in PIR other than

arr = 300
arr[0] = "hi"
arr[1] = "there"
arr[2] = "my"
...
arr[298] = "very"
arr[299] = "tired"

Same question with a hash of hashes or whatever.

-Amir

Bernhard Schmalhofer

unread,
Aug 4, 2005, 3:11:21 PM8/4/05
to Amir Karger, parrot
Amir Karger schrieb:

Assigning an integer to the array should do the trick.

.local pmc arr
arr = new ResizablePMCArray
arr = 300

should allocate storage for at least 300 PMCs.
For Hashes I think there is no such allocation strategy.

CU, Bernhard

Leopold Toetsch

unread,
Aug 4, 2005, 4:20:21 PM8/4/05
to Amir Karger, parrot

On Aug 4, 2005, at 14:59, Amir Karger wrote:

>
> Is there a way to declare an array of, say, 300 strings in PIR other
> than
>
> arr = 300
> arr[0] = "hi"
> arr[1] = "there"
> arr[2] = "my"
> ...
> arr[298] = "very"
> arr[299] = "tired"

Read the array entries from a text file?

> -Amir

leo

Leopold Toetsch

unread,
Aug 4, 2005, 6:54:06 PM8/4/05
to Amir Karger, parrot Internals

On Aug 4, 2005, at 22:20, Leopold Toetsch wrote:

>
>
> On Aug 4, 2005, at 14:59, Amir Karger wrote:

>> Is there a way to declare an array of, say, 300 strings in PIR other
>> than

> Read the array entries from a text file?

The more, that it looks like that you are dealing with the string
abbreviation table, which is very likely Z version dependent.

>> -Amir

leo

Amir Karger

unread,
Aug 5, 2005, 12:47:15 PM8/5/05
to

Actually, I haven't gotten that far. I'm thinking of creating a hash of
hashes with information about each opcode (for each version, if I ever
get past z3). So, e.g., if I tell the interpreter which opcodes have
extra label arguments, then the generic translation routine will know
when to read the extra arg. I'm trying to refactor the code to remove
redundancies. But it seems like building the hash of hashes will take a
lot of tedious coding. I'm thinking I might take the list of opcodes
from the Z standard and Perlify it to a long list of Parrot commands to
create the hash of hashes. It sounds like there's no Perlish shortcut
like [[qw(a b c)], [qw(d e f)]] to do this sort of thing.

I have to keep reminding myself that PIR isn't a HLL. But I forget how
convenient syntactic sugar is.

-Amir

Reply all
Reply to author
Forward
0 new messages