Inheritance/Single: Difference between revisions
Content deleted Content added
m →{{header|Perl 6}}: modernize |
→OOP Inheritance in TXR Lisp: Use latest OOP. |
||
Line 1,703: | Line 1,703: | ||
<lang txr>(defstruct animal nil |
<lang txr>(defstruct animal nil |
||
name |
name |
||
(get-name |
(:method get-name (me) |
||
⚫ | |||
(lambda (me) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
(speak |
|||
⚫ | |||
⚫ | |||
(defstruct dog animal |
(defstruct dog animal |
||
(:method speak (me : (stream *stdout*)) |
|||
(speak |
|||
( |
(put-line `@{me.(get-name)}: bark!` stream))) |
||
(put-line `@{me.(get-name)}: bark!` stream)))) |
|||
(defstruct cat animal |
(defstruct cat animal |
||
( |
(:method speak (me : (stream *stdout*)) |
||
(put-line `@{me.(get-name)}: meow!` stream))) |
|||
(defstruct lab dog) |
(defstruct lab dog) |