freenode/#lisp - IRC Chatlog
Search
14:26:28
Shinmera
Or just the unit that you're breaking in. You can use C-u C-c C-c to compile a block with high debug.
14:29:40
Shinmera
You can also inspect the values by clicking on them or moving the cursor to them and hitting return
14:32:05
Shinmera
For values on the repl you can also easily inspect the last one with slime using M-x slime-inspect * RET
15:39:35
malice
Anyone knows drakma? Can I somehow check headers of the request sent by http-request? I'm interested in headers created when using cookies.
18:16:50
junxit
I'm using drakma to connect to several APIs, and one of them is coming back with "error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version" ... I have a call that works in curl from the command line (MacOSX), but doesn't work from drakma ...other API calls to different sites work fine. I'm not sure what the next step in troubleshooting is, any suggestions?
18:39:34
rpg
junxit: Just from reading that, I wonder if Drakma is doing the authentication wrong. It looks like maybe you're using TLS and you have the wrong version?
18:40:20
junxit
yeah, but I'm not finding how to change/force that ... it's weird that it is only the one site that does it.
18:40:53
junxit
I tested it on a remote linux box, and it works. It also has always worked in the past *sigh*
18:41:06
rpg
junxit: You probably need to figure out first if it's an error in Drakma, or an error in the remote site.
18:41:49
junxit
I tested the same call using curl from the command line (outside of lisp) and it works.
18:44:16
rpg
junxit: All the run with curl tells you is that curl and the remote site are compatible. Unless you know how curl's behavior differs from Drakma's behavior, you are not much further along (except that you know that the remote site isn't just plain broken).
18:45:05
rpg
A good start in debugging might be to look at curl's command-line options and see if there's some auth setting that will make curl *also* break. That might help narrow things down. Or you get into Drakma and start tracing things. Or both
18:50:12
tomlukeywood
how would i initialise all the elements of an array with a value in common lisp?
18:52:15
junxit
yeah, they're Jira APIs and it seems to be a problem with my laptop as it works on a remote linux box
18:53:39
junxit
both drakma and dexador throw the same SSL error `A failure in the SSL library occurred on handle #<A Foreign Pointer #x1506150> (return code: 1).
18:57:00
junxit
@tomlukeywood use :initial-element or :initial-contents ... :initial-element sets all elements to the same value, :initial-contents you have to specify a value for every element in the array
19:00:08
junxit
@rumbler31 new laptop, so not using macports/homebrew .. openssl and curl seem to be stock
19:02:56
junxit
yep, 1795:error:140790E5:SSL routines:SSL23_WRITE:ssl handshake failure:/BuildRoot/Library/Caches/com.apple.xbs/Sources/OpenSSL098/OpenSSL098-64.50.7/src/ssl/s23_lib.c:185:
19:07:28
junxit
I've been putting off an update to Xcode, I'll update and see. If not, I'll install the homebrew version of openssl
19:08:51
junxit
also, the same openssl command connects to the other sites that *are* working. I'm going to guess that they updated the Jira server over the holiday, and it introduced an incompatibility
19:11:51
tomlukeywood
i am trying to give constants as parameters to (make-array) however i get an error when doing so. what is the correct way?
19:15:04
Xach
tomlukeywood: '(foo bar) evaluates is a list of two symbols. (list foo bar) will evaluate to a list of the value of two variables, FOO and BAR.
19:15:49
Xach
tomlukeywood: also, it's good to syntactically mark constants so they don't clash with other bindings.
19:16:34
Xach
tomlukeywood: In CL I often see constants marked with crosses, like +rows+ and +columns+
19:18:58
rpg
I think Robert Strandh has a lisp style guide somewhere on the web that covers this sort of thing. It was very good, I thought.
19:29:19
rpg_
I can't find it any more. If he's around, and doesn't object, I'd be happy to share it.
19:48:49
shka
rpg: here it is https://github.com/robert-strandh/SICL/blob/master/Specification/chap-general-coding-style.tex
19:54:50
phoe
github should auto-render TeX files in its preview, or at least offer it as an option.
19:55:33
fiddlerwoaroof
loop is lispy because a lisp is fundamentally just a way to write a bunch of domain specific languages to solve your problems in :)
19:59:15
phoe
LISP actually stands for Language Idiom Subdomain Protocol, which is a set of rules for developing custom DSLs to resolve particular classes of problems.
20:08:35
phoe
gah, I want to sit down and work on the UltraSpec. real life knows different though and keeps on throwing health/family/various other real life issues at me. I don't expect to be able to sit down and focus on it for the next 2+ months.
20:09:44
phoe
jmercouris: I'm just freaking sorry to let down all the people who offer me support at the moment and tell them that I'm not yet ready to lead the way.
20:10:13
jmercouris
phoe: Yeah, I can understand that, but it's okay, we are all human, with likely similar issues
20:10:55
phoe
I did a crapload of work converting things to DokuWiki and this work is right now pretty much useless for further work because I'm the only person around here right now who knows the details of DokuWiki format that I chose and the kinks and culprits of the current files.
20:11:37
phoe
I screwed up by that, I should have started from the beginning with distributed knowledge instead of knowledge that's stuck in my head and I have no time to sit down and utilize it.
20:12:00
phoe
well, shit. the only excuse I have is, all things take their time in the land of Lisp.
20:12:11
jmercouris
I think it's a good thing to share your experience, because maybe someone reading this channel log will avoid the same
20:13:22
rpg
Is there anything like a PATHNAME-DESIGNATOR-P function? Kind of hate to keep writing (or (stringp x) (pathnamep x))
20:14:23
Shinmera
All pathname functions take designators already so if something falls outside of that it'll error.
20:14:59
rpg
Shinmera: I have something like the case in CFFI -- I want to be able to supply an s-expression that evaluates to a pathname, in place of a pathname.
20:16:36
jmercouris
jasom: Hey jasom, I was wondering, would you like to be mentioned in the release credits?
20:17:45
rpg
Shinmera: I'm running experiments, and I want to dump a *portable* file designator into the output. E.g., I want the experiment file to report that the data was in (asdf:system-relative-pathname "experiments" "datafile1")
20:18:25
rpg
So I have a table of file designators that are s-expressions that can be printed into the script and then get evaluated to point to real files.
20:20:55
Shinmera
rpg: Use a macro that emits a quoted and unquoted version. One for printing, the other for the value.
20:21:20
Shinmera
rpg: I still don't quite understand though-- what pathname do you want to output? The one in which your experiment resides or?
20:21:58
jmercouris
Can anyone please help with a CFFI issue I'm having, getting the return back from a function: https://gist.github.com/875972985687a4d9d0f4afb80cb77975
20:22:23
rpg
Shinmera: I want to emit into a transcript file the *portable* file designator (the asdf:system-relative-pathname expression), so that the experiments can be replicated, but I need to evaluate them to actually get the data to process.
20:22:43
jmercouris
Within my callback, "callbacky" I'm trying to get the value of: webkit-javascript-result-get-value
20:22:57
Shinmera
(defmacro foo (expr) `(list :value ,expr :expr ',expr)) ; (foo (make-pathname :name "a")) => (:value "a" :expr (make-pathname :name "a"))
20:23:00
Xach
rpg: If it were me, I'd store the arguments to asdf:system-relative-pathname and apply them later. I would not use eval.
20:24:51
rpg
If this was more than a one off, I think you two would be right, but since it's a one off -- and not exposed to anyone to be a security threat -- these solutions smell like over-thinking.
20:26:00
rpg
Shinmera: I know how to do this if I'm going to do it right, but there's also an issue of knowing what's the proper cost-benefit tradeoff.
20:26:18
Shinmera
I've yet to encounter a problem that I could solve significantly faster with eval.
20:26:50
jasom
jmercouris: also if you named it scratchy.lisp instead of scratch.txt gist would syntax highlight it
20:28:03
Shinmera
shka: I'll want at least 90% of the profits off of that novel as royalties for that sentence.
20:28:04
jasom
jmercouris: reading the webkit docs, you get a pointer to a JSValue, the address of that pointer appears to be #X7FFFF002C830
20:29:45
jmercouris
jasom: Right, but given that pointer, how do I get that value at that pointer in lisp?
20:29:57
jasom
jmercouris: https://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html#webkit-web-view-run-javascript-finish
20:31:14
jasom
it's probably worthwhile to write a function to convert a JSValueRef to a lisp value, but you need to deal with NaN and Infinity that don't exist in lisp
20:31:50
Bike
most implementations use ieee floats i think, yhou just don't usually get a hold of them
20:32:10
rpg
Xach, Shinmera: I think there's a temptation to try to always to The Right Thing, but it's important also not to confuse production code with a utility script.
20:32:48
Shinmera
rpg: You can do whatever you want, naturally, but I can also criticise you for it. Your choice whether you want to let that bother you :)
20:33:24
Bike
jmercouris: the c code here checks whether value (the result from webkit_javascript_result_get_value) is a javascript string, and if it is, makes a c string with its data. you'd have to do similarly.
20:33:48
jmercouris
Bike: So in my code example I posted, I just want to assume for now that the result is a string
20:34:32
Shinmera
IF you don't need to keep value identity you could just serialise to JSON and parse that lisp native, and back.
20:36:11
Bike
how else would it work? if it can return any javascript value there has to be some kind of type information, it couldn't just be a c string
20:36:28
jmercouris
Bike: It should ALWAYS return a string, because all javascript values may be represented by JSON
20:36:55
Bike
that's like having a lisp system where everything was printed to string before being passed around
20:53:54
jmercouris
Is there some sort of thing like sldb-eval-with-break, so I don't have to change the function and re-eval it with a break inside?
20:54:16
jmercouris
Better yet, is there a good guide someone may reccomend for debugging with slime?
20:54:50
jasom
jmercouris: sbcl does have a stepper, I think you need to compile with a high level of debug for it to be useful though
20:55:27
jmercouris
There seem to be few faculties for support it and they are implementation dependent
21:01:48
aeth
jasom: on the other hand, debugging in languages that only have one implementation is portable across all implementations
21:04:09
jmercouris
jasom: So if you look in the C code you'll see I need to invoke JSValueToStringCopy, but this isn't provided by cl-webkit, how might I go about calling it? Do I have to do something like (cffi:defcfun "JSValueToStringCopy" :string) string-result (context JSGlobalContextRef) (value :pointer) ())?
21:04:49
jmercouris
How do I even know which library provides JSValueToStringCopy as in their example?
21:27:43
rpg
Stepping is definitely available in Allegro, but only for code that's interpreted, not compiled, IIRC (may have improved -- don't use it much)
21:50:16
jasom
jmercouris: the defcfun ought to work, assuming it's linked in somewhere; I haven't heard back yet from the webkit gtk channel yet
22:08:08
osune
I do (funcall fn arg) but fn can have [0-n] arguments what is the idomatic way to declare a fn with zero arguments? I'm undecided between &rest and a declare / ignore
22:14:02
phoe
I mean, you can always try, but Lisp is going to throw errors at you every time your Russian roulette doesn't work your way.
22:14:28
osune
ok let me backpaddle a bit, because maybe i ask the wrong question and my problem is more my design
22:15:47
Shinmera
phoe: ;) (defun call-anything (fn) (let (a) (loop (ignore-errors (return (apply fn a))) (push 0 a))))
22:18:09
osune
I parse user input for a chatbot via cl-pprce. assume the commands "/echo foo" and "/ping". One takes a parameter the other doesn't. I split the string into the command and the argument parts. So i have a special case that my functions only take zero or one parameter. The function itself tries to parse the complete argument string.
22:19:22
phoe
in one case you have ("/echo" "foo"), in the other case ("/ping" "") or ("/ping" NIL) depending on how you want to put it.
22:20:56
phoe
I wouldn't define functions with DEFUN for this though. my style, at least, would be to make an EQUAL-tested hash-table, and (setf (gethash "echo" hash-table) (lambda (arg-string) ...))
22:20:56
osune
yes. thats exactly my result after the first parse. Now i could do a (if arg (funcall fn arg) (funcall fn))
22:22:24
phoe
or rather, if you want PING to explicitly NOT want an argument, you can (lambda (arg) (when arg (error ...)) ...)
22:22:39
osune
I can see why lambda is a question of style and viable but having a named function helps a bit with debugging
22:22:52
phoe
or something else. so PING returns "wrong syntax: use /PING without an argument" or something.
22:23:25
osune
well exactly what you are suggesting is what I'm doing currently: (defun ping (arg) (declare (ignore arg) "pong"))
22:24:27
phoe
but then again, other people might have more valuable insight on the matter, so don't limit yourself to just my ideas.
22:24:30
Shinmera
What I would do is handle the arglist parsing in a common place, define each command as a native lisp function, and then just apply the function to the arglist, reporting errors to the user.
22:25:05
Shinmera
Though actually what i would do is use an existing library like Maiden to do all of that for me :^)
22:27:31
osune
But this is kinda a pet project to prepare myself for a reimplementation of a scheme midi sequencer , so I'll tinker a bit more and then take a look at it
22:29:15
Shinmera
osune: Anyway, something like this is what I would do: (defun ping () (reply "pong")) (defun handle-command (string) (let ((args (split string " "))) (apply (find-symbol (string-upcase (first args))) (rest args))))
22:29:40
osune
and as long I as cannot wrap my head around CFFI (libevdev/jack) I keep myself busy and keep learning
22:29:41
Shinmera
I say "something" since you probably want to throw your command functions either into a separate namespace entirely (preferable) or into their own package
22:33:16
osune
Shinmera: hm never played with find-symbol. I use a hash-table with :test 'equal to store the functions
22:33:16
phoe
osune: I would call it bad design to unnecessarily create functions that don't know how many arguments they will accept
22:34:01
phoe
but then again, depends on if you want things like "/ping foo bar baz quux fred" to work just like "/ping" would
22:36:04
Shinmera
makomo: I've never used it, but it looked overly complicated to me and like it tried to do too much. When I needed command line arg parsing I used Fare's command-line-arguments lib
22:36:10
phoe
CLON is a mammoth. Which has its upsides and downsides. I settled for Fare's command-line-arguments instead.
22:36:47
makomo
it does look complicated i guess, but that's only because argparsing is complicated imo :-)
22:37:26
makomo
Shinmera: oh, only because i saw you talking about argparsing and mentioning libraries
22:38:17
phoe
makomo: this discussion with osune is more about parsing function args inside Lisp, not on the boundary between Lisp and the OS
22:38:21
makomo
Shinmera: oh lol, i haven't read the whole thing actually, only your last couple of posts
22:39:15
Shinmera
Arg parsing in Maiden is handled by this lil' piece of beauty: https://github.com/Shirakumo/maiden/blob/master/agents/commands/parsing.lisp
22:40:53
osune
Ok lets say "/ping foo" is a no go. An error will be generated and returned to the user. What's the lisp way to call my two functions with stepping the least toes of good Common Lisp style ? *takes a look at the link
22:43:00
Shinmera
osune: Calling a function with the wrong number of arguments causes an error. Your function may also error for other intended or unintended reasons. Therefore you need to catch all errors to report to the user anyway.
22:55:29
osune
I see currently these options and I'm unsure which is the "best" or if I'm completely wrong: https://gist.github.com/osune/88f900b70c8083457816d3ca834b2cf3
22:55:55
jmercouris
jasom: The only thing I can find is that same JS core stuff by apple like you found; https://developer.apple.com/documentation/javascriptcore
23:09:02
Shinmera
osune: The "event" is there so that you have a context to work with in your commands. For instance, so that the command "knows" which channel to reply to.
23:09:28
Shinmera
Or rather, the event knows that and the reply function uses this information to do the right thing.
23:14:16
osune
love it! it solves the whole problem via format and I'm happy that I can say my solution looks nearly identical , apart from the event mechanic . Thanks that was insigthfull
23:15:10
Shinmera
The error reporting of this approach is somewhat poor as you're depending on the implementation's errors to be insightful (which they are often not)
23:15:52
Shinmera
A "proper" approach would manually parse and match a lambda list, like what maiden-commands does. But that's rather involved.
23:20:34
Shinmera
osune: I've updated the paste with a change that should improve error reports a bit.
23:48:00
aeth
pillton: Is there a way to see the disassembly produced by specialization-store for a given defspecialization?
23:54:48
aeth
Found it, it's (map nil (compose #'disassemble #'specialization-store:specialization-function) (specialization-store::store-specializations #'foo))
23:55:30
aeth
I was trying to call the slot names provided from the slime inspector (another way to get the disassembly), but your readers don't match your slot names
23:55:42
pillton
Another way is to give the specialization a function name. (defspecialization (store :name %store/specialization)) (disassemble '%store/specialization)
23:56:42
aeth
It looks like it produces exactly what I would produce by hand, with identical disassembly.
23:58:49
aeth
It also looks like it can be inlined, which is great for trivial functions if it works just like function inlining does
23:59:24
pillton
Yes. https://github.com/markcox80/specialization-store/wiki/Tutorial-3:-Compile-Time-Support
0:02:15
aeth
(Although technically the fixnum one is incorrect because adding two fixnums doesn't necessarily produce a fixnum.)
0:08:47
aeth
How do I know that it's using the correct foo? Or is that the runtime dispatch foo? Is that because I'm doing that in the REPL?
0:13:25
aeth
pillton: If I introduce an observable side effect to the runtime dispatch, I can see if a given function is using runtime dispatch
0:16:41
pillton
It should be exported. The expand-store function is part of the object protocol within SS's MOP.
0:18:31
aeth
Looks like the trace only shows up in the REPL when I do something like this: (let ((foo (let ((rand (random 1))) (if (zerop rand) 1f0 1)))) (foo foo foo))
0:18:52
aeth
e.g. (defun bar () (foo 1f0 2f0)) or (defun baz () (let ((foo (let ((rand (random 1))) (if (zerop rand) 1f0 1)))) (foo foo foo)))
0:20:57
aeth
This doesn't call the trace every time. (defun baz () (let ((foo (let ((rand (random 2))) (if (zerop rand) 1f0 1)))) (foo foo foo)))
0:22:06
aeth
I'm not sure if that's because it's really smart or if runtime dispatch uses something else
0:23:27
pillton
Expand-store is invoked when the function is compiled to see if any compile time optimizations can be performed.
0:28:47
aeth
But they call the same function in the disassembly. In fact, if I disassemble a foo-fn and a foo-sf, it looks like they call the same function in the disassembly. At least, if that's what this means; "MOV EAX, #x2054DF78"
0:36:24
aeth
Does this mean that when it's not inline SBCL always uses runtime dispatch to determine which foo to call, even when the types are known? e.g. (defun foo-sf () (foo 1f0 1f0)) (defun foo-fn () (foo 1 1))
0:37:27
aeth
Interestingly, CCL gives a bogus warning when defining the functions themselves: In FOO-SF: In the call to FOO with arguments (1.0 1.0), 2 arguments were provided, but at most 0 are accepted by the current global definition of FOO
0:37:51
pillton
Yes. The standard specifies that compiler macros are not invoked when a function is declared not inline.
0:42:16
aeth
pillton: Does specialization-store have a way to inline the dispatch but not the function itself? Sometimes that might be the most performant option, if the function is very large but the type of the arguments in the calling function is known
0:44:16
jmercouris
jasom: here's the interface file https://gist.github.com/d641b6ed92f35ae3fea76ddec14717b4
0:45:25
aeth
pillton: I guess it's possible with a combination of named specializations and expand functions, where the :expand-function calls the named specialization?
0:46:34
pillton
aeth: Matrix multiplication is always part of a larger problem. If the larger problem wants to be efficient then it should declare the types.
0:56:35
aeth
pillton: is it intentional that define-specialization cannot use :name and defspecialization can?
0:59:12
aeth
This is pointless compared to just inlining it, I was just combining the two things in the tutorial other than inline in one place
0:59:19
aeth
(define-specialization (foo :name %foo/single-float) ((x single-float) (y single-float)) single-float (:function (lambda (x y) (+ x y))) (:expand-function (specialization-store:compiler-macro-lambda (x y) `(+ ,x ,y))))
0:59:59
aeth
And there's no problem with defspecialization: (defspecialization (foo :name %foo/fixnum) ((x fixnum) (y fixnum)) fixnum (+ x y))
1:00:32
aeth
I was just going off of https://github.com/markcox80/specialization-store/wiki/Tutorial-3:-Compile-Time-Support
1:05:04
aeth
(define-specialization foo ((x single-float) (y single-float)) single-float (:name %foo/single-float) (:function (lambda (x y) (+ x y))) (:expand-function (specialization-store:compiler-macro-lambda (x y) `(+ ,x ,y))))