This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; As part of the implementation of Virtua's [1] object system I need | |
;; a facility called DEFINE-CONSTRUCTOR that defines a convenient | |
;; function for creating an instance of a class and setting its slots. | |
(define-constructor make-person Person (firstname lastname)) | |
;; should be operationally equivalent to | |
(define make-person | |
(lambda (firstname lastname) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro swap (a b) | |
#`(let ((tmp ,b)) | |
(setq ,b ,a) | |
(setq ,a tmp))) | |
(let ((x 1) (tmp 2)) | |
(swap x tmp) | |
(assert (and (= x 2) (= tmp 1))) | |
(swap tmp x) | |
(assert (and (= x 1) (= tmp 2)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(10:56:17 PM) msimoni: also: ein lisp mit CS verwendet native exceptions ja für BLOCK/RETURN-FROM | |
(10:56:30 PM) Chris Neukirchen: ok | |
(10:56:48 PM) msimoni: ich habe (js-throw obj) === throw obj | |
(10:57:22 PM) msimoni: und ($js-try handler body-expr) === try { eval(body-expr) } catch(e) { apply(handler, e) } | |
(10:57:35 PM) msimoni: das sind die primitives in der VM | |
(10:57:51 PM) msimoni: darauf baue ich BLOCK/RETURN-FROM so: | |
(10:58:06 PM) msimoni: | |
(def Block-Escape (make-class ())) | |
(def make-block-escape (lambda () (make-instance Block-Escape))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Try pasting this into the Virtua REPL at http://manuel.github.com/virtua/ | |
;; (better use V8 - stack trace printing is quite slow atm) | |
(defun foo (a b c) (bar b)) | |
(defun bar (x) (quux x)) | |
(defun quux (x) (print-stack-trace (stack-frame))) | |
(foo 1 2 3) | |
#[Native-Combiner] () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (call/cc f) | |
(continuation-capture | |
(lambda (k) | |
(f (lambda (val) | |
(continuation-graft k (lambda () val))))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; See http://okmij.org/ftp/continuations/implementations.html#dynamic-wind | |
;; and http://axisofeval.blogspot.com/2012/08/delimited-continuations-do-dynamic-wind.html | |
;; Slight trick here: use identity of yield-record-tag function as the actual tag | |
(define (yield-record-tag) yield-record-tag) | |
(define (make-yield-record v k) | |
(list yield-record-tag v k)) | |
;; Yield simply aborts up to the generator's caller, delivering to it | |
;; the yielded value and the continuation for resuming after the call |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Error monad from Filinski's "Representing Monads" | |
(define *default-prompt* (make-prompt)) | |
(define (reflect m) (shift *default-prompt* k (ext k m))) | |
(define (reify t) (push-prompt *default-prompt* (unit (t)))) | |
(define-record-type Success | |
(make-success a) | |
success? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
(define-class foo (make-foo)) | |
(define-class bar (make-bar)) | |
(define-generic (m obj)) | |
(define-method (m (f foo)) 1) | |
(define-method (m (b bar)) 2) | |
(print (m (make-foo))) ; => 1 | |
(print (m (make-bar))) ; => 2 | |
(define-method (m (f foo)) 3) | |
(print (m (make-foo))) ; => 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Wat Sleeping Demo</title> | |
<script type="text/javascript" src="../../wat.js"></script> | |
</head> | |
<body> | |
<h1><a href="https://github.com/manuel/wat-js">Wat</a></h1> | |
<script type="text/javascript"> | |
var code = | |
["begin", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# source : http://code.google.com/p/natvpn/source/browse/trunk/stun_server_list | |
# A list of available STUN server. | |
stun.l.google.com:19302 | |
stun1.l.google.com:19302 | |
stun2.l.google.com:19302 | |
stun3.l.google.com:19302 | |
stun4.l.google.com:19302 | |
stun01.sipphone.com | |
stun.ekiga.net |