Skip to content

Instantly share code, notes, and snippets.

(define-macro (dfsch:define-class name superklass slots
&rest class-opts
&key roles &allow-other-keys)
;; Remove role list from list of class options
(set! class-opts (plist-remove-keys class-opts '(:roles)))
;; Evaluate list of roles in outer context
(set! roles (eval-list roles (%macro-expansion-environment)))
(set! superklass (eval superklass (%macro-expansion-environment)))
00000000 0c 63 6f 6d 70 61 63 74 2d 6c 69 73 74 05 7f 03 |.compact-list...|
00000010 0d 63 61 6e 6f 6e 2d 65 6e 76 2d 72 65 66 05 64 |.canon-env-ref.d|
00000020 66 73 63 68 04 73 65 74 21 06 73 79 6d 62 6f 6c |fsch.set!.symbol|
00000030 14 64 66 73 63 68 25 69 6d 70 6c 65 6d 65 6e 74 |.dfsch%implement|
00000040 61 74 69 6f 6e 0a 63 6c 61 73 73 2d 6f 70 74 73 |ation.class-opts|
00000050 7f 01 7e 7d 11 70 6c 69 73 74 2d 72 65 6d 6f 76 |..~}.plist-remov|
00000060 65 2d 6b 65 79 73 7f 02 0e 62 61 63 6b 2d 72 65 |e-keys...back-re|
00000070 66 65 72 65 6e 63 65 04 7f 01 7e 7d 05 71 75 6f |ference...~}.quo|
00000080 74 65 0c 6d 75 74 61 62 6c 65 2d 70 61 69 72 7f |te.mutable-pair.|
00000090 01 7c 07 6b 65 79 77 6f 72 64 05 72 6f 6c 65 73 |.|.keyword.roles|
00000000 0c 63 6f 6d 70 61 63 74 2d 6c 69 73 74 03 0d 63 |.compact-list..c|
00000010 61 6e 6f 6e 2d 65 6e 76 2d 72 65 66 0e 64 66 73 |anon-env-ref.dfs|
00000020 63 68 25 69 6e 74 65 72 6e 61 6c 1a 25 64 65 66 |ch%internal.%def|
00000030 69 6e 65 2d 63 61 6e 6f 6e 69 63 61 6c 2d 63 6f |ine-canonical-co|
00000040 6e 73 74 61 6e 74 06 73 79 6d 62 6f 6c 0a 64 66 |nstant.symbol.df|
00000050 73 63 68 2d 75 73 65 72 09 66 61 63 74 6f 72 69 |sch-user.factori|
00000060 61 6c 7f 02 7e 7d 10 25 72 65 63 6c 6f 73 65 2d |al..~}.%reclose-|
00000070 63 6c 6f 73 75 72 65 11 73 74 61 6e 64 61 72 64 |closure.standard|
00000080 2d 66 75 6e 63 74 69 6f 6e 0b 6c 61 6d 62 64 61 |-function.lambda|
00000090 2d 6c 69 73 74 00 01 00 00 00 00 7c 7b 01 6e 7f |-list......|{.n.|
[689490.180010] vnet1: no IPv6 routers present
[769944.363808] php-fpm[8165]: segfault at 80e40 ip 082b109a sp bfe5d180 error 4 in php-fpm[8048000+3ae000]
[897417.111607] EXT3-fs error (device dm-0): ext3_free_blocks_sb: bit already cleared for block 459272
[897417.111671] Aborting journal on device dm-0.
[897417.152928] ext3_abort called.
[897417.152957] EXT3-fs error (device dm-0): ext3_journal_start_sb: Detected aborted journal
[897417.153013] Remounting filesystem read-only
[897417.184406] Remounting filesystem read-only
[897417.233282] EXT3-fs error (device dm-0) in ext3_free_blocks_sb: Journal has aborted
[897417.233348] EXT3-fs error (device dm-0) in ext3_free_blocks_sb: Journal has aborted
$ ./dfsch-repl
/\___/\ dfsch version 0.4.0-dev
( o o ) (rel-0.3.0-1219-g0ae9b2e) [Nov 15 2011 05:35:34]
== * == dfsch is free software, and you are welcome to redistribute it
) ( under certain conditions; see file COPYING for details.
]=> (car :mnau)
debugger invoked on type-error:
:mnau is not an instance of #<abstract-type 0x7ff0b410bae0 pair instance-size: 16>
:instance-suffices?: true
srcdirstrip=`echo ".." | sed 's/[].[^$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo ".." | sed 's/[].[^$\\*]/\\\\&/g'`; \
list='README ../m4/libtool.m4 ../m4/ltoptions.m4 ../m4/ltsugar.m4 ../m4/ltversion.m4 ../m4/lt~obsolete.m4 ../configure.ac ../aclocal.m4 dfsch/lib/threads.h dfsch/lib/os.h dfsch/lib/posix-regex.h dfsch/lib/inet.h dfsch/lib/cdebug.h dfsch/lib/cinspect.h dfsch/lib/console.h dfsch/lib/xml.h dfsch/lib/sxml.h dfsch/lib/shtml.h dfsch/lib/json.h dfsch/lib/socket-port.h dfsch/lib/http.h dfsch/lib/csv.h dfsch/lib/ini-file.h dfsch/lib/zlib.h dfsch/lib/tk-gui.h dfsch/lib/pcre.h dfsch/lib/crypto.h dfsch/lib/tokyo-cabinet.h dfsch/lib/tokyo-tyrant.h dfsch/lib/gd.h dfsch/lib/ffi.h dfsch/lib/curl.h dfsch/strings.h dfsch/defines.h dfsch/parse.h dfsch/hash.h dfsch/dfsch.h dfsch/types.h dfsch/number.h dfsch/magic.h dfsch/object.h dfsch/weak.h dfsch/format.h dfsch/ports.h dfsch/load.h dfsch/util.h dfsch/bignum.h dfsch/conditions.h dfsch/introspect.h dfsch/random.h dfsch/writer.h dfsch/eqhash.h dfsch/mkhash.h dfsch
@adh
adh / gist:979838
Created May 18, 2011 23:36
Compilation of nested closures
]=> (define (foo x)
..> (let ((x 0))
..> (lambda ()
..> (set! x (1+ x))
..> x)))
#<standard-function 0x15f30f0 foo(x)>
]=> (slot-ref foo :code)
((let ((x 0)) (lambda () (set! x (1+ x)) x)))
]=> (define quux (foo 12))
#<standard-function 0x165ff50 ()>
0000000000030fb0 <dfsch__reclose_closure>:
30fb0: 48 89 6c 24 f0 mov %rbp,-0x10(%rsp)
30fb5: 48 89 5c 24 e8 mov %rbx,-0x18(%rsp)
30fba: 48 89 f5 mov %rsi,%rbp
30fbd: 4c 89 64 24 f8 mov %r12,-0x8(%rsp)
30fc2: 48 83 ec 18 sub $0x18,%rsp
30fc6: 48 85 ff test %rdi,%rdi
30fc9: 0f 84 9d 00 00 00 je 3106c <dfsch__reclose_closure+0xbc>
30fcf: 40 f6 c7 07 test $0x7,%dil
30fd3: 0f 85 87 00 00 00 jne 31060 <dfsch__reclose_closure+0xb0>
/\___/\ dfsch version 0.4.0-dev
( o o ) (rel-0.3.0-937-g451e094) [May 1 2011 15:05:17]
== * == dfsch is free software, and you are welcome to redistribute it
) ( under certain conditions; see file COPYING for details.
]=> (define t (tokyo-cabinet:open-table "foo.tab"))
#<tokyo-cabinet:table 0x2206160 >
]=> (define (print-results idl)
..> (for-each (lambda (id) (write (collection->list (map-ref t id))) (newline)) idl))
#<standard-function 0x21e35f0 print-results(idl)>
]=> (define q (tokyo-cabinet:make-query t))
>>> def singleton(klass):
... inst = klass()
... return lambda:inst
...
>>> @singleton
... class Bar:
... pass
...
>>> Bar()
<__main__.Bar instance at 0x7fea76c054d0>