Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,17 @@
// Define the thread if it doesn't exist
// New definition supersede any current threads.
not ::serverwide_singleton->istype
? define serverwide_singleton => thread {
data public switch = 'x'
}
local(
a = serverwide_singleton,
b = serverwide_singleton,
)
#a->switch = 'a'
#b->switch = 'b'
#a->switch // b

View file

@ -0,0 +1,16 @@
// Define thread level singleton
define singleton => type {
data public switch = 'x'
public oncreate => var(.type)->isa(.type) ? var(.type) | var(.type) := self
}
local(
a = singleton,
b = singleton,
)
#a->switch = 'a'
#b->switch = 'b'
#a->switch // b

View file

@ -0,0 +1,22 @@
-- parent script "SingletonDemo"
property _instance
property _someProperty
----------------------------------------
-- @constructor
----------------------------------------
on new (me)
if not voidP(me.script._instance) then return me.script._instance
me.script._instance = me
me._someProperty = 0
return me
end
----------------------------------------
-- sample method
----------------------------------------
on someMethod (me, x)
me._someProperty = me._someProperty + x
return me._someProperty
end

View file

@ -0,0 +1,4 @@
type Singleton = object # Singleton* would export
foo*: int
var single* = Singleton(foo: 0)

View file

@ -0,0 +1,4 @@
import singleton
single.foo = 12
echo single.foo

View file

@ -0,0 +1,6 @@
Object Class new: Sequence(channel)
Sequence method: initialize(initialValue)
Channel newSize(1) := channel
@channel send(initialValue) drop ;
Sequence method: nextValue @channel receive dup 1 + @channel send drop ;

View file

@ -0,0 +1,6 @@
import: parallel
: testSequence
| s i |
Sequence new(0) ->s
100 loop: i [ #[ s nextValue println ] & ] ;

View file

@ -0,0 +1,21 @@
class Singleton(name) {
static instance;
method new(name) {
instance := Singleton.bless(Hash(:name => name));
}
method new {
Singleton.new(nil);
}
}
var s1 = Singleton('foo');
say s1.name; #=> 'foo'
say s1.object_id; #=> '30424504'
var s2 = Singleton();
say s2.name; #=> 'foo'
say s2.object_id; #=> '30424504'
s2.name = 'bar'; # change name in s2
say s1.name; #=> 'bar'