Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
14
Task/Inheritance-Single/AmigaE/inheritance-single.amiga
Normal file
14
Task/Inheritance-Single/AmigaE/inheritance-single.amiga
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
OBJECT animal
|
||||
ENDOBJECT
|
||||
|
||||
OBJECT dog OF animal
|
||||
ENDOBJECT
|
||||
|
||||
OBJECT cat OF animal
|
||||
ENDOBJECT
|
||||
|
||||
OBJECT lab OF dog
|
||||
ENDOBJECT
|
||||
|
||||
OBJECT collie OF dog
|
||||
ENDOBJECT
|
||||
7
Task/Inheritance-Single/Forth/inheritance-single-2.fth
Normal file
7
Task/Inheritance-Single/Forth/inheritance-single-2.fth
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
include FMS-SI.f
|
||||
|
||||
:class Animal ;class
|
||||
:class Dog <super Animal ;class
|
||||
:class Cat <super Animal ;class
|
||||
:class Lab <super Dog ;class
|
||||
:class Collie <super Dog ;class
|
||||
13
Task/Inheritance-Single/Neko/inheritance-single.neko
Normal file
13
Task/Inheritance-Single/Neko/inheritance-single.neko
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
var Animal = $new(null);
|
||||
|
||||
var Dog = $new(null);
|
||||
$objsetproto(Dog, Animal);
|
||||
|
||||
var Cat = $new(null);
|
||||
$objsetproto(Cat, Animal);
|
||||
|
||||
var Lab = $new(null);
|
||||
$objsetproto(Lab, Dog);
|
||||
|
||||
var Collie = $new(null);
|
||||
$objsetproto(Collie, Dog);
|
||||
|
|
@ -4,5 +4,5 @@ class Cat is Animal {}
|
|||
class Lab is Dog {}
|
||||
class Collie is Dog {}
|
||||
|
||||
say ~Collie.^parents; # undefined type object
|
||||
say ~Collie.new.^parents; # instantiated object
|
||||
say Collie.^parents; # undefined type object
|
||||
say Collie.new.^parents; # instantiated object
|
||||
|
|
|
|||
1
Task/Inheritance-Single/Self/inheritance-single-1.self
Normal file
1
Task/Inheritance-Single/Self/inheritance-single-1.self
Normal file
|
|
@ -0,0 +1 @@
|
|||
animal = ()
|
||||
1
Task/Inheritance-Single/Self/inheritance-single-2.self
Normal file
1
Task/Inheritance-Single/Self/inheritance-single-2.self
Normal file
|
|
@ -0,0 +1 @@
|
|||
dog = (| parent* = animal |)
|
||||
1
Task/Inheritance-Single/Self/inheritance-single-3.self
Normal file
1
Task/Inheritance-Single/Self/inheritance-single-3.self
Normal file
|
|
@ -0,0 +1 @@
|
|||
cat = (| parent* = animal |)
|
||||
1
Task/Inheritance-Single/Self/inheritance-single-4.self
Normal file
1
Task/Inheritance-Single/Self/inheritance-single-4.self
Normal file
|
|
@ -0,0 +1 @@
|
|||
lab = (| parent* = dog |)
|
||||
1
Task/Inheritance-Single/Self/inheritance-single-5.self
Normal file
1
Task/Inheritance-Single/Self/inheritance-single-5.self
Normal file
|
|
@ -0,0 +1 @@
|
|||
collie = (| parent* = dog |)
|
||||
23
Task/Inheritance-Single/TXR/inheritance-single-3.txr
Normal file
23
Task/Inheritance-Single/TXR/inheritance-single-3.txr
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
(defstruct animal nil
|
||||
name
|
||||
(:method get-name (me)
|
||||
(if me.name me.name (error `get-name: animal @me has no name`)))
|
||||
(:method speak (me stream)
|
||||
(error "abstract animal cannot speak")))
|
||||
|
||||
(defstruct dog animal
|
||||
(:method speak (me : (stream *stdout*))
|
||||
(put-line `@{me.(get-name)}: bark!` stream)))
|
||||
|
||||
(defstruct cat animal
|
||||
(:method speak (me : (stream *stdout*))
|
||||
(put-line `@{me.(get-name)}: meow!` stream)))
|
||||
|
||||
(defstruct lab dog)
|
||||
|
||||
(defstruct collie dog)
|
||||
|
||||
(let ((pet1 (new collie name "Lassie"))
|
||||
(pet2 (new cat name "Max")))
|
||||
pet1.(speak)
|
||||
pet2.(speak))
|
||||
Loading…
Add table
Add a link
Reference in a new issue