Skip to content

Instantly share code, notes, and snippets.

@TrainerGuy22
Last active November 5, 2022 23:53
Show Gist options
  • Save TrainerGuy22/2355e4accc8949c14384 to your computer and use it in GitHub Desktop.
Save TrainerGuy22/2355e4accc8949c14384 to your computer and use it in GitHub Desktop.
#!/usr/bin/al
namespace test;
import std.datatypes.{String, Integer, Float, Double};
import std.Process;
private saySomething(const something LetsDoSomethingCool?) String {
return generics(something?.something) + " Something else.";
}
private generics<X>(const X test) X {
return X;
}
Integer main(const argv List<String>) {
num2();
return 0;
}
num2() {
LetsDoSomethingCool something_cool = new MeToo;
LetsDoSomethingCool something_cool2 = new MeThree;
// Just let them fall out of scope.
// Or we can delete them.
delete something_cool2;
}
type _LetsDoSomethingCool class {
public String? something;
}
_LetsDoSomethingCool.this(let something : String, let suffix List<String>?) {
this.something = something;
if(suffix) {
// Operator overloading. :D
this.something.append(suffix as String);
}
}
_LetsDoSomethingCool.!this() {
auto new_something = "Hello.";
something = new_something;
// For now, I'm modeling the stdlib off of node.js's libs. :P
// printLine will just default to Process.stdout if you don't specify.
printLine("I'm saying " + saySomething(something = something) + "!");
}
_LetsDoSomethingCool.getSomething() String? {
return this.something;
}
type MeToo LetsDoSomethingCool;
MeToo.this(const String? something) {
if(something)
super(something = "Something #3.");
else
// More crazyness. ~= makes a copy in the VM instead of passing in by reference. Fancy stuff.
super(something ~= something);
}
MeToo.!this() {
super();
// Yes, your really looking at this.
case(this instanceof <>) {
MeThree {
printLine("Woah. Mind = blown.");
}
}
}
type MeThree MeToo;
MeThree.this() {
super("Something #4");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment