guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

return macro


From: Damien Mattei
Subject: return macro
Date: Mon, 28 Jun 2021 01:10:29 +0200

hi,

i wanted to create a macro that is used like a function definition and
allow return using call/cc:

(define-syntax def
(syntax-rules (return)
((_ (name args ...) body body* ...)
(define name (lambda (args ...)
(call/cc (lambda (return) body body* ...)))))
((_ name expr) (define name expr))))

unfortunaly i got error:

scheme@(guile-user)> (def (test x) (cond ((= x 3) 7) ((= x 2) (return 5))
(else 3)))
;;; <stdin>:2:42: warning: possibly unbound variable `return'
scheme@(guile-user)> (test 2)
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Unbound variable: return


any idea?

Damien


reply via email to

[Prev in Thread] Current Thread [Next in Thread]