mirror of
https://github.com/gren-lang/compiler.git
synced 2024-10-03 20:17:48 +03:00
Add docs for kernel object properties and optimize
This commit is contained in:
parent
35f29cc537
commit
ad8f817f5a
@ -47,6 +47,7 @@ A few things to note:
|
||||
* When defining functions and variables in the module, it needs to be prefixed with a _single_ underscore and the name of the file. In this case: `_LocalStorage_functionName`.
|
||||
* When calling a function, or referencing a variable in the same module, it must use the same prefix as when defining something.
|
||||
* When calling an external function or referencing an external variable, you must use _two_ underscores and the module name. In this case: `__Maybe_Just(item)`.
|
||||
* Object properties must be prefixed with `__$` on the javascript side if the objects come from gren, or are being passed to gren. Otherwise things will crash when `--optimize` mangles the names. E.g. `Gren.Kernel.MyModule.myFunc { foo = "bar" }` on the js side should access `foo` with `myOjb.__$foo`, and vice versa sending an object to gren from js: `__MyModule_anotherFunc({__$bar: "baz"})` would allow gren to access `bar` with `myObject.bar`.
|
||||
* Defining a function that takes more than two arguments, must be constructed using a curried function helper. For instance, defining a function like `setItem` would look like: `var _LocalStorage_setItem = F2(function(key, value) { ... });
|
||||
* Calling a function that takes between 2-9 arguments must be called using a partial application helper. As an example, calling a function with two arguments look like this: `A2(_LocalStorage_setItem, key, value)`.
|
||||
* Alternatively, you can simply perform a curried function call, though this will be worse for performance: `_LocalStorage_setItem(key)(value)`.
|
||||
|
Loading…
Reference in New Issue
Block a user