This commit is contained in:
Ingy döt Net 2013-04-10 16:57:12 -07:00
parent 518da4a923
commit 764da6cbbb
6144 changed files with 83610 additions and 11 deletions

View file

@ -0,0 +1,7 @@
class Abs {
public:
virtual int method1(double value) = 0;
virtual int add(int a, int b){
return a+b;
}
};

View file

@ -0,0 +1,9 @@
abstract class Class1
{
public abstract void method1();
public int method2()
{
return 0;
}
}

View file

@ -0,0 +1,13 @@
(defgeneric kar (kons)
(:documentation "Return the kar of a kons."))
(defgeneric kdr (kons)
(:documentation "Return the kdr of a kons."))
(defun konsp (object &aux (args (list object)))
"True if there are applicable methods for kar and kdr on object."
(not (or (endp (compute-applicable-methods #'kar args))
(endp (compute-applicable-methods #'kdr args)))))
(deftype kons ()
'(satisfies konsp))

View file

@ -0,0 +1,10 @@
(defmethod kar ((cons cons))
(car cons))
(defmethod kdr ((cons cons))
(cdr cons))
(konsp (cons 1 2)) ; => t
(typep (cons 1 2) 'kons) ; => t
(kar (cons 1 2)) ; => 1
(kdr (cons 1 2)) ; => 2

View file

@ -0,0 +1,11 @@
(defmethod kar ((n integer))
1)
(defmethod kdr ((n integer))
(if (zerop n) nil
(1- n)))
(konsp 45) ; => t
(typep 45 'kons) ; => t
(kar 45) ; => 1
(kdr 45) ; => 44

View file

@ -0,0 +1,27 @@
import std.stdio;
class Foo {
// abstract methods can have an implementation for
// use in super calls.
abstract void foo() {
writeln("Test");
}
}
interface Bar {
void bar();
// Final interface methods are allowed.
final int spam() { return 1; }
}
class Baz : Foo, Bar { // Super class must come first.
override void foo() {
writefln("Meep");
super.foo();
}
void bar() {}
}
void main() {}

View file

@ -0,0 +1,3 @@
TSomeClass = class abstract (TObject)
...
end;

View file

@ -0,0 +1,13 @@
type
TMyObject = class(TObject)
public
procedure AbstractFunction; virtual; abstract; // Your virtual abstract function to overwrite in descendant
procedure ConcreteFunction; virtual; // Concrete function calling the abstract function
end;
implementation
procedure TMyObject.ConcreteFunction;
begin
AbstractFunction; // Calling the abstract function
end;

View file

@ -0,0 +1,3 @@
interface Foo {
to bar(a :int, b :int)
}

View file

@ -0,0 +1,9 @@
interface Foo guards FooStamp {
to bar(a :int, b :int)
}
def x implements FooStamp {
to bar(a :int, b :int) {
return a - b
}
}