Difference between revisions of "Controlling robots in remotely-operated laboratory using Objection language"
From RoboWiki
(→Language) |
|||
Line 44: | Line 44: | ||
* API for calling external libraries | * API for calling external libraries | ||
* speed | * speed | ||
+ | |||
+ | == Very basic language examples == | ||
+ | |||
+ | # Prints some prime numbers | ||
+ | var primes := {} | ||
+ | for n in 2..100 do | ||
+ | [ | ||
+ | var isPrime := yes | ||
+ | for p in primes do | ||
+ | if n mod p = 0 then | ||
+ | [ | ||
+ | isPrime := no | ||
+ | break | ||
+ | ] | ||
+ | if isPrime then | ||
+ | primes.Add(n) | ||
+ | ] | ||
+ | |||
+ | print primes | ||
+ | |||
+ | # The same, compressed | ||
+ | var primes := {} | ||
+ | for n in 2..100 do | ||
+ | if not ([p | n mod p = 0] in primes) then | ||
+ | primes.Add(n) | ||
+ | print primes |
Revision as of 04:31, 15 April 2009
Our goal is to enable robots in virtual laboratory to be controlled using the Objection programming language.
Challenges
- The Objection language runtime is written in Delphi and has not been ported to platforms other than Win32 yet
- The codebase of Objection language needs to be reorganized in a way that will allow extending it with Robot library bindings, yet ensure that the runtime core remains independent of it.
- It should be possible to replace the runtime core with a newer Objection version with as little effort as possible
- Integration to existing virtual laboratory system
- End user interface
Language
Objection is a multiparadigm programming language, written partially in itself. Every value is a first class object, including functions. Blocks of code are anonymous functions and language constructs such as loops only manipulate with functions. All of this is hidden underneath a classical, structured syntax, but remains fully accessible for the user to explore.
Here is a short list of Objection features:
- garbage collection
- optimized tail recursion
- first class functions
- anonymous functions
- closures
- generators (via the yield keyword)
- duck typing
- all values are objects
- prototype object model (can be used indirectly using class-like syntactic sugar)
- operator overloading
- basic data structures literals
- infinite lists (via generators)
- classes and metaclasses
- objects ex nihilo
- natural language constructs
- powerfull built-in higher order operators
- eager evaluation
- support for return, break and continue commands
- compiled to bytecode interpreted by Objection Virtual Machine
- editor supporting syntax highlighting (Windows only)
Here is a short list of features that Objection currently lacks:
- short circuit evaluation of boolean operators
- call-by-reference for function arguments
- exceptions
- properties
- large numbers
- sane class library
- API for calling external libraries
- speed
Very basic language examples
# Prints some prime numbers var primes := {} for n in 2..100 do [ var isPrime := yes for p in primes do if n mod p = 0 then [ isPrime := no break ] if isPrime then primes.Add(n) ] print primes
# The same, compressed var primes := {} for n in 2..100 do if not ([p | n mod p = 0] in primes) then primes.Add(n) print primes