libera/#clasp - IRC Chatlog
Search
12:48:36
paulapatience
I haven't been contributing much because I haven't had the chance to use Clasp much yet. I just need to finish wrapping a C++ library so that I can start using it. Clasp is the reason I started using Common Lisp again, so I am definitely planning to contribute more.
13:22:21
paulapatience
Ok, I'm trying to implement an extensible sequence for an MFEM array, specifically make-sequence-like
13:23:07
paulapatience
The SBCL manual's section on extensible sequences says that if neither initial-element nor initial-contents are provided, the resulting sequence's elements should be identical to the elements of the provided sequence.
13:23:28
paulapatience
However, Clasp does not do that; if neither are provided, it takes the initial-element as being NIL
13:24:26
paulapatience
Or whatever the default initial-value should be, like 0d0 for a double-float vector
13:26:00
paulapatience
Incidentally, Shinmera's example in trivial-extensible-sequences also suffers from this
13:33:45
paulapatience
In fact, though, SBCL's behavior is the same as Clasp's. So maybe its manual is wrong.
13:49:28
paulapatience
I guess making sure make-sequence-like returns the same list is not really necessary, since subseq can accomplish the same thing. It might even be wasteful depending on the operation.
13:52:09
paulapatience
But Rhodes' code examples do not actually correctly check for initial-element being provided
13:52:28
paulapatience
It checks if both are provided, or if initial-contents is provided, but then assumes if those were not the case, that initial-element was provided
13:55:57
paulapatience
Actually, that makes sense for in the context of the paper, since it isn't specified that the result should be the same as the input
13:58:01
bike
make-sequence-like copying the elements of the input sequence is weird to me, since the input sequence is basically just a prototype
13:58:13
yitzi
Yeah, keep in mind that only SBCL and Clasp support extensible sequences. bike added it to Clasp, so he may have reused the SBCL implementation.
14:03:55
yitzi
Hmmm. So maybe we should see if we can add it to ECL. That would leave only CCL as the next most likely. Good luck getting it into CMUCL.
14:06:03
yitzi
I find that the biggest problem is that it only has green threads and building it is not easy.
14:14:26
paulapatience
adjust-sequence does not signal an error when initial-contents has an inconsistent length
14:14:50
paulapatience
The paper doesn't mention anything about signaling an error in that situation, though
14:15:17
paulapatience
I find it inconsistent with the behavior of make-sequence-like and make-array, though
14:17:06
paulapatience
Also, why should it not signal an error if initial-element and initial-contents are both provided
14:20:36
paulapatience
I think what's more likely in the case of the SBCL manual is that the text for make-sequence-like was copy-pasted from adjust-sequence
15:20:01
paulapatience
I'm wrapping an mfem::Array<int>. I just implemented length, elt, (setf elt), make-sequence-like and adjust-sequence for it.
15:22:28
paulapatience
Do I need to make a new class that subclasses INT-ARRAY and SEQUENCE, and appropriate converters for to_object and from_object to be able to pass instances to functions expecting just mfem::Array<int>?
15:26:05
paulapatience
I tried using (cleavir-stealth-mixins:add-mixin 'sequence 'int-array) but it complains about changing the metaclass
17:01:06
drmeister
This is a horrible and interesting story: https://www.youtube.com/watch?v=0pT-dWpmwhA
17:17:41
drmeister
I see. I watched that one story and now my youtube landing page is full of stories about it.
17:48:13
bike
yeah, i saw. honestly, i'm not sure. we do that for the built in classes specially as part of CLOS boot.
17:48:45
bike
https://github.com/clasp-developers/clasp/blob/main/src/lisp/kernel/clos/hierarchy.lisp#L295-L298
17:49:21
bike
like, on the C++ level, the SimpleVector_O classes actually aren't C++ subclasses of any Sequence_O, as i recall
17:58:33
paulapatience
Well, I could make a wrapper class on the Lisp side with as only element the raw C++ class, and then forward the appropriate function calls in the implementation of the extensible sequence protocol
18:01:07
drmeister
We have Sequence_V. It's not a real class like Array_O. The problem is we can't use C++ multiple inheritance because implementing GC with multiple inheritance is too difficult.
18:26:32
drmeister
Ok, that's what I thought. There is a class called Sequence_V. It's used in template programming to mimic some of what we need in C++ to get sequences to work.
18:26:32
paulapatience
The C++ class is int-array, and I've made an int-array-sequence which has an underlying-array slot
18:27:02
paulapatience
The only annoying thing is that on the Lisp side I have to be careful not to pass the int-array-sequence as argument to a function expecting an int-array
18:28:34
paulapatience
I would be fine with automatically converting to and from Lisp types, but sometimes the arrays could be huge
18:33:20
drmeister
I have to do some other stuff for the next couple of hours. I could talk about this more later.
18:33:57
drmeister
You are entering into a problem that I have been wanting a good general solution but I haven't completely implemented it yet.
18:39:00
paulapatience
Basically (defclass int-array-sequence (sequence) ((%underlying-array :type int-array)))