Search found 40 matches

by macrolyte
Sat Jun 28, 2014 9:05 am
Forum: Common Lisp
Topic: Question on Arrays Code
Replies: 1
Views: 2834

Question on Arrays Code

Hi. I was looking at implementing some matrix functions and have some questions on style and efficiency. My use of arrays is limited, so it took me a few hours to come up with this : (defun mult-arrays (&rest arrays) (let ((temp-array (make-array (array-dimension (car arrays) 0) :initial-element 1))...
by macrolyte
Sat Jun 14, 2014 3:35 pm
Forum: Common Lisp
Topic: Self Reference in CLOS
Replies: 2
Views: 3773

Re: Self Reference in CLOS

pjstirling wrote:Since CLOS methods require that the instance is passed to the method, I don't really understand why you would want this?
I was toying with some ideas on constructors, and ways to distinguish between multiple running instances, for now. It seems safe, I just want to be sure. Thanks again.
by macrolyte
Sat Jun 14, 2014 2:44 pm
Forum: Common Lisp
Topic: Self Reference in CLOS
Replies: 2
Views: 3773

Self Reference in CLOS

I haven't seen an example of a class which can reference itself, so is it wise/safe to do this? : (defclass self−reference() ((name :accessor acc−name :initarg name :initform ’()) (func :accessor acc−func :initarg func :initform ’()) (self :accessor this ;; should this be a reader? :initar...
by macrolyte
Thu Jun 12, 2014 3:27 pm
Forum: Common Lisp
Topic: Bordeaux Threads Questions
Replies: 13
Views: 15024

Re: Bordeaux Threads Questions

pjstirling wrote:SB-CONCURRENCY has mailboxes, which appear to do what you are intending.
REALLY??!! I'll take a look now. Thanks!
by macrolyte
Tue Jun 10, 2014 5:47 pm
Forum: Common Lisp
Topic: Bordeaux Threads Questions
Replies: 13
Views: 15024

Re: Bordeaux Threads Questions

Thanks jcbeaudoin, I thought that might be the case... anyways here is what I have done so far: (defparameter *test−lock* (bt:make−lock)) (defparameter *test−cond* (bt:make−condition−variable)) (defparameter *queue* ()) (defparameter *lock0* (bt:make−lock)) (defparameter *cv* (bt:make−...
by macrolyte
Sun Jun 08, 2014 4:10 pm
Forum: Common Lisp
Topic: Bordeaux Threads Questions
Replies: 13
Views: 15024

Re: Bordeaux Threads Questions

A couple more questions (please see code below): ;; is this a correct way for this? (defun test() ;; Is the general pattern to use a defun? Couldn't you use the lambda body in the thunk in make-thread just as well? (bt:with-lock-held (lock) (do-stuff) (do-more-stuff) (bt:condition-wait cv lock))) ;;...
by macrolyte
Sun Jun 08, 2014 3:33 pm
Forum: Common Lisp
Topic: Disable compiler warnings for special variables
Replies: 3
Views: 4567

Re: Disable compiler warnings for special variables

Did you search for "disable compiler warnings sbcl" ?:
I found all this in under 10 minutes (plus my lousy typing...)
by macrolyte
Sat Jun 07, 2014 3:59 pm
Forum: Common Lisp
Topic: Bordeaux Threads Questions
Replies: 13
Views: 15024

Re: Bordeaux Threads Questions

(defparameter *lock* (bt:make-lock)) (defparameter *cv* (bt:make-condition-variable)) (defparameter *place* ()) (defun try-with-lock-held () (bt:make-thread (lambda() (bt:with-lock-held (*lock*) ;; (setf *place* "done") (bt:condition-notify *cv*))) :name "with-lock-held")) ==>TRY-WITH-LOCK-HELD (tr...
by macrolyte
Sat Jun 07, 2014 2:28 pm
Forum: Common Lisp
Topic: Bordeaux Threads Questions
Replies: 13
Views: 15024

Re: Bordeaux Threads Questions

(defparameter *lock* (bt:make-lock)) (defparameter *cv* (bt:make-condition-variable)) (defparmeter place ()) (defun try-with-lock-held (place) (bt:make-thread (lambda() (bt:with-lock-held (*lock*) ;; should acquire AND release lock? (setf place "done") (bt:condition-notify *cv*))) :name "with-lock-...
by macrolyte
Thu Jun 05, 2014 6:05 pm
Forum: Common Lisp
Topic: Bordeaux Threads Questions
Replies: 13
Views: 15024

Bordeaux Threads Questions

Hey. I'm working through the concurrency chapter in Lisp Outside the Box found here . I'm using Bordeaux threads instead of Allegro CL. (defvar *k0* nil) (setf *k0* (bt:make-thread ;; capture returned thread object (lambda() (unwind-protect (loop) (print "Goodbye" #.*standard-output*))) :name "Say g...