freenode/#lisp - IRC Chatlog
Search
10:31:02
schweers
I have a slightly off-topic question. I have a class COST which calculates costs based on given initargs (using INITIALIZE-INSTANCE). This code has been tested and all is well. I now want to test another function, which creates a COST object using said initargs. In order to simplify testing, I’d like to make it configurable how such a COST object is created. The easiest way I can think of is adding a keyword argume
10:35:56
White_Flame
2 ways: pass in a "factory function" (whee java terminology), eg (lambda () (make-instance ...)), or pass in a list of initargs and use APPLY on MAKE-INSTANCE
10:38:18
schweers
The thing is that my old code already passes objects it produces on its own to MAKE-INSTANCE, so I’m not sure how APPLY and a list of initargs may help me. On the other hand ... is a lambda really different from supplying a different symbol?
10:39:39
schweers
Now that I think of it: the old code is a regular defun, while the new code I’m refactoring it into is an INITIALIZE-INSTANCE method on a new class, so I might as well use a keyword.
10:40:28
schweers
The code I want to test creates objects and I want to change how these objects are created (just for testing, at least for now)
10:43:00
schweers
White_Flame: your suggestion sounds a lot like what I had in mind, so my idea seems to not have been so far off :) Thanks for your feedback!
12:31:14
Selwyn
is there a way to print Lisp forms without the quote symbol and backquote symbol being replaced by ' and `?
12:32:56
Selwyn
at the REPL, '`(a ,b) ==> `(a ,b) whereas the desired output would be something like (MY-IMPL::QUASIQUOTE (A (MY-IMPL::UNQUOTE B)))
12:37:40
heisig
Selwyn: Maybe fare-quasiquote ( https://github.com/fare/fare-quasiquote ) can help you. As flip214 said, quasiquotation is, by default, very implementation-dependent.
13:59:03
ogamita
Selwyn: (print-conses '`(a ,b)) #| (list* . ((quote . (a . ())) . ((list . (b . ())) . ()))) --> (list* 'a (list b)) |#
13:59:32
ogamita
(symbol-package 'print-conses) #| --> #<Package "COM.INFORMATIMAGO.COMMON-LISP.PICTURE.CONS-TO-ASCII"> |#
14:00:32
ogamita
Selwyn: note however that: (print-conses '(a #(b (c d e) f) g)) #| (a . (#(b (c d e) f) . (g . ()))) --> (a #(b (c d e) f) g) |# ie. it doesn't enter into vectors and other structures.
14:00:50
pfdietz
xsperry: in that thing from yesterday, you could also imagine f and g (and (c f g)) return the value returned by the argument thunk when it is called.
14:03:54
Selwyn
ogamita: thanks for the link. sbcl in particular relies on some structures to implement unquoting
21:05:01
anamorphic_
Hi, I have a bunch of lisp files and I want to create a static cross reference for them (perhaps building something like LXR) - is xref.lisp from the AI repo my best bet as a starting point?
21:13:38
pjb
anamorphic_: yes. Also, it has been included in slime/swank, so perhaps it's modernized in there?