Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
|
|
@ -0,0 +1,8 @@
|
|||
package My_Class is
|
||||
type Object is tagged private;
|
||||
procedure Primitive(Self: Object); -- primitive subprogram
|
||||
procedure Dynamic(Self: Object'Class);
|
||||
procedure Static;
|
||||
private
|
||||
type Object is tagged null record;
|
||||
end My_Class;
|
||||
18
Task/Call-an-object-method/Ada/call-an-object-method-2.adb
Normal file
18
Task/Call-an-object-method/Ada/call-an-object-method-2.adb
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package body My_Class is
|
||||
procedure Primitive(Self: Object) is
|
||||
begin
|
||||
Put_Line("Hello World!");
|
||||
end Primitive;
|
||||
|
||||
procedure Dynamic(Self: Object'Class) is
|
||||
begin
|
||||
Put("Hi there! ... ");
|
||||
Self.Primitive; -- dispatching call: calls different subprograms,
|
||||
-- depending on the type of Self
|
||||
end Dynamic;
|
||||
|
||||
procedure Static is
|
||||
begin
|
||||
Put_Line("Greetings");
|
||||
end Static;
|
||||
end My_Class;
|
||||
11
Task/Call-an-object-method/Ada/call-an-object-method-3.adb
Normal file
11
Task/Call-an-object-method/Ada/call-an-object-method-3.adb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package Other_Class is
|
||||
type Object is new My_Class.Object with null record;
|
||||
overriding procedure Primitive(Self: Object);
|
||||
end Other_Class;
|
||||
|
||||
package body Other_Class is
|
||||
procedure Primitive(Self: Object) is
|
||||
begin
|
||||
Put_Line("Hello Universe!");
|
||||
end Primitive;
|
||||
end Other_Class;
|
||||
20
Task/Call-an-object-method/Ada/call-an-object-method-4.adb
Normal file
20
Task/Call-an-object-method/Ada/call-an-object-method-4.adb
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
|
||||
procedure Call_Method is
|
||||
|
||||
package My_Class is ... -- see above
|
||||
package body My_Class is ... -- see above
|
||||
|
||||
package Other_Class is ... -- see above
|
||||
package body Other_Class is ... -- see above
|
||||
|
||||
Ob1: My_Class.Object; -- our "root" type
|
||||
Ob2: Other_Class.Object; -- a type derived from the "root" type
|
||||
|
||||
begin
|
||||
My_Class.Static;
|
||||
Ob1.Primitive;
|
||||
Ob2.Primitive;
|
||||
Ob1.Dynamic;
|
||||
Ob2.Dynamic;
|
||||
end Call_Method;
|
||||
11
Task/Call-an-object-method/COBOL/call-an-object-method-1.cob
Normal file
11
Task/Call-an-object-method/COBOL/call-an-object-method-1.cob
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
*> INVOKE statements.
|
||||
INVOKE my-class "some-method" *> Factory object
|
||||
USING BY REFERENCE some-parameter
|
||||
RETURNING foo
|
||||
INVOKE my-instance "another-method" *> Instance object
|
||||
USING BY REFERENCE some-parameter
|
||||
RETURNING foo
|
||||
|
||||
*> Inline method invocation.
|
||||
MOVE my-class::"some-method"(some-parameter) TO foo *> Factory object
|
||||
MOVE my-instance::"another-method"(some-parameter) TO foo *> Instance object
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
INVOKE some-instance "FactoryObject" RETURNING foo-factory
|
||||
*> foo-factory can be treated like a normal object reference.
|
||||
INVOKE foo-factory "someMethod"
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
// Call an object method. Nigel Galloway: April 17th., 2026
|
||||
type myClass(g:string)=
|
||||
let n=g
|
||||
static member whoAreUstat n=printfn "A static member of myClass %s" n
|
||||
member this.whoAreUins=printfn "An instance member of myClass %s" n
|
||||
|
||||
myClass.whoAreUstat "Nigel"
|
||||
(myClass "Nigel").whoAreUins
|
||||
13
Task/Call-an-object-method/Haxe/call-an-object-method.hx
Normal file
13
Task/Call-an-object-method/Haxe/call-an-object-method.hx
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
class ExampleClass {
|
||||
public function exampleMethod() {
|
||||
return "This is a method!";
|
||||
}
|
||||
public function new() {}
|
||||
}
|
||||
|
||||
class Main {
|
||||
static public function main():Void {
|
||||
var exampleObject = new ExampleClass();
|
||||
trace(exampleObject.exampleMethod());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
class myclass
|
||||
static function smethod() print("static method called") end
|
||||
|
||||
function imethod() print("instance method called") end
|
||||
end
|
||||
|
||||
myclass.smethod()
|
||||
local mc = new myclass()
|
||||
mc.imethod()
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
$Date = Get-Date
|
||||
$Date.AddDays( 1 )
|
||||
[System.Math]::Sqrt( 2 )
|
||||
22
Task/Call-an-object-method/Red/call-an-object-method.red
Normal file
22
Task/Call-an-object-method/Red/call-an-object-method.red
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
;-object creation
|
||||
my-proto: object [
|
||||
val1: 2
|
||||
val2: 3
|
||||
set: func [arg1 arg2] [self/val1: arg1 self/val2: arg2]
|
||||
sum: func [][ return (val1 + val2)]
|
||||
]
|
||||
|
||||
;-create an instance
|
||||
my-obj1: copy my-proto
|
||||
;-calling internal method to get value
|
||||
print my-obj1/sum
|
||||
|
||||
;-create a new instance
|
||||
my-obj2: copy my-proto
|
||||
;- calling an internal mathod to set value
|
||||
my-obj2/set 1 1
|
||||
;-calling the get method
|
||||
print my-obj2/sum
|
||||
|
||||
;-calling the get method on the first object
|
||||
print my-obj1/sum
|
||||
Loading…
Add table
Add a link
Reference in a new issue