Gammapedia is archived. No new edits are allowed and no new accounts can be registered.
Ikepedia is the officially decreed successor to Gammapedia concerning Gammasphere canon.
Infinitypedia is another successor.
User:Abwayax/Abwayax programming language
Data types
- Scalar: holds an alphanumerical value, denoted by $
- Array: holds a collection of values of any data type, denoted by @
- Hash: holds a collection of values mapped to keys, denoted by %
- Object: a data structure with methods and instance variables, denoted by *
- Function: an executable body of code, denoted by & (all functions are defined like this)
Scope
Global scope
Everything defined outside an object or function is considered to be in the global scope. A variable is defined as public by default; to mark it as private to the currently running script, prefix the variable declaration with private. To ensure that a variable is not redefined later in the script, mark it as final.
Function scope
Anything defined inside the body of a function is considered to be in "function scope". Variables defined within a function are local to the function and cannot be referenced outside it. However, any attempt to define a variable that has the same name as one in the global scope will reference the global variable; to get around this define the variable with the keyword local.
1
$string = "A String with Spaces"; @words = split(" ",$string); foreach(@words As $words) { print $string; }
2
&foo = { print bar(); } &bar = { return baz("foo"); } &baz($arg) = { return "$arg equals $arg"; } foo(); // foo equals foo
3
*myObj = object(); *myObj->method = { print "Method"; } *myObj->method();
4
&Increaser = { *myObj = object(); setType(*myObj,"Increaser"); public-readonly *myObj->amount = 0; final *myObj->increase = { *this->amount++; } return *myObj; } *myIncreaser = Increaser(); *myIncreaser->increase(); *myIncreaser->increase(); print *myIncreaser->amount; // you can read it, but not write to it
5
&SuperIncreaser($step) = { *myObj = Increaser(); setType(*myObj,"SuperIncreaser"); final private *myObj->step = $step; final *myObj->superIncrease = { for($i = 0; $i < *this->step; $i++) *this->increase(); } return *myObj; } *mySuperIncreaser = SuperIncreaser(40); *mySuperIncreaser->increase(); // amount is 1; *mySuperIncreaser->increase(); // amount is 2; *mySuperIncreaser->superIncrease(); // amount is 42;
6
&square($num) = stringAsFunction("return \$num * \$num"); print square(5); // 25
7
&smethit($arg) = eval("smeth { $arg }"); smethit("Loop i from 1 to 10, increasing i by 1: Print i.");
8
malbolge { (=<`:9876Z4321UT.-Q+*)M'&%$H"!~}|Bzy?=|{z]KwZY44Eq0/{mlk** hKs_dG5[m_BA{?-Y;;Vb'rR5431M}/.zHGwEDCBA@98\6543W10/.R,+O< } // Hello, world.
9
java { JFrame frame = new JFrame(); frame.add(new JTextArea(mySuperIncreaser.amount)); } smeth { Call method setTitle on frame with parameter "Dynamically Generated Project F Window". } *frame->setSize(); *frame->setVisible(true);
10
&pfeval($stuff) = { return eval($stuff); } java { System.out.println(pfeval("*frame->getTitle()")); } // note: the Project F eval function is not carried over into embedded languages because almost every language has its own eval
11
*aList = JavaObject("java.util.ArrayList"); *aList->add("woot"); *aList->add("pwn"); print *aList->toString();
12
/* lol */ maybe() { print "This line has a 50% chance of being printed."; } maybe(4/5) { print "but this line has an 80% chance"; }