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

From Gammapedia
Jump to navigationJump to search

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.