freenode/lisp - IRC Chatlog
Search
8:34:59
Grue`
aeth: yeah it's called MAPCAN: (mapcan #'(lambda (x) (and (numberp x) (list x))) '(a 1 b c 3 4 d 5)) => (1 3 4 5)
8:47:10
shaftoe
if my function's argument is a list containing one specific type... is there a way to help compiler beyond (declare (type list x))
8:48:34
Xof
if you know the length of the list you could (declare (type (cons integer (cons integer (cons integer (cons ... null)))) x)) but that's really a terrible idea
8:49:48
shaftoe
i have plenty of functions that take lists as arguments, but i've always wondered how to optimize them further
8:51:28
pjb
notice that there's no optimization to be have, by declaring the type of all the elements of a list, since cons cells are the same for any type of element.
11:19:05
libreman
The problem is that within swank the file location is passed to definition-source-for-emacs for non expanded (read) code and slime gets the location for the expanded code. And as cl-annot generates code this is new location is not correct
15:13:30
beach
Slow but steady progress. I am working on a library that will allow for source tracking in a compiler or editor.
15:13:51
beach
At the same time, I am working on the incremental Common Lisp parser for the Second Climacs editor.
15:22:42
python476
right now I'm off computing (electronics), a bit before that I was trying to write a tiny lisp in pascal :)
15:24:58
beach
I was working for a company that had a rule that everything had to be written in Pascal.
15:27:25
malice`
I also wanted to get clever with format and do something like (format t "~{~A~}~%" (make-list 25 :initial-element #\=)) but that's longer
15:51:57
p_l
malice`: ... somehow I got from there to (princ (make-array 15 :element-type 'standard-char :initial-element #\=))
16:04:31
malice`
I have a tree. I want to provide a generic function that would allow for using a function on each element of the tree (let's call it maptree). I also want for the user to be able to provide the traversal method from the default - e.g. in-order, post-order, ... - or instead pass a custom function that would walk the tree.
16:06:08
malice`
I think that's quite okay; however, my concern is that I define it as a generic function, but traversal methods might be different for different classes (some class might want to have a method with e.g. :fast traversal implemented that would be unique to it), but documenting the method isn't that useful in CL imho, then documentation isn't helpful on the matter of traversal method. Is my concern valid?
16:07:35
phoe
what you describe looks like a name collision for two classes that want the :fast keyword to mean different things
16:08:20
malice`
I define a general "trie" class, then "standard-trie" (or something like that) that derives from trie
16:08:27
phoe
malice`: that's what my question meant; good, then you can freely use generic functions.
16:08:57
malice`
that would behave a little bit different with its keys, and write new methods for them
16:10:13
malice`
I was thinking more of a scenario where e.g. standard-trie has (:default) as list of possible traversal methods
16:10:26
malice`
and someone implements nonstandard-trie which has (:default :fast) as traversal methods
16:11:13
phoe
(defmethod traverse ((tree randomly-sorted-tree) (traversal-method default-traversal)) ...)
16:11:27
phoe
(defmethod traverse ((tree randomly-sorted-tree) (traversal-method run-around-in-circles)) ...)
16:17:00
pjb
malice`: have a look at the two tree posts referenced from http://informatimago.com/articles/usenet.html#Forms--Lists--Trees--and-Data-Types
16:25:11
Bike
you can define a normal fnction like that and then have it pass its arguments to a generic function, though
16:26:53
malice`
pjb: I looked at them. This looks nice and I might consider defining the methods by means of walk-tree, but I would like to provide a simpler interface to the methods
16:44:10
otjura
is there a way to pass arguments to lisp scripts when running like sbcl --scripts foo.lisp
17:34:44
fiveop
`(defun foo ()\n "bar\n(baz)"\nnil)` (with \n proper line breaks) causes problems with indentation (after the doc string) and with top-level form recognition of slime (e.g. with C-c C-c), because of the doc string line starting with a (
18:50:59
shrdlu68
I have a logging function in a library, and I want to give users the option to define their own function to do logging. From what I've gathered so far, this is done using generic functions, where the users specialze the said function. Is this conventional? Would simply redefining the function work?
18:56:19
Grue`
yeah, a downstream project can redefine any function in your library. i do that sometimes
18:58:34
Grue`
for example if you change the api and user's function is not compatible with your library anymore
18:58:51
Bike
references to #'foo would still be the old function. another library could redefine something and then a user would want to redefine it themselves while letting the other library ocntinue to work