freenode/lisp - IRC Chatlog
Search
3:59:57
aeth
An object abstraction over this would probably be to get everything that's defined for some ID, and pretend that it's one object so it's easy to do something like e.g. print the object or inspect it in slime. This would be very easy if slots can return and set multiple values. I'm not sure if they can. And if they can, would it break the SLIME inspector?
4:02:21
aeth
That's not that big of an issue because there are two ways to access the 2D arrays, either one slot at a time (like my example where I bind a location.y) or as multiple values
4:04:01
aeth
I may have to define official names for them, though. At the moment any slot names for a slot in a 2D array are only bound at the accessor level, i.e. (location.y location 1) binds (aref location some-index 1) to location.y in a symbol-macrolet not unlike with-accessors
4:04:14
aeth
dmiles: Well, not really, since that would require bounds checking and this is for a game engine.
4:05:39
aeth
dmiles: I defined array-row-of-2, array-row-of-3, and array-row-of-4 as accessors (both to get values and set values). You can use them improperly. If you e.g. (setf (array-row-of-2 some-array-with-length-four-rows 42) (values 1f0 2f0)) it'll just set the two fields. If you do the reverse and do array-row-of-4 on something with length-two rows, it will fail with a runtime error unless safety is 0, which no one should ever use.
4:07:10
Bike
i don't understand what multiple values have to do with slots. you defined some multiple value accessors, no big.
4:08:10
dmiles
aeth: oh, i hear you, you are thinking about wether or not it is sensible to create an accessor
4:08:34
aeth
Bike: If I can abuse the MOP to work somewhat like this as well, I create an alternative interface into the database that's more first-class within the language, so I could have more debugging power.
4:08:59
dmiles
aeth: sensible in the sense that there is at least some translation in which debugging would be livable
4:09:28
Bike
i don't see what multiple values adds to debugging. they're not fun to debug, in my experience.
4:09:51
Bike
if you were dedicated, you could probably define an alternate standard-object with a completely overriden allocate-instance so that slot values are stored in an array or whatever.
4:10:34
jasom
anyone know of a decent library for making a fininte state machine in lisp? something like a LABELS inside LOOP would be nice. Mutually recursive functions work with proper optimization settings, but I've been told not to do that in common lisp :P
4:11:06
aeth
Bike: well, I was wondering if I could make a similar interface through CLOS, although I guess I *can*, just as accessors, rather than as slots, and the slots would have to use the direct one-value accessor.
4:11:31
Bike
yes. that's what i'm saying. i don't understand why you want multiple value slots when you already have multiple value accessors.
4:12:41
aeth
The main thing I'd want from CLOS is a way to see an ID as an object rather than a bunch of arrays that mostly contain irrelevant values. It doesn't even need to be efficient, since ideally it'd only be used for debugging purposes like defining a print-object.
4:13:48
jasom
nyef`: well I find tagbody looks good for writing out longhand, but labels with a loop has the logic inside-out and is problematic to indent automatically.
4:14:39
aeth
Bike: Yes, but what I would want is a CLOS object that can have slots called e.g. location.x, location.y, location.z, etc. And then if I inspect that object, location.x will show the value of (aref location (id-to-index entity-id) 0) and location.y would show the value of (aref location (id-to-index entity-id) 1) etc.
4:15:30
aeth
It is an entity's position in the world. 3 single-float values, normally. Some systems use double-float if the worlds are massive.
4:16:15
Bike
so you want an object that doesn't actually store its position, it just stores an index into some global array.
4:18:04
aeth
But I would like to be able to use the SLIME inspector, have defined print-objects, etc.
4:18:18
dmiles
having slots is so you can at least feel like you are holding an object in your hands?
4:18:22
aeth
i.e. I would like to make a CLOS object whose slots are accessors, if that's at all possible
4:19:59
dmiles
having slots is so you can at least feel like you are holding an object in your hands? I see yes.. so you can use things like print-object can even change values on the target if needbe
4:20:06
jasom
" defstruct without a :type option defines a class with the structure name as its name. The metaclass of structure instances is structure-class. "
4:20:28
aeth
Bike: I can have an entity with the label cube which is mapped to the ID 42 which is mapped to the index 37 (well, I haven't written the third part quite yet, but that's coming very soon... at the moment IDs are the indices). The entity doesn't exist. There are many arrays.
4:21:49
Bike
perhaps i should be more explicit. there is no need for you to use print-object for printing some non-object. you can have your own printing function to print it. this is no loss to you since nothing could possibly call print-object on your object because there is no object.
4:22:28
Bike
if you wanted, you could define a kind of proxy object that just stores 37 and defines a bunch of accessors, but you haven't, which presumably you have some reason for.
4:22:35
aeth
Well, I could (if I modify my query system to allow for an "all") write something called print-entity that queries all of the places where 37 is a valid index, and prints it as if it's one object.
4:24:58
aeth
But I'm wondering how deep I can go in making a proxy object, which could have uses where the query macro(s) fail, although the performance would probably not make it anything useful outside of debugging.
4:25:27
Bike
you can obviously define a proxy object and define a print object method on it that prints whatever you want, and the object having data in its slots is immaterial.
4:25:28
aeth
If I could actually have proxy slots instead of proxy accessors, I could use the SLIME inspector itself.
4:26:40
Bike
i think swank has some kind of interface you can customize, but it might not be exported.
4:28:00
aeth
It would be very useful (more useful than just a print, which I can do through a query macro with some small changes) if I could somehow inspect an object and see the slots as if it was an object, even though they're just slots in various arrays.
4:35:10
aeth
Bike: thanks, looks like going beyond that it's defmethod all-slots-for-inspector ((object standard-object))
4:36:06
Bike
shorter version: if you want to inspect weird things, you don't need to parlay that into sweeping ideas about clos
4:38:56
aeth
It looks like swank uses the MOP, so if the MOP is powerful enough to change the concept of what a slot is, I should be able to make it SLIME inspectable without having to modify swank. i.e. if I can make a slot a call to an accessor (well, actually two since I don't actually know what the index is, only what the ID is)
4:40:59
aeth
The inspector is just what I know would be useful now. If I use the MOP, it's possible that there's a future use to the object abstraction.
4:49:22
aeth
One thing I could do that's probably easier and even less efficient is to have a query object, i.e. query into an object or something.
4:49:42
aeth
This is probably the first thing that I would have thought of in a less powerful language without a MOP
4:55:12
aeth
i.e. instead of having the object constructed via the MOP to directly access the slots, I construct an object in a similar way that I would do something like print-entity, except returning an object with populated slots from the accessors instead of writing to a stream.
4:58:36
tko
hmm I just started CL a few minutes about coming from Clojure but I'm curious what this convo is all about
4:59:00
tko
I don't know anything about MOP / CLOS, although CLOS is one of the first things I wanted to look into with common lisp
5:01:24
aeth
tko: I have a very elaborate data structure. Because it's elaborate, it's not easy to inspect the contents in an intuitive way.
5:02:09
aeth
One way to inspect the contents in an intuitive way would be to allocate a temporary standard-object (i.e. an object that's created with a CLOS defclass) that somehow has the same contents because those are trivial to inspect.
5:03:24
aeth
Things are inspected through SLIME, the CL IDE for Emacs. swank is the protocol that SLIME uses to talk to a running CL.
5:04:17
aeth
Technically, other editors and IDEs can write their own SLIME-like thing using swank, but nearly everyone programs CL in Emacs+SLIME.
5:05:35
tko
so the temporary standard object would be like an object that contains all the values of your structure (or less) and that is organized in a way thats easier to read or interpret?
5:06:30
aeth
It would combine all of the pieces of data that represent an entity into one object. Which would be 1/2500 of the data structure, if it's filled to the arbitrary constant cap I set for it.
5:09:26
aeth
I think Bike's alternative approach would be to define methods that swank uses that are ultimately used by the SLIME inspector, i.e. create new things that swank will dispatch on as various relevant defmethods
5:09:40
nyef`
aeth: Or you could "just" declare for SBCL and unportability and implement an INSPECTED-PARTS method.
5:10:54
Bike
i mean, with the whole novel clos thing you're still relying on the inspector working in some particular way with slots
5:11:21
aeth
Would that work, though? I want to inspect one particular ID stored in a large data structure. A simpler example would be e.g. inspecting one node in a tree by providing the tree and what to look up into the tree.
5:13:11
aeth
But since it's only used for debugging it doesn't need to be efficient. I could just allocate an object from a query and then inspect that. Although then if I'm inspecting it live I'd have to do some trick to avoid filling the heap.
5:15:08
aeth
Bike: Hmmm... Or... I could be really lazy and make an object that encapsulates two objects...
5:15:46
Bike
so that you can take advantage of all the standard customization facilities that arne't real, makes sense to me
5:16:24
aeth
Bike: however non-standard things are, my own solution would be even more non-standard and even less supported
5:17:16
Bike
well, my main advice is to try something out rather than write a dissertation over the course of two hours, i'd do well to remember that
5:24:10
dmiles
aeth: well i am glad that I was correct in imagining that you were copying a reference setf-able place
5:29:36
aeth
dmiles: Well, I'm making local bindings to arrays (which does not copy the arrays themselves), and then using symbol-macrolet over accessors that are too complicated for with-accessors (such as aref or my custom array-row accessors)
5:31:40
dmiles
you know for these synthesized objects you are thinking about there is a system for synchronising them.. https://bitbucket.org/tarballs_are_good/cl-locatives
5:32:37
dmiles
you point the object at your proxy and your real thing.. when your proxy changes.. so does the real thing
5:33:03
earl-ducaine
Out of fairness to other CLs and the libraries in the Quicklisp repo, the problem that I described as 'dependancy hell' (for ccl) was only that I was using the wrong CLX library. Once I installed a compatible one using ASDF everything else worked.
5:34:28
aeth
with accessors is the thing that can turn (foo some-object) into foo, so you can (setf foo 42) and it's really (setf (foo some-object) 42)
5:36:10
dmiles
hrrm the package i was thinking of was actually was more in depth.. pjb suggested it to me the other week)
5:36:47
aeth
I took the recommended way of implementing with-accessors and modified it to work on (aref a 42) (aref a 42 0) and my custom array row accessors
6:10:05
aeth
dmiles: proxy with-accessors? as in an object that can call with-accessors (or, actually, with-entity-accessors in this case) on itself every second or something, to keep a somewhat up to date picture of what's going on? Could become a threading mess, though.
14:23:04
ebzzry
I have `sbcl --load quicklisp.lisp --eval '(progn (quicklisp-quickstart:install) (let ((ql-util::*do-not-prompt* t)) (ql:add-to-init-file) (sb-ext:quit))'` but it doesn’t wokr.
14:32:04
scymtym
ebzzry: try sbcl --load quicklisp.lisp --eval '(quicklisp-quickstart:install)' --eval '(let …)' --quit