freenode/#lisp - IRC Chatlog
Search
16:17:13
alandipert
i am using lisp for some adventofcode problems, i'd much appreciate any thoughts or feedback on my solution for today's puzzle http://adventofcode.com/2017/day/6 https://github.com/alandipert/advent-of-code-2017/blob/master/day06.lisp
16:17:41
ercourisjm
Bike: Can you explain exactly what is going on then? I'm not doubting your opinion, just trying to understand
16:18:21
Bike
The CL package doesn't even have a symbol CONSTANT (try (find-symbol "CONSTANT" "CL"))
16:18:57
Bike
defconstant makes constant bindings. there is no way to alter a constant binding portably. you can't shadow them. that's what a constant is.
16:19:05
_death
alandipert: looks similar to mine.. https://gist.github.com/death/02e716211827683c48a9c580348fd5a5
16:26:47
mercourisj
I've asked this quesiton awhile ago and looked through the IRC logs to try to find it but could not, what's the way to list all of the variables defied by defvar?
16:27:55
Shinmera
Here's how to do it on some implementations. https://github.com/Shinmera/staple/blob/master/symbols.lisp#L198
16:30:59
Younder
Look Lisp allows you to enter a string for documantaion. It is however optional and should be. But if the interface is documented it should be possible to figure out what function you want.
16:32:23
whoman
.... asinine would be typing like a sloppy pig and expecting everyone to mentally compensate
16:32:49
jmercouris
I'm going to stay offline until my connection stops breaking, sorry for the lurker spam
16:32:54
whoman
and of course usually those times being the times under emotion or stress or anger, which never leads to clarity or understanding.
16:35:14
whoman
it is understood that listing symbols is how we inter-face with lisp. which is interesting because 'graphical' user inter-faces are probably less meaningfull due to not being as linguistic as text/repl/tui
16:37:29
flip214
I tried to subscribe to the elsconf ML; the confirmation link arrived within a minute, but there's no password or welcome message after ~15 minutes....
16:46:49
flip214
ah, sorry for the noise. there's no automatic welcome mail, but "Awaiting moderator approval"
18:04:56
Xach
borodust: but for quicklisp, all new stuff is added, and the old stuff stays in place, and new dists point to a mix of old and new archives
18:05:27
Xach
so one distinfo.txt is updated to point to the new system / release indexes, but the old ones stay in place pointing at older stuff
18:05:41
Xach
but there is a second distinfo.txt that never changes that matches up to that particular set of stuff
18:07:01
Xach
borodust: http://blog.quicklisp.org/2011/08/going-back-in-dist-time.html has the guide
18:49:21
phoe
I want to use a hash table for storing vectors of 16 (unsigned-byte 8)s. How should I do that? EQUALP?
18:55:06
pjb
phoe: yes, you have to use equalp. Notice that if they were vectors containing strings, strings would be compared case insensively.
19:22:03
gendl
Hi, if I have an error object in a variable, how can I actually "throw" that error and land in the debugger?
19:24:35
gendl
I have an existing handler-case, I want to keep it mostly the same, but just have it signal the error right now for debugging purposes.
19:24:45
jasom
gendl: handler-bind will automatically resignal if you don't have a non-local exit; this is one of several differences between bind and case
19:25:22
Bike
jasom: this is slightly inaccurate- rather than resignalling, it just doesn't stop the existing signaling from continuing
19:25:25
jackdaniel
handler-bind doesn't unwind the stack (important note if you are interested in a backtrace)
19:26:53
jackdaniel
nb, if you want to have backtrace and actually handle the error, you want handler-bind inside handler-case ;)
19:27:00
jasom
gendl: for logging backtraces http://shinmera.github.io/dissect/ has a pretty good out-of-the-box experience; you can literally just bind #'dissect:present and be done.
19:27:52
jasom
gendl: handler-case will give you the backtrace for the scope in which the handler-case appears (the stack has already unwound to there by this point) handler-bind will have available the stacktrace at the point of the signal (the stack has yet to be unwound)
19:29:03
Shinmera
As jasom mentioned, with dissect you can capture the stack information and pass it around as you want.
19:29:30
jasom
this is also why handler-bind doesn't silence the error; you need to manually unwind the stack (e.g. throw) , wherase handler-case has already unwound the stack for you.
19:42:49
k-stz
In 64bit sbcl, fixnum are of size 2^63, this can be verified by adding `most-positive-fixnum' and `most-negative-fixnum'. That leaves a single bit (63+1) to be the lowtag identifying the type in memory.
19:42:52
k-stz
I try to understand how a single bit suffices for this, also reading the sbcl internals talks about lowtags. Where memory is dword (2x64bit) alligned and the least significant, low, 4bits of that alligned memory is used for type information.
19:45:55
k-stz
in sbcl all lips objects have type information in memory, so should't there be more bits to distinguish them all
19:49:33
jsnell
k-stz: xxx0 are all fixnums; xxx1 are types of other values, with 3 bits to identify further
19:58:08
jsnell
I guess looking at https://github.com/sbcl/sbcl/blob/master/src/compiler/generic/early-objdef.lisp would be a useful thing to look at
20:00:19
k-stz
So if i understand correctly: every pointer that starts with a 0, is identified to point to a fixnum, else the next 3 bits are read to identify other types. Now these 4bit-tag are already part of the pointer to the object in the lisp-heap, because they are dword aligned, the pointer doesn't need the lower 4 bits to distinguish the 16bytes within.
20:02:17
sjl
k-stz: ending with a 0 doesn't mean it points to a fixnum -- it means the fixnum is immediately encoded in the other bits
20:02:50
k-stz
sjl: ah that makes sense! because fixnums are supposed to guard against heap allocation
20:14:06
k-stz
that seems clever to me, is that common implementation practice? I guess the C malloc()/free() couple implementation might use those tricks too
20:15:12
pjb
In one or two old implementation, the type tag was relatively to a memory page, so all the object allocated in a given page were of the same type. But AFAIK, all implementations had immediate values, for optimization.
20:15:29
sjl
k-stz: it's been common/around since 1966 https://www.snellman.net/blog/archive/2017-09-04-lisp-numbers/
20:15:51
pjb
Since the start, the first LISP implementation used this trick, which was natural on the 7090.
20:16:19
pjb
Actually, one could say the 709/7090 was a lisp machine; it even had a EVAL I mean, XEC instruction!
20:16:52
sjl
pjb: do you have a source for that? the post I linked says disagrees that lisp 1/1.5 did it, and cites their manuals
20:18:22
sjl
sure. but according to the manuals, lisp 1/1.5 didn't do it, even if it was around beforehand
20:22:12
osune
I'm looking at database bindings for storing a little bit of data (3 - 4 relational tables ; ~ 300 rows each ). I would go for cl-sqlite but I've seen rucksack(http://quickdocs.org/rucksack/ ), too. Has somebody experience with this?
20:24:38
jsnell
pjb: yes, those are the exact sources that show that those Lisp implementations did not encode immediate values in pointer values via tagging
20:27:45
jsnell
pjb: you have a very curious definition of immediate, I guess. a number in Lisp I is four conses + a heap-allocated raw value
20:35:43
phoe
osune: that's not a lot of data, rucksack might be able to help you here if you're looking for a portable solution.
21:03:11
felideon
phoe: on a cursory look, planks seems to abstract the rucksack transactions and serialization stuff.
21:04:07
felideon
osune: so if your 4 tables map nicely to CLOS objects, planks might be worth a shot.
21:05:18
osune
planks didn't provide a tutorial / manual / docstrings or i missed them all ; so I was unsure what it provides
21:06:13
felideon
osune: seems like https://github.com/drewc/planks/blob/master/src/persistent-objects.lisp is where the magic happens.
21:06:50
felideon
I'm assuming you want to inherit PERSISTENT-STANDARD-OBJECT when you create your classes.
21:08:25
osune
you are assuming wrong cause I have no idea what you are talking about ! This is my first dip into persistance in common lisp beside from "write it to a file", so this symbol is unkown to me.
21:10:16
felideon
osune: no worries, I mispoke. I should have said 'I would imagine having to inherit'
21:13:04
osune
ahh I see. I think I start to understand the rucksack way first, from there I hope to understand what problem planks tries to solve. Thanks for your help
21:16:03
osune
I think this is to heavy weight for my current usecase. But I keep it in mind. thanks
21:21:48
felideon
osune: I see the tutorial now. I was wondering why class definitions had to be wrapped in transactions and the answer is in there.
21:22:37
felideon
osune: If you want another simple example, I also played with rucksack a few years ago, based on the tutorial. https://github.com/felideon/cluckin-sack/blob/master/cluckin-sack.lisp
21:41:17
jmercouris
I need to basically make autocomplete for my describe-symbol function in my browser and I was going to limit it to *earmuff* symbols, so I wanted to just have a filter
21:43:06
jmercouris
Another thing I've been thinking about lately is the elisp convention of (interactive) within a defun body making the command callable by the command system, is there a way I can achieve something similar in common lisp?
21:43:18
pjb
jmercouris: of course, you can filter the result of (package-symbols), but it would be faster to filter while do-symbols, or even, to use apropos-list.
21:43:40
pjb
(apropos-list "\\*" "CL-USER") #| --> (*read-eval* … *oldest-forward-compatible-asdf-version*) |#
21:43:54
pjb
but it's not conforming, the syntax in the first argument of apropos-list is implementation dependant.
21:45:00
jmercouris
pjb: I'd like to stick with things that are standard across implementations mostly
21:45:35
jmercouris
The thing about the (interactive) within the body of the defun is, I don't understand how I'd get a reference to the current function to register it, somehow I feel like this involves a part of lisp I am unfamiliar with so far
21:46:28
pjb
jmercouris: first, in CL it's written (declare (interactive)). emacs lisp has this special case declaration (interactive).
21:46:46
pjb
jmercouris: then, indeed, non-standard declarations must be processed by your own tools.
21:47:02
pjb
So if you want it to be processed when you evaluate the defun form, it must be your own defun macro.
21:47:30
Bike
you could also have a table of interactivity information, like a hash table where the keys are functions, and have a like (register-interactive function specification-goes-here)
21:49:49
pjb
jmercouris: be careful in macros, try to avoid compilation-time stuff, since it makes it harder to compile-file.
21:50:58
jmercouris
Yeah, I will have to be careful, I've already really messed up my keybinding definition macro I think, I will probably have to redo it and simplify the definition of commands I think
21:51:19
jmercouris
It is way too obtuse, even when I am implementing new keybindings I am having to look up my own syntax
21:53:26
emaczen
I'm getting different results between SBCL and CCL -- what are some common things to check?
21:53:55
pjb
For example, hemlock-interface:defcommand doesn't defun at compilation-time so the compiler cannot know that the command is a function, so if you try to call it in other code compiled, you will get a undefined function warning… This is bad.
21:54:22
pjb
But if you call the make-command function that follows at compilation-time it's bad too…
21:55:10
Xach
emaczen: there are many differences, like in how random state works, the internal time units, etc. What kind of stuff does your code do?
21:58:58
emaczen
At the moment I'm mainly interested in looking at deleting caches or other compiler stuff that would be differnet between SBCL and CCL
21:59:48
Bike
(load (compile-file "whatever.lisp")) will force recompilation and reload of whatever's on your disk.
21:59:53
Xach
whoman: I use it, but I think the built-in stuff in asdf does a lot of stuff and more portably too.
22:01:59
Bike
something to notice here is that the caching is done by asdf rather than by your implementation.
22:02:34
Bike
so what else are you doing? calling any libraries that use implementation details? getting into the package system? what?
22:18:07
Xach
emaczen: it is cruel to string me along like this :( i am dying to know what is going on!
22:19:49
emaczen
Xach: I'm inspecting, trying to find reasonable discrepancies, taking educated shots in the dark!
22:22:47
jasom
emaczen: what happens when you modify literals (if you use backtick you may have literals and not realize it)
22:24:17
jasom
emaczen: if sbcl has no style-warnings then you are less likely to be doing it though.
22:25:02
jasom
and on other implementations it may cause all appearances of '(1 2 3) to behave like '(1) afterwards
22:37:06
emaczen
well, I may have narrowed it down to a specific function of mine, SBCL always returns the same thing, whereas CCL does not and CCLs return value is very different each time...
22:37:26
emaczen
I still have no idea why or which implementation defined feature is causing it, but I'm getting there
22:45:23
emaczen
I will if I really can't figure it out -- if I pasted it, you would need a lot of other code still
23:14:03
jmercouris
I have something like do-symbols in a list of symbols, I want to turn that list of symbols to a list of strings
23:32:13
Xach
it is interesting that you can make a web browser without knowing how to get a symbol name as a string.
23:40:38
jasom
jmercouris: symbols are also string designators so you can just do e.g. (string 'foo)
0:08:06
jasom
blargh. Suggestions for debugging compiler macros? Specifically cffi:foreign-alloc appears to be not expanding to a fast path
0:09:03
Bike
jmercouris: (describe (find-class 'cl-string-match:re-match)) might also be informative.
0:09:10
pjb
Otherwise, to debug it, you can just call it directly (extrating the body in a normal function).
0:10:09
jasom
Bike: well I know it's not expandingas expected because I end up with foreign-alloc on the stac rather than %foreign-alloc
0:17:21
jasom
specifically if you specify initial contents, then it completely loses all optimizations for the type being constant
0:21:40
jasom
I changed my with-foreign-alloc macro to perform the initialization of the memory manually and got a ~1000X speedup
0:24:12
Bike
so with constant type and unconstant but specified count you'd want it to expand to `(%foreign-alloc (* ,count ,(foreign-type-size (eval type))))?
0:24:40
Bike
for initial contents you'd have to once-only the contents and take the length, i guess.
1:06:00
Ober
huh. 'At the request of John McCarthy, Lisp’s creator, no single language that is a member of the Lisp family is to be intended to be the definitive dialect; that is, none is to be called just “LISP.” '
1:29:07
k-stz
another tagged pointer example: (setf *a* (1+ most-positive-fixnum) *b* (1+ most-positive-fixnum)) (eq *a* *b*) => nil, but set *a* and *b* to the same fixnum number then (eq *a* *b*) ==> T ! For sbcl at least, because EQ does pointer comparison. I guess, then, with EQ one can test if a value is represented by an immediate tag pointer
1:41:23
aeth
There's nothing restricting with-accessors to only be for accessors to CLOS objects, is there? It says undefined, but it should in most if not all implementations just be a trivial symbol-macrolet. http://www.lispworks.com/documentation/HyperSpec/Body/m_w_acce.htm
1:45:55
aeth
I'll probably copy the basic symbol-macrolet pattern (and change it slightly) for things that don't necessarily have that slot concept
1:47:01
Bike
if an implementation did actually restrict it to standard objects, you could probably decently make a case against that to them
1:55:11
aeth
Sorry, I mean, you can do (defmethod meh ((foo foo) x) (values foo x)) and that's separate from (defmethod meh (y x) y) with the former being (FOO T) and the latter being (T T). Also, you can do (class-of (make-foo)) and get a structure-class just like you can do (class-of (make-instance 'bar)) and get a standard-class.
1:57:50
Bike
structure objects are certainly instances of a structure class, and structures are described as having slots and accessors. the question is whether with-accessors means the general senses of those terms or the CLOS-specific senses.
1:59:43
aeth
Although I don't think that would apply to my particular case, where I want to use it on a vector struct. I could definitely see this potentially failing.
2:08:49
aeth
It's a bad argument because CL is already inconsistent, so arguing that something would keep things simple and consistent wouldn't really be relevant in an interpretation of the specification.
3:16:21
pfdietz
The random tester appears to have exhausted itself on sbcl. Ah well, the latest campaign was fun while it lasted. Interesting how bugs can breed over time.
3:20:42
pfdietz
"object n. 1. any Lisp datum. ``The function cons creates an object which refers to two other objects.''"
3:23:16
pfdietz
"access n., [...] 2. n. (of a place) an attempt to access[1] the value of the place."
3:24:50
pfdietz
I think (with-accessors ((x car) (y cdr)) (cons 1 2) (values x y)) ==> 1, 2 would be valid.
3:27:03
Zhivago
Sounds reasonable to me -- it looks like a convenience for establishing a symbol-macrolet.
3:28:50
Bike
I thought maybe it could do CLOS-specific optimizations like using more direct slot access when possible, but it seems to pretty specifically invoke the given accessors.
3:30:26
whoman
hmm what is this error from MOP - forward referenced class? not sure how that is going on
3:31:19
Bike
(defclass foo (bar) ()): if bar is undefined when this is evaluated, it's forward-referenced.
3:47:04
loke
pfdietz: CLHS has the following to say about WITH-ACCESSORS: “The consequences are undefined if any accessor-name is not the name of an accessor for the instance.”
3:54:26
loke
aeth: “instance” is defined as: “instance n. 1. a direct instance. 2. a generalized instance. 3. an indirect instance.]
3:54:40
loke
“direct instance n. (of a class C) an object whose class is C itself, rather than some subclass of C. ``The function make-instance always returns a direct instance of the class which is (or is named by) its first argument.''”
3:55:01
loke
“generalized instance n. (of a class) an object the class of which is either that class itself, or some subclass of that class. (Because of the correspondence between types and classes, the term ``generalized instance of X'' implies ``object of type X'' and in cases where X is a class (or class name) the reverse is also true. The former terminology emphasizes the view of X as a class while the latter emphasizes the view of X as a type
3:55:16
loke
“indirect instance n. (of a class C1) an object of class C2, where C2 is a subclass of C1. ``An integer is an indirect instance of the class number.''”
3:56:11
aeth
It definitely looks like with-accessors should work on any accessor with a reader (foo x) and (setf (foo x) new-object) writer, e.g. cxr
3:56:33
aeth
The HyperSpec states all the cxr things are accessors. http://www.lispworks.com/documentation/HyperSpec/Body/f_car_c.htm
3:57:54
loke
aeth: Yes. There is a non-normative note in the documenation for WITH-ACCESSORS suggesting the typical implementation is simply a MACROLET
3:58:41
aeth
accessors are definitely something that the spec gets right imo. reader (foo ...) and writer (setf (foo ...) new-object) symmetry, that can apply to just about anything.
3:59:20
aeth
Isn't everything an instance since everything has a class, and so with-accessors should really just work on everything with a conventional accessor pair?
4:00:02
loke
aeth: That's the thing. That reading is certainly a valid one... Here's the documentation for "accessor":
4:00:23
loke
“access n., v.t. 1. v.t. (a place, or array) to read[1] or write[1] the value of the place or an element of the array. 2. n. (of a place) an attempt to access[1] the value of the place.”
4:01:07
aeth
It seems natural that with-accessors is an abstraction over conventional/idiomatic CL accessors. (And that's probably one reason why it's better than with-slots, it's abstract.)
4:01:21
aeth
Bike: After this conversation, I'm tempted to do it over anything that has accessors, not just structs.
4:01:23
loke
Bike: Sounds unlikely. Why would any implementation deviate from the standard SYMBOL-MACROLET implementation?
4:02:28
aeth
with-accessors on anything with well-defined accessors (i.e. a matching setf foo for any given foo) seems reasonable
4:03:12
loke
ACTION can pretty much guarantee that it'll work on all implementations, regardless of whether it's allowed by the spec or not.
4:03:21
aeth
The implementation is trivial (although SBCL, CCL, and ECL all have slight differences in the macroexpand-1, try it!), so there probably could be an implementation-specific workaround on implementations that don't use this interpretation.
4:03:59
loke
But, if the original intent of WITH-ACCESSORS was to be allowed for anything, what is the meaning of this statement: “The consequences are undefined if any accessor-name is not the name of an accessor for the instance.”
4:07:12
aeth
Two possibilities. (1) they were opening the door for optimizations or (2) they were opening the door for the trivial implementation, which technically makes things work for non-accessors like print.