Anonymous user
Constrained genericity: Difference between revisions
m
→{{header|Forth}}
Line 362:
=={{header|Forth}}==
{{works with|Forth}}
Works with any ANS Forth
Needs the FMS-SI (single inheritance) library code located here:
Line 369:
include FMS-SILib.f
swap >body { where-dfa class-dfa }
▲: (where) { class-xt where-xt -- flag }
begin
class-
while
class-
class-
repeat false ;
: where ( class-xt "classname" -- flag )
' >body state @
if postpone literal postpone (where)
else (where)
Line 401 ⟶ 396:
else ." not an eatable type "
then ;m
:m get ( -- obj ) eatable-types ;m
;class
: test ( obj -- ) \ send the eat message to each object in the object-list
begin dup each:
while eat
Line 410 ⟶ 405:
FoodBox fb
3 ' Eatable fb fill: \ fill the object-list with 3 objects of class Eatable
fb get test
successful eat
|