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: Difference between revisions
No edit summary |
No edit summary |
||
(2 intermediate revisions by one other user not shown) | |||
Line 30: | Line 30: | ||
* '''public-readonly''': In objects, public-readonly fields can be read by any code, but modified only by object method code. | * '''public-readonly''': In objects, public-readonly fields can be read by any code, but modified only by object method code. | ||
==Embedded Scripts== | ==Embedded Scripts== | ||
abwayax can take advantage of other scripting languages with special blocks. For example, a '''sleep''' block denotes code that should be executed as [http://sleep.hick.org/ Sleep] code. In particular, when abwayax encounters a '''java''' block, it first checks to see if you have [http://www.beanshell.org/license.html BeanShell] in the classpath; if so, it runs the code under BeanShell; if not, the code is run under a [http://koala.ilog.fr/djava/ DynamicJava] interpreter. When abwayax runs embedded code, it will try to copy all of the symbols in its symbol table to the other interpreter, and recopy them to the abwayax symbol table when done, making the integration as seamless as possible. | |||
== | ==Optimum.abwayax== | ||
The final test case of abwayax is '''[http://gammapedia.goldeye.info/index.php?title=User:Abwayax/Abwayax_programming_language/Optimum.abwayax&action=raw Optimum.abwayax]''' ([http://gammapedia.goldeye.info/index.php?title=User:Abwayax/Abwayax_programming_language/Optimum.abwayax&action=edit edit]), which should include all of the desired features of the language. The language will be considered "complete" if Optimum.abwayax runs flawlessly. | |||
= | |||
= | |||
Latest revision as of 07:40, 28 October 2007
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.
Object scope
"Object scope" refers to code in object methods. Object scope includes the instance fields and other methods of the object. In object scope, all members of the object, including private ones, are available for reading and writing. The special variables *this and *super are used to access the members of the current object and its superclass. At any time, a member (field or method) may be defined or redefined. Individual members of an object must be marked final to prevent redefinition or modification. Marking the object variable itself as final prevents any new members from being added to it.
Namespace scope
"Namespace scope" refers to all code enclosed in a namespace block. A namespace is a grouping of related functions and data. To create a namespace, use
namespace MyNamespace { // stuff here }
Alternatively, to place all the code in a script file under a namespace, you can use
namespace MyNamespace;
To access data in a namespace, use
MyNamespace::nameOfVariable
Note that you have to add the appropriate prefix ($,%,@,&,*) to the beginning of the namespace name. In addition, if you want to import all of the members of a namespace into the global scope, you can use
using namespace MyNamespace;
Data marked private is available only to the namespace.
Access Modifiers
- public: Every script can access the data.
- private: In objects, private fields can only be accessed by methods of that object. In namespace scope, private variables are hidden from code outside the namespace.
- public-readonly: In objects, public-readonly fields can be read by any code, but modified only by object method code.
Embedded Scripts
abwayax can take advantage of other scripting languages with special blocks. For example, a sleep block denotes code that should be executed as Sleep code. In particular, when abwayax encounters a java block, it first checks to see if you have BeanShell in the classpath; if so, it runs the code under BeanShell; if not, the code is run under a DynamicJava interpreter. When abwayax runs embedded code, it will try to copy all of the symbols in its symbol table to the other interpreter, and recopy them to the abwayax symbol table when done, making the integration as seamless as possible.
Optimum.abwayax
The final test case of abwayax is Optimum.abwayax (edit), which should include all of the desired features of the language. The language will be considered "complete" if Optimum.abwayax runs flawlessly.