Skip to content

Commit 5009be5

Browse files
committed
document limitations jcubic#182
1 parent 2b11dbc commit 5009be5

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.14-blue.svg)](https://www.npmjs.com/package/@jcubic/lips)
44
![1.0.0 Complete](https://img.shields.io/github/milestones/progress-percent/jcubic/lips/1?label=1.0.0%20Complete)
5-
[![travis](https://travis-ci.com/jcubic/lips.svg?branch=devel&a8c8b394c40212aa9829e7e03f3e4750cf110813)](https://travis-ci.com/jcubic/lips)
5+
[![travis](https://travis-ci.com/jcubic/lips.svg?branch=devel&2b11dbcbf8069977208a6ff4a0757fe77b592f5d)](https://travis-ci.com/jcubic/lips)
66
[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&bbffc3b45ac48fb918c597ba56678937)](https://coveralls.io/github/jcubic/lips?branch=devel)
77
[![Join Gitter Chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jcubic/lips)
88
[![GitHub license](https://img.shields.io/github/license/jcubic/lips.svg)](https://github.com/jcubic/lips/blob/master/LICENSE)
@@ -181,6 +181,27 @@ chmod a+x foo.scm
181181

182182
Executables also return a S-Expression according to SRFI-176 use `lips --version` or `lips -V`.
183183

184+
## Limitations
185+
Because LIPS is tree walking interpreter sometimes it may be slow. Especially if you want to
186+
process long arrays and use callback function. If the array is quite large each pice of code
187+
inside the callback may slow down the processing. For example see:
188+
189+
script [reference.scm](https://github.com/jcubic/lips/blob/devel/scripts/reference.scm)
190+
191+
That generates reference documentation for all builtin functions and macros.
192+
The slow part is `(names.sort name-compare)` (`Array::sort`) that take quite time to calculate,
193+
because the array with functions and macros is quite large. If you came into performance issue,
194+
you can write the part of the code in JavaScript. If you want to do this in LIPS Scheme you can use
195+
something like this:
196+
197+
```scheme
198+
(let ((fn (self.eval "(function(a, b) {
199+
/* any complex code in JS */
200+
return a.localeCompare(b);
201+
})")))
202+
(arr.sort fn))
203+
```
204+
184205
## Links
185206
* [Gitter Chat](https://gitter.im/jcubic/lips)
186207
* [LISP: Scheme in JavaScript Git Repository](https://github.com/jcubic/lips)

templates/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,27 @@ chmod a+x foo.scm
181181

182182
Executables also return a S-Expression according to SRFI-176 use `lips --version` or `lips -V`.
183183

184+
## Limitations
185+
Because LIPS is tree walking interpreter sometimes it may be slow. Especially if you want to
186+
process long arrays and use callback function. If the array is quite large each pice of code
187+
inside the callback may slow down the processing. For example see:
188+
189+
script [reference.scm](https://github.com/jcubic/lips/blob/{{BRANCH}}/scripts/reference.scm)
190+
191+
That generates reference documentation for all builtin functions and macros.
192+
The slow part is `(names.sort name-compare)` (`Array::sort`) that take quite time to calculate,
193+
because the array with functions and macros is quite large. If you came into performance issue,
194+
you can write the part of the code in JavaScript. If you want to do this in LIPS Scheme you can use
195+
something like this:
196+
197+
```scheme
198+
(let ((fn (self.eval "(function(a, b) {
199+
/* any complex code in JS */
200+
return a.localeCompare(b);
201+
})")))
202+
(arr.sort fn))
203+
```
204+
184205
## Links
185206
* [Gitter Chat](https://gitter.im/jcubic/lips)
186207
* [LISP: Scheme in JavaScript Git Repository](https://github.com/jcubic/lips)

0 commit comments

Comments
 (0)