Jump to content

Urbiscript

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Mean as custard (talk | contribs) at 10:57, 23 September 2011 (tags). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
urbiscript
Paradigmmulti-paradigm: object-oriented, imperative, functional, procedural, reflective
Designed byJean-Christophe Baillie
DeveloperGostai et al.
First appeared2003
Stable release
2.7.1 / March 17, 2011; 14 years ago (2011-03-17)
Typing disciplineduck, dynamic
OSCross-platform
LicenseGNU Affero GPL v3[1]
Filename extensions.u
Websiteurbiforge.org
Influenced by
C++, Self, Io

urbiscript is a programming language for robotics. It features syntactic support for concurrency and event-based programming. It is a prototype-based object-oriented scripting language. Tightly bound to the Urbi platform it supports seamless integration of C++/Java components.

Syntax and semantics

Inspiration

From the syntactical point of view, urbiscript belongs to the C-family of programming languages.

Its prototype-based object-oriented design was influenced by the Self and the Io programming languages.

Sequential statements and control flow

urbiscript statements include (among others)[2]:

  • The if statement, which conditionally executes a block of code, along with else.
  • The traditional for statement, as in C which iterates over an iterable object, capturing each element to a local variable for use by the attached block.
  • Another for statement, which iterates over an iterable object, capturing each element to a local variable for use by the attached block.
  • The while statement, which executes a block of code as long as its condition is true.
  • The try statement, which allows exceptions thrown in its attached code block to be caught and handled by catch clauses. An optional else clause is run if no exception was thrown. Clean-up code can be guaranteed to be run in every case when given in a finally-clause.
  • The assert statement, used during debugging to check for conditions that ought to apply. urbiscript also feature assert blocks, which can be used to factor several assert statements.

Concurrent statements and control flow

In urbiscript, several control-flow constructs come in several "flavors": two types of sequential composition, and two types of concurrent composition.

Statement composition

Like in C, the semicolon denotes sequential composition: a;b stands for "run statement a then run statement b. Other tasks may be run between a and b. Another statement separator, pipe, denotes "tight sequential composition": no other task can be run between a and b in a|b.

Similarly urbiscript features two means to compose statements concurrently. With a,b, first a is run, and at some point b will be --- possibly while a is still running. This is very similar to the & operator in Unix shells. Alternatively, with a&b, both a and b are started together; in interactive sessions, this means that a won't be run until b is fully entered and properly followed by either a ; or a ,.

Concurrent flavors of sequential constructs

Most looping constructs in urbiscript come in several "flavors", which are based on the four statement separators: ;, |, ,, and &.

For instance

 // This is actually "for;".
 for (var i : [0, 1, 2])
 {
   echo(i);
   echo(i ** 2);
 };

displays

 [00002919] *** 0
 [00002921] *** 0
 [00002921] *** 1
 [00002922] *** 1
 [00002922] *** 2
 [00002922] *** 4

i.e., the loop bodies are not executed sequentially, while the for& keyword runs the loop bodies concurrently:

 for& (var i : [0, 1, 2])
 {
   echo(i);
   echo(i ** 2);
 };
 [00021680] *** 0
 [00021680] *** 1
 [00021680] *** 2
 [00021682] *** 0
 [00021682] *** 1
 [00021682] *** 4

See also

References

  1. ^ "Why Open Source". Retrieved 2011-09-20.
  2. ^ "urbiscript Language Reference Manual". Retrieved 2011-09-20.