Skip to content

Instantly share code, notes, and snippets.

@podhmo
Created October 2, 2010 03:13
Show Gist options
  • Save podhmo/607230 to your computer and use it in GitHub Desktop.
Save podhmo/607230 to your computer and use it in GitHub Desktop.
(define-cise-stmt RESULT_NEW_LIST
[(_ "base" i size loop-body)
`(let* ((__start::ScmObj SCM_NIL)
(__last::ScmObj SCM_NIL)
(__size::int ,size))
(dotimes (,i __size)
,loop-body)
(result __start))]
[(_ :index i :size size ('let* binding . body))
`(RESULT_NEW_LIST "base" ,i ,size
(let* ,(append binding
`((__e::ScmObj (begin ,@body))))
(SCM_APPEND1 __start __last __e)))]
[(_ :index i :size size element_fun)
`(RESULT_NEW_LIST "base" ,i ,size
(let* ((__e::ScmObj ,element_fun))
(SCM_APPEND1 __start __last __e)))])
(define-cproc glc-catalog-list ()
(RESULT_NEW_LIST :index i
:size (cast int (glcGeti GLC_CATALOG_COUNT))
(let* ((cstr::(const char*) (cast (const char*) (glcGetListc GLC_CATALOG_LIST i))))
(Scm_MakeString cstr -1 -1 SCM_STRING_COPYING))))
;; これと同等
;; (define-cproc glc_catalog_list ()
;; (let* ((start::ScmObj SCM_NIL)
;; (last::ScmObj SCM_NIL)
;; (count::int (cast int (glcGeti GLC_CATALOG_COUNT))))
;; (dotimes (i count)
;; (let* ((cstr::(const char*) (cast (const char*) (glcGetListc GLC_CATALOG_LIST i)))
;; (e::ScmObj (Scm_MakeString cstr -1 -1 SCM_STRING_COPYING)))
;; (SCM_APPEND1 start last e)))
;; (result start)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment