diff --git a/cell2.md b/cell2.md new file mode 100644 index 00000000..77538bd7 --- /dev/null +++ b/cell2.md @@ -0,0 +1,50 @@ +# 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/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). + +### 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 + diff --git a/scripts/os.c b/scripts/os.c index 847de863..a95c291e 100644 --- a/scripts/os.c +++ b/scripts/os.c @@ -359,7 +359,7 @@ static JSValue js_os_dylib_symbol(JSContext *js, JSValue self, int argc, JSValue return JS_ThrowTypeError(js, "symbol name must be a string"); } - void *symbol; + JSValue (*symbol)(JSContext *js); #ifdef _WIN32 symbol = GetProcAddress((HMODULE)handle, symbol_name); #else @@ -380,7 +380,7 @@ static JSValue js_os_dylib_symbol(JSContext *js, JSValue self, int argc, JSValue } // Return the symbol as a pointer value - return JS_NewInt64(js, (int64_t)(uintptr_t)symbol); + return symbol(js); } static const JSCFunctionListEntry js_os_funcs[] = {