GOOD Generic Object Oriented Definitions
GOOD is a new Programming language under heavy development.
GOOD in a few words:
- Anything (really anything!) is a definition (instance) of an object.
- There is no difference between compile time and runtime semantics, the system will deduce the best evaluation strategy.
- GOOD itself will be implemented as a GOOD library, the language will become very dynamic, a program can adapt the language to the specific domain of the problem to be solved.
- GOOD programms become verifyable to some extent, where that is not possible the system adds runtime checks.
- GOOD uses a prototype based object system, that means that you derive from existing object instances and not from classes.
- All objects are immutable, they cannot be altered after creation.
- GOOD objects are only defined by their Attributes, there is no hardcoded type system.
- Backtracking and overloading.
write some more here...
Foundation
["/From C to GOOD"]
How does it look like?
Ok, here a small and in some detail incomplete overview about the core syntax.
core syntax
GOODs core knows only one construct, an 'object definition' which looks like: (["/BNF"] page)
:name(parameters) base_object(arguments) { body }- parameters, arguments and body are nested object definitions.
- base_object is the name of some other object.
- all of this entities are optional.
GOOD supports multiple inheritance, thus there might be more than one base_object(arguments) statement.
there might be more than one { body } part with baseclasses interweaved (not further explained here).
- All literals are string objects within the core syntax (this means that the program source consists of strings, and NOT that all internal data is handled as strings)
- String literals are enclosed in single or double quotes, note that this is only syntactic sugar to produce a string object.
The name does not need to be enclosed in quotes if it does not contain whitespaces.
- Object definitions can be prefixed/postfixed/sequenced with operators. I won't explain that here because it looks straightforward. Assume arithmetic operators, ',' and ';' to be defined.
A single underscore _ is used for universal pattern matching.
concrete examples:
an empty object named 'foo'
:foo;
an unnamed instance of 'exit'
exit;
an instance of 'integer' which is constructed with 10 and named 'ten'
:ten integer('10');a "Hello World!" could look like this, but IO is still unspecified
print("Hello World");a factorial implementation might look like this (flavored version with bounds check and exceptions)
:factorial( integer('0') ) function
{
:= integer('1')
},
:factorial( :n integer( _ ) { n > '0' && n <= '12' }) recursive function
{
:= { n * factorial( n - '1' ) }
},
:factorial( :n integer( _ ){ n > '12' } ) function
{
:= exception('out of range')
};Note: the := is just an definition of a member named = and is used to pass functional results by convention.
Ah, well i will prepare a /AnnotatedFactorialVersion of this code by public demand
Semantics
Semantics will be described in the GOOD Book which i am working on. There is some discusion about it on ["/Semantics"].
Operators
I put some prelimary thoughts about which operator will be used in GOOD on ["/Operators"]. Please review them and tell me if they are pleasant for our eyes.
Exceptions
I've written thoughts about the exception handling in ["/Exceptions"]
Imperative Programming library
Examples how ["/Imperative"] constructs can be implemented in GOOD.