Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion building core.ops op_hash at runtime
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Nicholas Clark  
View profile  
 More options Sep 11 2002, 7:48 am
Newsgroups: perl.perl6.internals
From: n...@ccl4.org (Nicholas Clark)
Date: Wed, 11 Sep 2002 12:01:47 +0100
Local: Wed, Sep 11 2002 7:01 am
Subject: Re: [RFC] building core.ops op_hash at runtime

On Wed, Sep 11, 2002 at 12:50:28PM +0200, Leopold Toetsch wrote:
> The op_code() function in op_lib_t does look up an op_info_table entry
> by the op's full_name. To accomplish this, the current implementation
> builds via ops2c.pl basically a static hash table, which get's appended
> to core_ops.c and core_ops_prederef.c.

> My proposal is: build a hash table at runtime on the first invocation of
> op_code() (which parrot doesn't do).
> If no one has objections I'll send a patch.

I like this idea. (but I've no idea of the subtle implications)
Where you thinking of building the hash table in one hit using a linear
parse over the op names the first time a lookup is requested?

An alternative (more complex, may not be worth it) is to perform the hash
construction in a lazy fashion:

Initialise with a flag that says the hash isn't complete, and a pointer at
the start of the linear list.

When somewhere requests a name, look in the hash. If found, good
Once the hash becomes flagged as complete you stop here, returning not found.

Resume the linear search using the pointer. Hash everything you pass by
that isn't what you're looking for.

If you find it, good. hash it too, save the new pointer, return the result.

If you hit the end, flag the hash as complete, return failure.

ex::lib::zip is using this approach to scan the directory of the zip file
its stuffed in @INC on perl (5.8 or later). I don't know if it's faster, but
it feels nicer :-)

Nicholas Clark


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.