freenode/lisp - IRC Chatlog
Search
18:58:12
nyef
Basically "our type system can't express this, so we'll shove it into the variable namespace and have the humans do the type checking."
19:02:32
pebblexe
how can I specify the limits of the type accepted for something?: https://gist.github.com/pebblexe/28473dc4b1a172e023c9d6f5a993e29c
19:05:29
pebblexe
Bike: but what's the point of declaring it after the function call except as an optimization? I would like to do something like this (defmethod test ((integer n)) ...)
19:05:46
pebblexe
I mean it would also catch errors, but I mean I am looking to dispatch on the type
19:06:08
Bike
you mean you want it to use one method if it's in that range, and another if it's an integer outside that range?
19:06:14
varjag
but whatever numeric optimization you make there, will be negligible after you cons all that into a list and (i assume) traverse it later
19:06:56
pebblexe
varjag: I am not worried about optimization, I just want to have good looking code
19:07:01
Bike
yeah, you can't do that. you can dispatch on integers and then do a basic (if (< ...) ...) in the body, of course.
19:07:31
Bike
you can't dispatch on types because any value belongs to multiple types that are not subtypes of each other.
19:09:00
pebblexe
Bike: the types are also a tree http://sellout.github.io/2012/03/03/common-lisp-type-hierarchy/
19:09:30
Bike
what is the relationship between "integers between 0 and 10" and "integers between 5 and 15"?
19:10:04
pebblexe
if I have a function that runs if 'x' is true about the variable, it makes sense to run it
19:14:00
Bike
hum, even in that image you can see non-tree-ness at simple-string and simple-bit-vector
19:26:31
scymtym
on a related note: this https://github.com/sbcl/specializable/tree/wip-type-specializer/src/type-specializer (example: https://github.com/sbcl/specializable/blob/wip-type-specializer/examples/type-specializer.lisp ) now mostly works with vanilla sbcl master. the previously mentioned problems w.r.t. sorting applicable methods remain, of course
19:29:45
pebblexe
is it possible to do it this way?: https://gist.github.com/pebblexe/1634baa131afd2c0a7cb236a3002dd89
19:30:29
Bike
no. (standard) generic functions specialize on classes. eql t and a function are not classes.
19:31:52
scymtym
pebblexe: https://github.com/pcostanza/filtered-functions may be interesting for you
19:32:33
jasom
pebblexe: usually if I want to do somethign fancy, I just use etypecase or optima or whatever.
19:33:03
pebblexe
jasom: yeah I've looked at optima, I was just hoping I could get some experience with clos
19:33:19
scymtym
iirc, fortress had a solution for this kind of applicable method ordering. i think it was something like being forced to define a method that is more specific than both of the ambiguous methods. but that seems to prohibit call-next-method
19:34:41
pebblexe
okay I am having issues where sometimes stuff doesn't compile after using defmethods to experiment, like it complains about something that I've commented out
19:35:17
pebblexe
I think it's only happened in ccl, but I think it might have happened in sbcl as well
19:35:50
Bike
when you recompile a function, you replace the definition, but when you recompile a file and you just commented out a method, there's no reason for that method to go away, you know?
19:36:09
Bike
what i do is M-x slime-inspect the generic function, and that brings up a menu where you can undefine particular methods
19:38:17
pebblexe
Bike: I am not sure what you mean, I mean functions go away when I comment them out, right? why are methods different?
19:42:50
Bike
your lisp image has a persistent state, calling load and whatnot just alters that state
19:43:03
Bike
defun adds a new function, but if it's commented out that just means it doesn't add a new function, not that it removes a function
19:43:09
daemoz
Bike: How do I undefine something from the slime-inspect menu? Just delete everything and press enter?
19:43:14
pebblexe
what does this error mean?: https://gist.github.com/pebblexe/31503c36172e43bc4c21ceb176d47d56
19:43:56
Bike
daemoz: you can remove particular methods by going to the line with the method and hitting enter. where it says [remove method]
19:44:25
nyef
pebblexe: I'm not too familiar with CCL, but I think that it's saying that the file underlying whatever stream that is was closed?
19:57:31
pebblexe
now I am getting this error trying to (ql:quickload "optima") https://gist.github.com/pebblexe/fd096a27962d9f81e6a5f7b8cac3c4b8
19:59:37
pebblexe
yeah and in sbcl I get: https://gist.github.com/pebblexe/d30811426c3a0109d6108fedaff04358
20:13:17
websterbudding
I'm having trouble parsing json strings in lisp. Both cl-json and yason require outer double quotes and escaped inner double quotes. But JSON.stringify does not generate escaped double quotes.
20:18:36
pebblexe
how do I use a package in a file that starts with in-package? for example I have (in-package #:cl-msgpack) and I would like to import optima
20:38:38
pebblexe
how do I create/append to a file? it seems that :if-exists :append causes it to error out if it doesn't exist
20:42:18
pebblexe
jackdaniel: okay, I was just going off of practical common lisp, but I'll check there too
20:45:20
pebblexe
how do I use with-open-file to point to a file specific to a directory? I mean slime starts up with what as the home directory to write to?
20:49:29
pebblexe
figured it out! it's (merge-pathnames (asdf:system-source-directory :cl-msgpack) "temp-bytes")