add partcont library

This commit is contained in:
Yuichi Nishiwaki 2014-05-19 14:38:32 +09:00
parent 10db8b9a2b
commit 5ba1d4eb39
3 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,2 @@
file(GLOB PARTCONT_FILES ${PROJECT_SOURCE_DIR}/contrib/partcont/piclib/*.scm)
list(APPEND PICLIB_CONTRIB_LIBS ${PARTCONT_FILES})

View File

@ -0,0 +1,28 @@
(define-library (picrin control)
(import (scheme base))
(define m #f)
(define (reset t)
(call/cc
(lambda (k)
(let ((n m))
(set! m (lambda (r)
(set! m n)
(k r)))
(t)))))
(define (shift h)
(call/cc
(lambda (k)
(h (lambda (v)
(reset (lambda ()
(k v))))))))
(define prompt reset)
(define control shift)
(export shift
reset
control
prompt))

View File

@ -9,6 +9,8 @@ set(XFILE_SOURCES extlib/xfile/xfile.c)
# piclib
find_package(Perl REQUIRED)
file(GLOB_RECURSE PICLIB_SCHEME_LIBS ${PROJECT_SOURCE_DIR}/piclib/*.scm)
list(APPEND PICLIBS ${PICLIB_SCHEME_LIBS})
list(APPEND PICLIBS ${PICLIB_CONTRIB_LIBS})
set(PICLIB_SOURCES ${PROJECT_SOURCE_DIR}/src/load_piclib.c)
add_custom_command(
OUTPUT ${PICLIB_SOURCES}