preparing 0.9 version, rename to crl1.h
[svn/Cll1h/.git] / demos / objects / objects-wiki.c
diff --git a/demos/objects/objects-wiki.c b/demos/objects/objects-wiki.c
deleted file mode 100644 (file)
index 08403cb..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-#include "cll1.h"
-
-/* This is C<<1 rewrite of object polymorphism from
-   http://en.wikipedia.org/wiki/Polymorphism_in_object-oriented_programming
-   
-   Of course there are easier ways to do the same thing... :-) 
-   (G)2008 xChas */
-
-def_interface(Animal,Actions)
-{
- str method(talk) (Animal self);
-};
-
-def_obj(Animal)
-{
- interface(Actions);
- str name;
-};
-
-construct(Animal,Actions) (Animal self, str name)
-{
- self->name = name;
- return self;
-}
-
-/* implementation of methods */
-
-str catTalk(Animal self)
-{
- return "Meow!";
-}
-
-str dogTalk(Animal self)
-{
- return "Arf! Arf!";
-}
-
-/* registration of methods to object interface */
-
-Actions catActions(void)
-{
- Get_mem(this, Actions);
-
- this->talk = catTalk;
- return this;
-}
-
-Actions dogActions(void)
-{
- Get_mem(this, Actions);
-
- this->talk = dogTalk;
- return this;
-}
-
-/* usage of objects inside C<<1 program */
-
-program
-{
- int i;
- Animal animal[3];
- Actions cat = catActions();
- Actions dog = dogActions();
-
- animal[0] = get_obj(Animal, cat, "Missy");
- animal[1] = get_obj(Animal, cat, "Mr. Bojangles");
- animal[2] = get_obj(Animal, dog, "Lassie");
-
- for_range(i, 0, 2)
- {
-  print(animal[i]->name, ":", _(talk, animal[i]));
- }
-
-}
This page took 0.10598 seconds and 4 git commands to generate.