58 lines
2.9 KiB
Markdown
58 lines
2.9 KiB
Markdown
# Cell
|
|
Cell is an actor system, intended to make it easy to parallelize programs.
|
|
|
|
Programs are written in cell, but cell also makes it trivial to interface with C code.
|
|
|
|
## Packages
|
|
Each cell package has a .cell directory at its root. .ce files within this directory can be launched as cell actors, and .cm files can be imported with the 'use' statement.
|
|
|
|
### File search
|
|
When a file is imported, cell will search the following locations:
|
|
- The current package
|
|
- Imported packages
|
|
- The cell standard library
|
|
|
|
Files leading with an underscore are not available to import from a package (but are OK for within a package)
|
|
|
|
For example, consider this project:
|
|
prosperon/
|
|
prosperon/sprite.cm
|
|
prosperon/render.cm
|
|
prosperon/_help.cm
|
|
prosperon/render.c
|
|
prosperon/ui/
|
|
prosperon/ui/button.cm
|
|
|
|
sprite.cm can use(render); but an outside package must use(prosperon/render). sprite can use(help), but an outside package cannot use(prosperon/help).
|
|
|
|
A file like render.c above will be compiled into a dynamic library for the target platform (ie, on macos a .dylib), named the name of the package, 'prosperon.dylib'. For a local package, it will be local.dylib.
|
|
|
|
In the case above, the js_prosperon_render_use function will be found in the prosperon.dylib, and the result of that will be passed to render.cm as 'this', allowing for trivial extension.
|
|
|
|
If a C function OR a .cm file is found for a particular import, searching stops, preventing, for example, accidentally applying a .cm file from a local find to a package that has one which is similarly named.
|
|
|
|
### Importing packages
|
|
Each package has a list of packages it depends on. They can use their own naming convention for them. Packages are imported from URLs, so, gitea.pockle.world/john/prosperon imports 'prosperon'; but, when importing, you can say, 'renderer = gitea.pockle.world/john/prosperon', and that means you can use(renderer/sprite), etc.
|
|
|
|
## Modules
|
|
Modules have a .cm extension. Modules return a single value.
|
|
|
|
## Programs
|
|
Programs have a .ce extension. Programs do not return a value.
|
|
|
|
## The scripting language
|
|
Cell is basically javascript, but with some key modifications:
|
|
- blobs instead of arraybuffers, which are written and read bit by bit
|
|
- All equivalences are hard; there is only != and ==, and they do what !== and === do in javascript
|
|
- There is no undefined, only null
|
|
- 'var' acts like let, and 'def' acts like const; there is no let and const
|
|
- logging is done with the global 'log' object; log.console outputs to console, log.error outputs an error, etc.
|
|
- All numbers are dec64, and are all therefore exact; no floating point rounding errors.
|
|
- All closures act like _ =>, and close over the 'this' variable
|
|
- Arrays are distinct from objects
|
|
- There is no 'delete' operator, just assign to null
|
|
- There is no 'with'
|
|
- There are no property descriptors, objects are more like records that can hold functions, numbers, anything.
|
|
- stone() makes an object immutable, forever
|
|
|