On Sat, Apr 10, 2004 at 09:08:22PM -0400, Stéphane Payrard wrote:
> Hi,
> 
> I am writing a PerlPair PMC and I have a problem with an
> optimization. BTW: probably a modified PerlPair could be used
> to implement lisp cons pairs and the optimization will be even
> more useful because of the widespread use of pairs.
> 
> The optimization: I want to avoid storing a key or or value as a
> PMC but I must know when I am obliged to promote it to a pmc. I
> am obliged to do it when someone takes a reference to it.
> 
> The problem is when someone accesses the key or value as a pmc
> using a get_pmc_keyed_*, I can't know if it is simply to later
> clone it or if it is to keep a reference to it.
> 
> Is this a real shortcoming of the PMC API or am I overlooking
> something?

A way to solve that shortcoming would be to add
get_pmc_keyed_*_clone PMC methods. One would then assume that if
someone uses a non cloning get_pmc_keyed_* method, he does intend to take
a reference to the entity. In that case, if the accessed entity
is not yet a pmc, it has to be promoted to an pmc.

Comments?

--
 stef

> 
> --
>  stef

Reply via email to