freenode/#lisp - IRC Chatlog
Search
21:06:31
sjl
You can use a dotted list to do the equivalent of &rest, and you can use NIL to ignore values, but it's not full destructuring-bind level of power.
21:07:44
dxtr
Well if it's not possible it's not possible. Just figured that it doesn't hurt to ask so I don't re-invent stuff that exists
21:09:28
sjl
dxtr: it's still not clear what you're trying to do. That example will return '((1 2) (2 3) ... (9 10) (10 nil)). Is that not what you want?
21:09:48
makomo
dxtr: i'm not completely sure what you want to do. the example you gave above evaluates without errors. i was expecting an example where you provide the destructuring, the input and the values of A and B you want
21:12:26
Bike
well, you can't get a bunch of variables (like A and B) from a number, you'd get a subsequence
21:12:36
sjl
There's no way to do that kind of thing with destructuring, no. You could do something like:
21:12:52
sjl
(defun ngrams (n list) (loop :for x :on list :repeat (- (length list) n) :collect (take n x)))
21:13:35
Bike
you could do (loop for sublist on list by (lambda (l) (nthcdr n l)) for real-sublist = (subseq sublist 0 n) ...work with real-sublist here...)
21:13:49
makomo
dxtr: as mentioned, you can't really do that with destructuring. the problem is that X is a run-time thing, while the destructuring specification has to be known at compile-time, at the moment you write the code (and "tricks" like &rest don't really help here)
4:22:25
aeth
So this seems to work as a way to run something in another thread but the consing quickly adds up so it's clearly not supposed to be done in a big loop: (defun my-thread () (loop (bt:with-lock-held (*world*) (bt:condition-wait *hello* *world*)) (format t "Hello!~%")))
4:23:49
aeth
Is there a better way to tell a thread to wait to resume until it's told to do so by another thread? One that's more loop-friendly.
4:28:51
pjb
aeth: condition-wait is the way to do it. However you have to be careful if several threads wait on the same condition, since it's random which will wake on signaling the condition.
4:30:31
aeth
pjb: What I like about condition-wait is that every subthread can be written like a loop, just like the outer controlling loop. What I don't like about it is: (1) it would be tricky to coordinate e.g. 127 child threads since they'd all need their own name to be awken that way
4:31:25
aeth
and (3) in SBCL it appears to cons a decent measurable amount *each* iteration of the loop, so for something that's a quick calculation meant to be run very frequently, this is going to be very suboptimal
4:57:44
emaczen
I'm using cffi:define-foreign-library and cffi:use-foreign-library no differently than I have in the past, but for some reason when I asdf:load-system my system with the foreign-libraries lisp just hangs
4:58:46
emaczen
Strangely, the compilation reports that it has cached the fasl so if I restart, it will successfully load the cached version
5:02:45
emaczen
It looks like the use-foreign-library form is what is hanging (if I comment it out and try asdf:load-system) but even when I leave it in, the forms following are compiled/loaded but it just hangs...
5:49:16
emaczen
Related to what I asked about an hour ago, I decided to try loading my system with my own loader rather than ASDF (my loader doesn't know how to load CFFI, so I used ASDF to load CFFI first before loading my system) and I'm not getting any hangs
6:18:22
PuercoPop
yeah, its an external contrib. (I'm using the Sly port of said contrib. Just expanded a macrolet)
6:20:03
PuercoPop
https://github.com/joddie/macrostep The macrostep repo appears to have the Slime support included
6:28:12
emaczen
What is the correct method to customize when a defclass form is evaluated? I tried ensure-class-using-class with my metaclass being the first specializer, and it works, but only after the defclass form has been evaluated once (which is because of the way ensure-class is defined by default)
6:50:24
emaczen
phoe: I'm reading the definitions of sb-mop:ensure-class and sb-mop:ensure-class-using-class
6:52:10
emaczen
The reason why, is because the metaclass object in (defmethod ensure-class-using-class ((class null) name &rest args &key) ...) has type standard-class
6:53:02
emaczen
I put a break point in the call right above (apply #'make-instance metaclass :name name initargs)
7:12:34
emaczen
The problem is the metaclass argument in ensure-class-using class is a standard-class with the name of my metaclass
7:18:04
emaczen
Before, after I tried what I thought, then I tried make-instance like you originally said haha
8:32:18
schweers
I have a question about DECLAIM. If I put a toplevel form at the beginning of a file, it will affect the compilation of the rest of said file, correct?
8:33:53
jackdaniel
schweers: "As with other defining macros, it is unspecified whether or not the compile-time side-effects of a declaim persist after the file has been compiled. "
8:34:46
schweers
I can’t help it, but this seems like a bad idea. Do you know the reasoning behind this descision?
8:37:15
schweers
This seems to me as if the declaim forms in a library I load (might) affect how my code is optimized. Or did I get that wrong?
8:38:02
jackdaniel
it is unspecified, so they might (just as proclaim and changing reader settings will)
8:39:09
jackdaniel
as of rationale: I can imagine it is for consistency with other macros which are treated specially when toplevel
8:40:22
schweers
I’m not sure which others are treated this way, can you give an example off the top of your head?
8:43:04
jackdaniel
i.e defmacro, in-package and such, they affect compiler even without being put in eval-when
8:43:45
schweers
Ah, and there too it is unspecified when the effect ends? Well, I guess not for defmacro, but for in-package?
8:51:04
jackdaniel
this is a tricky one, in-package setf *package*, but package is bound for each file
9:03:35
makomo
"(...) nor is it specified whether they are available in subsequent compilation units or subsequent invocations of the compiler."