March 2014 update

This commit is contained in:
Ingy döt Net 2014-04-02 16:56:35 +00:00
parent 09687c4926
commit a25938f123
1846 changed files with 21876 additions and 5203 deletions

View file

@ -0,0 +1,13 @@
( ( myClass
= (name=aClass)
( Method
= .out$(str$("Output from " !(its.name) ": " !arg))
)
(new=.!arg:?(its.name))
)
& (myClass.Method)$"Example of calling a 'class' method"
& new$(myClass,object1):?MyObject
& (MyObject..Method)$"Example of calling an instance method"
& !MyObject:?Alias
& (Alias..Method)$"Example of calling an instance method from an alias"
);

View file

@ -0,0 +1,7 @@
*> INVOKE
INVOKE FooClass "someMethod" RETURNING bar *> Factory object
INVOKE foo-instance "anotherMethod" RETURNING bar *> Instance object
*> Inline method invocation
MOVE FooClass::"someMethod" TO bar *> Factory object
MOVE foo-instance::"anotherMethod" TO bar *> Instance object

View file

@ -0,0 +1,3 @@
INVOKE foo-instance "FactoryObject" RETURNING foo-factory
*> foo-factory can be treated like a normal object reference.
INVOKE foo-factory "someMethod"

View file

@ -0,0 +1,5 @@
// Static (known in Pascal as class method)
MyClass.method(someParameter);
// Instance
myInstance.method(someParameter);

View file

@ -24,5 +24,4 @@ BEGIN
myInstance := myClass(null);
DBMS_OUTPUT.put_line( myClass.static_method() );
DBMS_OUTPUT.put_line( myInstance.instance_method() );
END;
/
END;/

View file

@ -1,10 +1,9 @@
/** This class implicitly includes a constructor which accepts an Int and
/* This class implicitly includes a constructor which accepts an Int and
* creates "val variable1: Int" with that value.
*/
class MyClass(val variable1: Int) {
var variable2 = "asdf" // Another instance variable; a public var this time
class MyClass(val memberVal: Int) { // Acts like a getter, getter automatically generated.
var variable2 = "asdf" // Another instance variable; a public mutable this time
def this() = this(0) // An auxilliary constructor that instantiates with a default value
def myMethod = variable1 // A getter for variable1, getter of variable1 is auto-created
}
object HelloObject {
@ -13,13 +12,13 @@ object HelloObject {
/** Demonstrate use of our example class.
*/
object Call_an_object_method extends Application {
object Call_an_object_method extends App {
val s = "Hello"
val m = new MyClass()
val m = new MyClass
val n = new MyClass(3)
println(HelloObject.s) // prints "Hello" by object getterHelloObject
println(m.myMethod) // prints 0
println(n.myMethod) // prints 3
assert(HelloObject.s == "Hello") // "Hello" by object getterHelloObject
assert(m.memberVal == 0)
assert(n.memberVal == 3)
println("Successfully completed without error.")
}