forked from vedderb/bldc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squashed 'lispBM/lispBM/' changes from 6a448aa3..c097f5c6
c097f5c6 cleaning pass and refactoring 5384d522 refactoring application experiment 087ede4e refactor: readability, clearity and in some places - to a small degree - correctness 89575d8b small change to one event test ba6e7fa7 logged change 16ac6bd1 logged change 089468b3 removing make-env. in-env in the interest of keeping core language small f18015f7 Merge branch 'master' of github.com:svenssonjoel/lispbm 5b19dfda simplification and readability refactoring. 8c492889 Update gotchas.md 754221b9 Update gotchas.md a0931bac bump version e49071dc Changed behavior closure application to zero args. Application of a continuation (call-cc) with 0 args still uses the old approach where 0 args is equivalent to application to nil 35f495f3 mini tweak readme fdd01ff1 update README b21a3fa7 Update gotchas.md 92d9f561 update gotchas 0d708de7 bugfix in incremental reader and addition of a gotchas.md file for edge-case behaviors d9a38456 updated lbmref with take and drop 86b1cc1b take, drop, change to make-env returned result ea29f5ec added take and drop as built-in primitives and change to result env for make-env 55a5b1f5 added some tests and a small amount of doc e2d2f745 tweaks bccdee1f make-env and in-env 3a03232a added make-env and in-env for library-encapsulation e5b5ba66 mini tweak dce87812 removed extra ; 190b4d9e mini tweak 6864fa32 fix repl after removal of reading_done callback ea3aba39 removed reading_done_callback and made the nonsense default variants for all remaining callback 427cb37c bugfix read-program, tightening up, cleaning 119d9fd3 refactoring and tightening up 10573404 cleaning and readability 63b750b5 small tweaks d44c8bdc bug fix related to row numbers in error messages while doing incremental read. Now more precise. d0125bd1 refactoring for readability. setjmp/longjmp for escape from deeply nested errors. git-subtree-dir: lispBM/lispBM git-subtree-split: c097f5c66bd539442a48d41a66da1c657af502a1
- Loading branch information
Showing
34 changed files
with
901 additions
and
1,031 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
|
||
[Language reference](./lbmref.md) | ||
[Gotchas and caveats](./gotchas.md) | ||
|
||
|
||
## Programming manual | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# LBM Gotchas and Caveats | ||
|
||
This document collects caveats and gotchas as they are discovered. Hopefully these will | ||
also be given efficient solutions at some points in which case the solution to that gotcha | ||
will also be documented here. | ||
|
||
If you find any more gotchas, please let me know how to trigger them! Would be much appreciated. | ||
|
||
## Environment | ||
|
||
In LBM there is a global environment which is an association list of `(symbol . value)` pairs. | ||
There is also a local environment that is carried along in the evaluator while evaluating | ||
expressions. This local environment is also an association list `(symbol . value)` pairs. | ||
|
||
### Closure Gotcha! | ||
|
||
When a closure is created, a reference to the local environment is stored in the closure object. | ||
This is for efficiency reasons as traversing the expression and pulling in all free variables | ||
would be a somewhat costly operation (order of the size of the expression) while saving a reference | ||
to the local environment is an O(1) operation. This essentially trades some space (as it potentially | ||
prohibits GC from removing some dead values during the life-time of that closure) for improved performance. | ||
|
||
Note that the global environment is not "saved" in the same way inside the closure. Given that | ||
`undefine` exists in LBM, this is a potential foot-gun as illustrated by the example below: | ||
|
||
```clj | ||
# (define a 10) | ||
> 10 | ||
# (define f (lambda (x) (+ x a))) | ||
> (closure (x) (+ x a) nil) | ||
# (undefine 'a) | ||
> ((f closure (x) (+ x a) nil)) | ||
# (f 1) | ||
*** Error: variable_not_bound | ||
*** a | ||
# | ||
*** Between rows: (-1 unknown) | ||
*** Start: -1 | ||
*** End: -1 | ||
# | ||
> variable_not_bound | ||
# | ||
``` | ||
|
||
Currently no (efficient) solution in mind for this gotcha. Just be careful if you use `undefine`. | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.