RosettaCodeData/Task/Polymorphism/Factor/polymorphism.factor

14 lines
277 B
Factor
Raw Permalink Normal View History

2013-04-10 23:57:08 -07:00
QUALIFIED: io ! there already is print in io
GENERIC: print ( shape -- )
TUPLE: point x y ;
C: <point> point ! shorthand constructor definition
M: point print drop "Point" io:print ;
TUPLE: circle radius x y ;
C: <circle> circle
M: circle print drop "Circle" io:print ;