logo       

pmc_type: msg#00542

lang.perl.perl6.internals

Subject: pmc_type

pmc_type is documented and implemented as follows:

/*

=item C<INTVAL
pmc_type(Parrot_Interp interp, STRING *name)>

Returns the PMC type for C<name>.

=cut

*/

INTVAL
pmc_type(Parrot_Interp interp, STRING *name)
{
HashBucket *bucket;
PMC *classname_hash = interp->class_hash;

bucket = hash_get_bucket(interp, PMC_struct_val(classname_hash), name);
if (bucket)
return PMC_int_val((PMC*) bucket->value);
return Parrot_get_datatype_enum(interp, name);

}

On IRC I asked:

17:44 <@Nicholas> can the type returned by Parrot_PMC_typenum for a PMC ever be
zero?
17:45 <@Dan> I don't think so, no
17:46 <@Dan> Take that back -- a PMC of type 'default' can have a type of 0
17:46 <@Dan> But you shouldn't ever have one, as they're not really
instantiatable


In which case:

1: What does pmc_type return if it fails to find a PMC?
2: If that answer is 0, is it safe to document that 0 is a failure return,
which happens to map to the PMC type for "default", but as they can't be
instantiated looking up "default" is "not supported" (or words to that
effect)


Nicholas Clark



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise