This file contains hidden or 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
--- | |
First 'scripting' excursion in Foolang! | |
Input is file containing stuff like this: | |
CLOSURE 1: | |
args: ["out"] | |
body: | |
(self | |
displayOn: out) |
This file contains hidden or 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
;;;; In response to: | |
;;;; | |
;;;; http://www.reddit.com/r/lisp/comments/3710zq/directed_procrastination_backtracking_with_the/ | |
;;;; http://directed-procrastination.blogspot.se/2011/05/backtracking-with-common-lisp-condition.html | |
;;;; | |
;;;; Demonstrating why one should not use conditions for this kind of stuff, | |
;;;; instead using the dynamic binding and unwinding facilities on which the | |
;;;; condition system is built. The author's backtracking system doesn't compare | |
;;;; badly to Screamer because his is simple: it compares badly because using | |
;;;; conditions is a bad match for the task. |
This file contains hidden or 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
;;;; By Nikodemus Siivola <[email protected]>, 2012. | |
;;;; | |
;;;; Permission is hereby granted, free of charge, to any person | |
;;;; obtaining a copy of this software and associated documentation files | |
;;;; (the "Software"), to deal in the Software without restriction, | |
;;;; including without limitation the rights to use, copy, modify, merge, | |
;;;; publish, distribute, sublicense, and/or sell copies of the Software, | |
;;;; and to permit persons to whom the Software is furnished to do so, | |
;;;; subject to the following conditions: | |
;;;; |
This file contains hidden or 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
(defconstant +foo-count+ (ash (sb-int:power-of-two-ceiling | |
(* 8 sb-vm::*backend-page-bytes*)) | |
-1)) | |
(defconstant +foo-mask+ (1- +foo-count+)) | |
(defun foo-duplicates (list) | |
(let ((bitmap (make-array +foo-count+ :element-type 'bit)) | |
(results nil)) | |
(declare (dynamic-extent bitmap)) |
This file contains hidden or 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
;;; If a fasl was stale, try to recompile and load (once). | |
(defmethod asdf:perform :around ((o asdf:load-op) | |
(c asdf:cl-source-file)) | |
(handler-case (call-next-method o c) | |
(sb-ext:invalid-fasl () | |
(asdf:perform (make-instance 'asdf:compile-op) c) | |
(call-next-method)))) | |
This file contains hidden or 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
;;;; Inspired by http://directed-procrastination.blogspot.com/2011/11/broken-weight-problem.html | |
;;;; | |
;;;; An example of using a generator to make your nondeterminism read nice. | |
(in-package :screamer-user) | |
(defun a-subset (set) | |
"Non-deterministically returns all the subsets of SET, including the empty set NIL." | |
(when set | |
(either |
This file contains hidden or 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
(with-lock (*lock*) | |
(unwind-protect | |
;; Calls CONDITION-WAIT on the lock | |
(foo) | |
;; If FOO unwinds, the lock it might not be held here! | |
(bar))) |
This file contains hidden or 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
(defun condition-wait (waitqueue lock &key timeout) | |
(release-lock lock) | |
(let ((self *current-thread*)) | |
(unwind-protect | |
(progn | |
(enqueue self waitqueue) | |
(when (wait-for (eq self (queue-first waitqueue)) | |
:timeout timeout) | |
(grab-lock lock :timeout timeout))) | |
(delete-from-queue self)))) |
This file contains hidden or 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
Context from IRC logs for future reference. | |
[12:36] <kushal> nikodemus, can you point me to some tutorial on debugging on sbcl ? | |
[12:37] * andreer ([email protected]) has joined #quicklisp | |
[12:38] <nikodemus> kushal: no really good ones actually exist at the moment. i'm planning on writing one before the year is out, but... in the meanwhile, i can give some pointers | |
[12:38] <nikodemus> a couple of questions: is this a general question, or do you have a specific issue you need to debug? | |
[12:39] <kushal> right now , general, managed to debug the specific issue somehow :) | |
[12:39] <nikodemus> ok. are you using slime? | |
[12:39] <kushal> nikodemus, yes and no both | |
[12:40] <nikodemus> good. :) |