Skip to content

Commit

Permalink
use let-values code fom R7RS spec #281
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Jan 21, 2024
1 parent f5b040a commit 74b8199
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 54 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@

<h1 align="center">
<img src="https://github.com/jcubic/lips/blob/master/assets/lips.svg?raw=true"
<img src="https://github.com/jcubic/lips/blob/devel/assets/lips.svg?raw=true"
alt="LIPS - Scheme Based Powerful Lisp Language" />
</h1>

[![X (formerly Twitter) Follow](https://img.shields.io/twitter/follow/lips_lang)](https://twitter.com/lips_lang)
[![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.18-blue.svg)](https://www.npmjs.com/package/@jcubic/lips)
![1.0.0 Complete](https://img.shields.io/github/milestones/progress-percent/jcubic/lips/1?label=1.0.0%20Complete)
[![Build and test](https://github.com/jcubic/lips/actions/workflows/build.yaml/badge.svg?branch=master&event=push)](https://github.com/jcubic/lips/actions/workflows/build.yaml)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=master&7951433cc9ff158c3701ffea07e0f004)](https://coveralls.io/github/jcubic/lips?branch=master)
[![Build and test](https://github.com/jcubic/lips/actions/workflows/build.yaml/badge.svg?branch=devel&event=push)](https://github.com/jcubic/lips/actions/workflows/build.yaml)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&7951433cc9ff158c3701ffea07e0f004)](https://coveralls.io/github/jcubic/lips?branch=devel)
[![Join Gitter Chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jcubic/lips)
![NPM Download Count](https://img.shields.io/npm/dm/@jcubic/lips)
![JSDelivr Download count](https://img.shields.io/jsdelivr/npm/hm/@jcubic/lips)
Expand Down Expand Up @@ -163,7 +163,7 @@ npm install -g @jcubic/lips@beta

you can run the interpreter from the terminal:

![LIPS: Scheme interactive terminal](https://github.com/jcubic/lips/blob/master/assets/screencast.gif?raw=true)
![LIPS: Scheme interactive terminal](https://github.com/jcubic/lips/blob/devel/assets/screencast.gif?raw=true)


You can also run code in a string with:
Expand Down Expand Up @@ -202,14 +202,14 @@ Executables also return a S-Expression according to SRFI-176 use `lips --version

## FOSDEM'23 Presentation [Video]

[![FOSDEM 2023 - LIPS Scheme: Powerful introspection and extensibility](https://github.com/jcubic/lips/blob/master/assets/fosdem-intro.png?raw=true)](https://fosdem.org/2023/schedule/event/lipsscheme/)
[![FOSDEM 2023 - LIPS Scheme: Powerful introspection and extensibility](https://github.com/jcubic/lips/blob/devel/assets/fosdem-intro.png?raw=true)](https://fosdem.org/2023/schedule/event/lipsscheme/)

## Limitations
Because LIPS is tree walking interpreter sometimes it may be slow. Especially if you want to
process long arrays and use callback function. If the array is quite large each piece of code
inside the callback may slow down the processing. For example see:

script [reference.scm](https://github.com/jcubic/lips/blob/master/scripts/reference.scm)
script [reference.scm](https://github.com/jcubic/lips/blob/devel/scripts/reference.scm)

That generates reference documentation for all builtin functions and macros.
The slow part is `(names.sort name-compare)` (`Array::sort`) that take quite time to calculate,
Expand Down
14 changes: 7 additions & 7 deletions dist/lips.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions dist/lips.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions dist/lips.esm.min.js

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions dist/lips.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions dist/lips.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/std.min.scm

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 22 additions & 9 deletions dist/std.scm

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified dist/std.xcb
Binary file not shown.
31 changes: 22 additions & 9 deletions lib/R7RS.scm
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,28 @@

;; -----------------------------------------------------------------------------
(define-syntax let-values
(syntax-rules ()
((_ ()) nil)
((_ () body ...) (begin body ...))
((_ (((x ...) values) ...) body ...)
(apply (lambda (x ... ...)
body ...)
(vector->list (apply vector-append (map (lambda (arg) ((. arg "valueOf")))
(list values ...)))))))
"(let-values binding body ...)
(syntax-rules (bind mktmp)
((let-values (binding ...) body0 body1 ...)
(let-values bind
(binding ...) () (begin body0 body1 ...)))
((let-values bind () tmps body)
(let tmps body))
((let-values bind ((b0 e0) binding ...) tmps body)
(let-values mktmp b0 e0 () (binding ...) tmps body))
((let-values mktmp () e0 args bindings tmps body)
(call-with-values
(lambda () e0)
(lambda args
(let-values bind
bindings tmps body))))
((let-values mktmp (a . b) e0 (arg ...) bindings (tmp ...) body)
(let-values mktmp b e0 (arg ... x) bindings (tmp ... (a x)) body))
((let-values mktmp a e0 (arg ...) bindings (tmp ...) body)
(call-with-values
(lambda () e0)
(lambda (arg ... . x)
(let-values bind bindings (tmp ... (a x)) body)))))
"(let-values (binding ...) body ...)
The macro work similar to let but variable is list of values and value
need to evaluate to result of calling values.")
Expand Down

0 comments on commit 74b8199

Please sign in to comment.