freenode/#lisp - IRC Chatlog
Search
19:20:44
makomo
there's swank::*connections* but i'd like something that's actually exported (and possibly documented)
19:43:29
jackdaniel
and if a superficial requirement is to have the symbol exported, then export it and forget about the issue
19:45:58
makomo
there's no requirement. i was just hoping that there's an "official" way to do it, i.e. that there's a proper protocol
20:16:33
dim
I'm close to having c:build-program work for pgloader, but I don't quite get what the epilogue should look like
20:17:17
dim
given (c:build-program "/tmp/pgloader/pgloader" :epilogue-code '(cl-user::pgloader-image-main) I get The function PGLOADER-IMAGE-MAIN is undefined., but it's defined in the same "src/save.lisp" file as where the call to c:build-program is found...
20:29:17
jackdaniel
c:build-program *is not* save-lisp-and-die, it builds application from other artifacts
20:29:31
jackdaniel
so if this function is not in one of these artifacts, then indeed function won't be accessible
20:33:45
brainacid0
hey, im very new. i was curious if there is a way i can write my code in one line and have the editor do the indentation?
20:34:29
phoe
brainacid0: it's not your task, your editor should count the parens for your and automatically indent your code
20:35:08
phoe
vim should be capable of that. I'm not a vim user myself though so can't give you concrete pointers.
20:37:56
brainacid0
see im not really a programmer per se so i dont have the ey and thought process down
20:57:54
makomo
what's the way one is supposed to use named-readtable's IN-READTABLE? just stick it as one of the first top-level forms within your file?
20:59:57
makomo
Xach: and the way IN-READTABLE is implemented will ensure that this readtable is used while reading the current file only?
21:00:37
makomo
i suppose that has to do with the fact that both LOAD and COMPILE-FILE bind *READTABLE*?
21:04:35
makomo
i see. one last thing, since IN-READTABLE is executed in all 3 EVAL-WHEN situations, then any usages of READ within that file will use that readtable, right?
21:05:29
makomo
unless you (or the code that indirectly calls READ) rebinds *READTABLE* to something else
21:06:19
makomo
so i guess that in general one should be very careful when writing code that uses READ, taking care to explicitly bind the readtable that you want to use, etc.?
21:12:37
makomo
mhm. i just finally diagnosed an error which was due to Swank calling READ for whatever reason when slime-restart-frame is called. since some code modified the standard readtable, Swank's READ would use it god knows how and the reader function would error
21:12:57
Xach
it is bad to directly modify the standard readtable. i think some implementations protect against that?
21:30:33
makomo
Xach: i maintain a certain lisp tool that is used to generate c++ code. to ease that task, it has a reader macro which lets you easily embed chunks of C++ code (which support interpolation) into lisp
21:33:53
Xach
do you make use of the pretty printer dispatch for any of that? i've seen some interesting uses of it but mostly fall back to templated strings myself
21:33:58
makomo
and there's a little DSL which lets you define the C++ types and automatically register the generation of their serialization code, etc.
21:36:17
makomo
Xach: nope, but i never thought about it either (i'm not the original author of the core) -- all of it is templated strings like you say
21:41:55
Xach
makomo: ahhh. the pretty printer can do smart things with indentation and continued lines and conditional breaks and such. i've seen it used to write pretty struct initialization code for C, for example.
21:42:15
Xach
but if you're just piping through another formatter there is no real need to generate pretty code initially
21:42:59
makomo
also, i believe it would be hell to try t model the usual C++ style guidelines using the pretty printer
0:29:15
fouric
how can i check to see if a given generic function is applicable to a given object - without actually calling the GF?
0:33:05
pjb
(defmethod moo ((a integer) (b integer)) (+ a b)) (find-method (function moo) '() (mapcar (function find-class) '(integer string)) nil) #| --> nil |#
0:33:21
pjb
(find-method (function moo) '() (mapcar (function find-class) '(integer integer)) nil) #| --> #<standard-method moo (integer integer)> |#
0:46:06
Bike
find-method finds, well, specific methods. with pjb's example, if you tried it with (#<class fixnum> #<class fixnum>) it would find no method, even though the method on integers is applicable to fixnums.
0:46:21
Bike
there's compute-applicable-method, which gives you a list of methods given a gf and arguments
0:46:45
Bike
however, even if there are applicable methods, they may not be enough to form an effective method, e.g. if there are :around methods but no primary methods
0:55:35
fouric
which gets called on an object when it doesn't understand a message that was sent to it
0:56:13
fouric
i came up with https://gist.github.com/fouric/595724587ecf6021ad4cfce4facf63dd but i don't think it works entirely correctly
0:57:27
Bike
if you're already in no-applicable-method, you can assume the generic function isn't applicable, no?
0:59:52
fouric
if it doesn't, then we need to just call the normal ("primary"?) no-applicable-method
1:00:19
pjb
(find-method (function moo) '() (mapcar (function find-class) '(integer fixnum)) nil) #| --> nil |#
1:00:40
fouric
...and then reason i don't just invoke does-not-understand off the bat is because otherwise we'll recurse infinitely
1:03:41
fouric
i'm sorry, i still confuse "generic function" and "method" with each other because in other languages they mean the same thing
1:04:41
fouric
or, rather, a class either defines special behavior, or the normal CL machinery is used to signal that there's no applicable method
1:05:49
fouric
it could just be printed out, or maybe logged to a file, or maybe the reason the function was called was because RPC, and a response needs to be sent back over the network instead of signalling a condition locally
1:07:11
Bike
how would the system even get to no-applicable-method if there is a method matching the first argument?
1:10:26
Bike
let's back up another step here. the code you wrote is illegal. you can't specialize no-applicable-method on nothing like that, since it would override everything in the system.
1:11:14
Bike
then if you do, you could have no-applicable-method call does-not-understand. if does-not-understand is a normal gf and not one of your custom gfs, no-applicable-method in the case of lacking a does-not-understand method would not go into your method and there would be no recursion.
1:14:20
Bike
but in general i think you'll have to think this through more. multimethods and complex method combination make CL generic functions pretty distinct from the smalltalk object system...
1:23:43
fouric
Bike: it would override everything in the system, but only for classes that didn't have a does-not-understand method defined, and that should be OK, right?
1:24:17
Bike
i mean, consider if someone else wnated to do something like this, and you both tried to define an unspecialized :around
1:27:55
fouric
i don't quite understand how :before/:after/:around methods are combined with primary methods
1:28:48
specbot
Standard Method Combination: http://www.lispworks.com/reference/HyperSpec/Body/07_ffb.htm
4:15:28
didi
Has anyone played with the idea of a function returning a variable number of values? For example, a matching function might return (values x) if I ask for a single match and (values x y z) if I ask for three matches.
4:22:27
White_Flame
when receiving the values, you probably want to multiple-value-bind with &optional or &rest
4:23:03
White_Flame
other than that, I don't think there's anything abnormal about it. It's supported by the language
4:23:48
White_Flame
SBCL might whine about optimization issues with the number of values not being fixed, depending on your speed setting, but it'll deal with it
4:33:27
White_Flame
yep, but if you set speed 3, it whines about every place it can't fully optimize
4:35:26
White_Flame
wrote it a long time ago, not sure how accurate it is for current versions: https://pastebin.com/Rmyazt4z
5:19:40
pjb
didi: (ql:quickload :cl-ppcre) (cl-ppcre:scan "(a)" "hello a world") #| --> 6 ; 7 ; #(6) ; #(7) |# (cl-ppcre:scan "(a).*(b)" "hello a world before") #| --> 6 ; 15 ; #(6 14) ; #(7 15) |#
5:20:44
pjb
didi: there's no difficulty in writing such a function. But if the number of values is not known at compilation-time, then you will have to use multiple-value-list and cons a list!
5:21:42
pjb
(loop repeat 3 collect (multiple-value-list (values-list (make-list (random 10))))) #| --> ((nil nil) (nil nil nil nil nil nil nil) (nil nil nil)) |#
5:21:47
White_Flame
multiple-value-bind and &rest, if used immediately and not passed around, has the possibility of not consing
5:27:28
slyrus__
I'm looking for a lispy approach to "time travel" through a modestly-sized (read: small) data set, where I want to be able to see the "state of the (again, relatively small) world" at a particular point in time. Anyone have any suggestions?
5:28:13
slyrus__
beach has a library called Clobber that might be a good place to start, but I figured I'd see if others have dealt with this or similar problems before.
5:28:53
White_Flame
either that, or keep a changelist of undo/redo function objects that you can use to traverse time
5:32:51
didi
SBCL seems to not care about not receiving some values. (multiple-value-bind (x y) (values) x y) => NIL
5:33:27
White_Flame
" If there are more vars than values returned, extra values of nil are given to the remaining vars. " - clhs
5:34:37
slyrus__
thanks White_Flame. I also came across this: https://github.com/smithzvk/Versioned-Objects which sounded like it might be what I'm after.
5:58:40
White_Flame
when performance is critical in inner loops, and you're guaranteed to not to be dealing with numbers or characters
5:59:17
White_Flame
(unless the numbers are guaranteed to be fixnums, but even then I think ABCL doesn't guarantee that fixnums are EQ)
6:08:11
pjb
verisimilitude: EQ is an operator that serves only to detect whether an implementation copies integers and characters or not.
6:08:58
verisimilitude
If you wanted to be mean, didi, you could write Common Lisp that behaves subtly differently between implementations based on whether objects that happen to be numbers or characters are ever EQ.
6:11:41
verisimilitude
EQL is more complex, purely because it can't simply compare a combined tag and pointer value to arrive at its answer.
6:14:57
pjb
verisimilitude: but forgetting about EQ frees some neurons for better things, and you don't have to think whether you can use it or not when you write code, and you don't have to ponder whether something special occurs with numbers and characters when you read it.
6:15:09
verisimilitude
You'll mostly be using EQL, though, didi. When in doubt between EQUAL and EQUALP, just use EQUALP if you're too lazy to look at the documentation.
6:15:41
verisimilitude
Sure, but why are you using Common Lisp instead of something else, at that point, pjb?