Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,11 @@
class Thingable{ var thing; }
class Delegator{
var delegate;
fcn operation{
if (delegate) delegate.thing;
else "default implementation"
}
}
class Delegate(Thingable){ thing = "delegate implementation" }

View file

@ -0,0 +1,7 @@
// Without a delegate:
a:= Delegator();
a.operation().println(); //--> "default implementation"
// With a delegate:
a.delegate = Delegate();
a.operation().println(); //-->"delegate implementation"

View file

@ -0,0 +1,6 @@
class [static] Logger{ // Only one logging resource
var [mixin=File] dst; // File like semantics, eg Data, Pipe
dst = File.DevNull;
// initially, the logger does nothing
fcn log(msg){dst.writeln(vm.pasteArgs())}
}

View file

@ -0,0 +1,6 @@
Logger.log("this is a test"); //-->nada
Logger.dst=Console;
Logger.log("this is a test 2"); //-->writes to Console
class B(Logger){ log("Hello from ",self,"'s constructor"); }
B(); //-->Hello from Class(B)'s constructor