Thanks, but I don’t want the name of the kind, I want the kind itself. In the standard rules there are a few phrases which use arguments something like “name of kind of value”, but I can’t get them to work.
The only library phrases that accept naked kinds look like this:
To decide what K is the (name of kind K) produced by (RL - rule producing a value of kind K):
(- ResultOfRule({RL}, 0, false, {-strong-kind:K}) -).
I can’t tell what the “-strong-kind” qualifier is doing there; in my tests it always compiles to 9, no matter what kind is used. In further tests I managed to make the I7 compiler assert, but since I’m misusing an undocumented notation, I’m not surprised.
In any case this sort of phrase requires a second argument – a value whose type involves K in some way. So it’s not what you want.
Aha – it appears that -strong-kind:K generates the I6 constant OBJECT_TY, NUMBER_TY, etc (as appropriate for K). All kinds-of-thing generate 9 because that’s OBJECT_TY.
[ TestSubkind subclass superclass i;
! These classes are outside the kind heirarchy and must be dealt with first
if ( subclass == Class or Object or Routine or String or VPH_Class )
rfalse;
while (1)
{
if ( KindHierarchy–>i == subclass )
return KindHierarchy–>( KindHierarchy–>(i + 1) * 2 ) == superclass;
i = i + 2;
}
];
-).
To repeat with (loopvar - nonexisting K variable) running through the/-- kinds of (kind - name of kind of value of kind K) begin – end:
(- objectloop( {loopvar} && metaclass({loopvar}) == Class && TestSubkind({loopvar}, KindOfObj({-default-value-for:kind})) ) -).
When play begins:
repeat with A running through the kinds of scroll:
say “Kind: [A][line break]”;[/code]
Things I’d like to clean up if possible:
A better way to eliminate non-kind classes than manually listing them all, or some way to find out the number of kinds.
Some way to get access to the class of a kind other than through it’s default value (which necessitates creating an instance of each kind which you want to iterate through.)
Regarding 1 and 2, my earlier reply to Victor somewhat addresses both points, at the cost of introducing dead code. I’m not quite sure if it’s what you want.