Mmmh. You can devise manifold "language query" mechanisms ...
How do I find objects based on a slot value in XoTCL?
Class Person -slots {
Attribute first_name
Attribute last_name
Attribute jobs -multivalued true
Attribute tasks -multivalued true
}Person instforward expr -objscope ::expr
Person proc @ {attribute {operator eq} value} {
if {[my info slots $attribute] eq ""} return;
set results [list]
foreach i [my info instances -closure] {
if {[$i exists $attribute]} {
if {[expr "\"[$i $attribute]\" $operator \"$value\""]} {
lappend results $i
}
}
}
return $results
}
Person new -first_name Malte -last_name Sussdorff
Person new -first_name Gustaf -last_name Neumann
Person new -first_name Stefan -last_name Sobernig
Person new -first_name Gustaf -last_name "von Neumann"
puts [Person @ first_name eq Gustaf]
And more specifically, how do I find all multivalued slots of a class?
set multivalued_slots [list]
foreach s [Person info slots] {
if {[$s multivalued]} {
lappend multivalued_slots $s
}
}
puts $multivalued_slots
And how do I get a list of identifiers (not names, but IDs which are again a slot of the slot) for those multivalued slots?
I don't quite get what you want to achieve here, maybe it is answered above ...