Skip to content

Commit

Permalink
docs: Add section about JS source code limitations
Browse files Browse the repository at this point in the history
  • Loading branch information
Olian04 committed Jul 22, 2024
1 parent 161fe3f commit 6f802d5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ Accessing a property which was not passed into the template engine will result i

## Development

The source code is structured in such a way that the compiled output when targeting JS does not use recursion in the main parts of the library (`tokenizer.gleam`, `parser.gleam`, `engine.gleam` & `ctx_utils.gleam`). This prevents the JS engine from throwing "Maximum call stack size exceeded" for regular use-cases. While most JS engines boast about implementing tail call optimization, the Gleam compiler is not yet advanced enough to properly take advantage of this. There for, any changes made to the code will need to be carefully inspected after compiling to JS to make sure that no recursion is introduced. This behavior is likely to change with changes to the Gleam compiler, so whenever a new version of the Gleam compiler is released, this library will need to be recompiled and checked (at least until the Gleam compiler becomes smart enough to properly utilize TCO in JS).

Latest Gleam compiler version checked: `1.3.2`

Known recursion that needs to be resolved:

* Parsing the body of a block in `parser.gleam`

### Running in development

```sh
gleam test
gleam test # Test Erlang
gleam test -t js # Test Nodejs
```

0 comments on commit 6f802d5

Please sign in to comment.