Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sebbekarlsson/cola

component language (component-based programming language)
https://github.com/sebbekarlsson/cola

components interpreter programming-language wip

Last synced: 3 months ago
JSON representation

component language (component-based programming language)

Awesome Lists containing this project

README

        

## Cola
> _A component-based programming language._

## Snippet
> Here is what it looks like:

comp productlist use httplib, json {
function array get_products {
return json.parse(httplib.get('http://example.org/products'));
};

function array yields {
return get_products();
};
};

comp main use productlist {
function void run {
foreach (productlist as product) {
print(product);
};
};
};

## How to write a component
### The syntax
> The syntax for a component looks like this:
`comp [NAME] use [DEPENDENCY-LIST] [LBRACE] [RBRACE]`

comp mycomponent use somelibrary {
...
};

### The run-method
> The `run` method in a component can be executed through the `run` statement:

comp mycomponent {
function void run {
print("Hello World!")
};
};

comp main use mycomponent {
// run method of `mycomponent` is executed when mounted like this
};

### The yields-method
> The `yields` method in a component is used to make a component act as if
> it was another data-type. For example:

comp PI {
function float yields {
return 3.14;
};
};

comp main use PI {
function void run {
print(PI * 0.5);
};
};

> ... here, the `PI` component is treated as if it was a float.

### Interpreter instructions
> You can include other files using interpreter instructions, it looks
> very much like in `C`:

#include "somefile.cola"

comp main {
...

## Data-types
> The existing data-types are:
* int
* string
* array
* map
* struct

### Note
> The `array` data-type can hold any sort of type, but the type must
> be specified like: `array numbers;` or `array names;`

> The `map` data-type can also hold any sort of type and specified like:
> `map ages;` or `map> fav_numbers;`

## Built-in methods
> These are the built-in methods that currently exists:
* **print** - _print something to stdout_ (takes an infinite list of arguments)