Skip to content

Instantly share code, notes, and snippets.

View ijp's full-sized avatar

Ian Price ijp

  • Aberdeen, Scotland
View GitHub Profile
@ijp
ijp / gist:1306772
Created October 23, 2011 02:31
a bug in guiles peval
(define (test peval?)
(compile
'(let ()
(define (rewind-protect thunk protector)
(dynamic-wind
(let ((entered? #f))
(lambda ()
(if entered?
(error "Re-entering rewind-protected extent."))
(set! entered? #t)))
(define guardian (make-guardian))
(define finalizer-table (make-weak-key-hash-table))
(let ((f (lambda () (display "test\n"))))
(guardian f)
(hashq-set! finalizer-table (cons #f #f) f)
#f) ;; just in case you want to test at repl
(write finalizer-table)
(newline)
@ijp
ijp / *shell*
Created November 7, 2011 15:40
make[3]: Entering directory `/home/ian/src/guile/libguile'
GEN guile−procedures.texi
Throw without catch before boot:
Throw to key misc−error with args ("module−transformer" "no module, and `macroexpand' unbound" () #f)Aborting.
/bin/sh: line 1: 4920 Broken pipe cat alist.doc arbiters.doc array−handle.doc array−map.doc arrays.doc async.doc backtrace.doc boolean.doc bitvectors.doc bytevectors.doc chars.doc control.doc continuations.doc debug.doc deprecated.doc deprecation.doc dynl.doc dynwind.doc eq.doc error.doc eval.doc evalext.doc expand.doc extensions.doc feature.doc filesys.doc fluids.doc foreign.doc fports.doc gc−malloc.doc gc.doc gettext.doc generalized−arrays.doc generalized−vectors.doc goops.doc gsubr.doc guardians.doc hash.doc hashtab.doc hooks.doc i18n.doc init.doc ioext.doc keywords.doc list.doc load.doc macros.doc mallocs.doc memoize.doc modules.doc numbers.doc objprop.doc options.doc pairs.doc ports.doc print.doc procprop.doc procs.doc promises.doc r6rs−ports.doc random.doc rdel
;; Syntax parameter examples
(define-syntax-parameter abort
(syntax-rules ()))
(define-syntax forever
(syntax-rules ()
[(forever body ...)
(call/cc (lambda (abort-k)
(syntax-parameterize
@ijp
ijp / ->.scm
Created November 11, 2011 19:35
scheme version of clojure's ->
;; scheme version of clojure's ->
;; ->
;; macro
;; Usage: (-> x)
;; (-> x form)
;; (-> x form & more)
;; Threads the expr through the forms. Inserts x as the
;; second item in the first form, making a list of it if it is not a
;; list already. If there are more forms, inserts the first form as the
#!r6rs
;; a permissive version of receive, that allows extra values without
;; error, and supplies a default for missing ones
;;
;; tested on guile and racket
(library (permissive-receive)
(export receive*)
(import (rnrs)
(for (only (srfi :1 lists) iota) expand))
(define-syntax receive*
#!r6rs
;; Really simple generators using delimited continuations
(library (toys simple-generators)
(export make-generator
up-from
list->generator)
(import (rnrs)
(spells delimited-control))
(use-modules (ice-9 control)
(rnrs hashtables)
(web server)
(sxml simple)
(web response)
(web request)
(web uri)
(ice-9 match))
;; utilities
@ijp
ijp / rec.ml
Created November 28, 2011 16:17
class type foo =
object
method bar : bazt
end and bazt =
object
inherit foo
end;;
class baz =
object (self : #foo)
@ijp
ijp / module-exports.scm
Created December 1, 2011 20:12
get a list of module exports
(define-module (module-exports)
#:export (module-exports)
#:use-module (ice-9 session))
(define (module-exports module-name)
(let ((new-module (resolve-module module-name)))
(apropos-fold (lambda (module name var data)
(if (eqv? module new-module)
(cons name data)
data))