User:Saejox/AngelScript

AngelScript
ParadigmMulti-paradigm: scripting, imperative, functional, object-oriented
First appeared2003
Stable release
2.41.0 / August 7, 2012 (2012-08-07)
Typing disciplineStatic
OSCross-platform
Licensezlib License
Filename extensions.as
Websiteangelcode.com/angelscript
Influenced by
C++

AngelScript is a scripting language designed to be inside C/C++ applications and games. AngelScript released as open source in permissive zlib license. It is cross-platform and known to work with many platforms and compilers. [1]

Library appeared in 2003, and still actively maintained.

Language Features edit

  • Familiar, C++ like
  • Static typing, Compile time static checks to ensure strong typing.
  • Handles, Pointer like operators. Maybe used in both script and C++ extensions.
  • Object-oriented, Classes and interfaces. Single inheritance through classes, multiple-inheritance with interfaces.
  • Compiled, script compile to bytecode before execution. Runtime compile is allowed.
  • Allow direct access to C++ objects, functions and properties
  • Sandbox, script are limited to what application exposes.
  • Optional UTF-8 and UTF-16 encoding for script files.
  • Concurrent, many scripts may be run in parallel.

Examples edit

Comments

// a single line comment start withs to slashes
/*
  A multi-line comments start with slash and an asterisk, ends with slash and an asterisk
*/

Functions

void Foo()
{
  // statements
}

Loops

for(uint i=0; i < 10; ++i)
{
  //statements
}
while(boolean_var)
{
  // statements
}
do
{
  // statements
}while(boolean_var)

Classes

AngelScript supports object-oriented programming.

It has single inheritance for classes, and polymorphism with interfaces.

class Base
{
 Base() // constructor
 {
   foo = 53;
 }
 int foo;
 float Bar()
 {
   // statements
 }
}; // semicolon optional

class Child : Base // inherits base
{
  Child()
  {
    Base::Base(); // call Base constructor
  }

  ~Child() // destructor. all methods are virtual
  {
    // statements
  }
}

Handles

Handles are AngelScript's way of handling pointers.

Handles may be passed between script Virtual Machine and application without any change in address they point at.

Handles do not have pointer arithmetic.

Handles are reference counted. They are released when not needed automatically.

An incremental Garbage collector (computing) exists to resolve possible circular references.

Object obj;
Object @handle = obj; // handle holds a reference to obj 
Object @handle2 = null; // handle2 is null. null is a built-in value that all handles can take
@handle2 = handle; // handle2 now holds reference to obj
@handle = null; // handle is now null. handle2 still holds reference to obj.

/* obj will not be released until handle2 is destroyed or has reference to another Object. */

Used in edit

See also edit

References edit

External links edit