-
Notifications
You must be signed in to change notification settings - Fork 0
/
block.scm
52 lines (39 loc) · 1.39 KB
/
block.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
; This file is part of Scheme+
;; Copyright 2021 Damien MATTEI
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
(define-syntax $ ;; Warning : used by SRFI 9 : Record too ?
(syntax-rules ()
((_ ev) ev)
((_ ev ...) (begin ev ...))))
;; scheme@(guile-user)> (def bar (& (declare x y) {x <- 1} {y <- 2} (lambda (t) (+ x y t))))
;;
;; (def bar (& (declare x y)
;; {x <- 1}
;; {y <- 2}
;; (lambda (t) (+ x y t))))
;;
;; scheme@(guile-user)> (bar 7)
;; $2 = 10
(define-syntax &
(syntax-rules ()
((_ ev) (let () ev)) ;; there can be a <+ in it expanding with a 'define not allowed in expression context
((_ ev ...) (let () ev ...))))
;; then and else do as BEGINners ;-)
(define-syntax then-block
(syntax-rules ()
((_ ev) ev)
((_ ev ...) (begin ev ...))))
(define-syntax else-block
(syntax-rules ()
((_ ev) ev)
((_ ev ...) (begin ev ...))))
;; damned... this one makes syntax enlightning bug in Emacs
;; (define-syntax |
;; (syntax-rules ()
;; ((_ ev) ev)
;; ((_ ev ...) (begin ev ...))))