freenode/#lisp - IRC Chatlog
Search
12:43:26
drmeister
Is there a way to shut down pretty printing for trace output? Or is this an implementation dependent detail?
12:44:35
Shinmera
Well, setting *print-pretty* is an option unless the implementation changes that itself during tracing.
12:48:23
scymtym
maybe implementations could add something along the lines of SB-EXT:*DEBUG-PRINT-VARIABLE-ALIST* for TRACE
12:48:58
drmeister
Sometimes in clasp trace generates pretty printed output and other times it doesn't.
12:49:27
drmeister
It's pretty much "(setq *print-pretty* <which one doesn't drmeister want right now>)"
13:01:16
drmeister
(blush) Simply (setf *print-pretty* nil) in the slime repl turns pretty printing off for trace
17:39:24
jackdaniel
Devon: advices are supported only by CCL I think (I don't count commercial implementations because I don't use them so don't know)
17:40:16
jackdaniel
s/commercial/locked down/ - corrected myself because foss implementation may be commercial, why not
17:49:35
Devon
Any CL lacking DEFADVICE is an outlier, it may not be in the spec but it's in the culture.
17:50:46
jackdaniel
(probably because sbcl doesn't have it though, most libraries are developed with sbcl ;)
17:52:52
pjb
Adding an advice would require recompiling all the files that use the adviced function.
17:53:02
jackdaniel
actually more like: practice makes culture -thinking otherwise is called social engineering ;-)
17:53:53
jasom
pjb: adding an advice would have exactly the same limits as redefining a function; and people do that with C-c C-c all the time
17:55:14
phoe
"There are three kinds of advice that may be defined: before, after and around advice."
17:56:25
Shinmera
On SBCL you can emulate advice by using (trace foo :report NIL :condition/-after/-all stuff)
17:57:04
makomo
could you use something like ensure-generic-function combined with standard method combination?
17:57:52
pjb
OR, you can not use cl:defun, instead define your own defun macro, implement the conforming tricks so that any library compiled will use your:defun and then you can conformingly have a defadvice that would work even with inlined function calls.
18:06:24
makomo
what's the best way to have something like an enumeration, i.e. a mapping from symbols to values?
18:07:45
makomo
i want it to hold globally, i don't want to have to wrap everything into a symbol-macrolet
18:11:16
Shinmera
Or just define a function that does an ecase to return the value, and have the function exist at compile-time with eval-when
18:11:54
makomo
i guess that's also an option. i suppose i could write a macro that would automatically give me the other direction as well right?
18:12:20
Shinmera
In that case I'd store the map as an alist in a variable, and define two functions to do the lookup in either direction.
18:12:33
scymtym
emacs' object system has an interesting combination of CLOS and an advice facility: method qualifiers can always be augmented with :extra STRING, basically allowing the "same" method to be defined multiple times, like named pieces of advice
19:14:12
pjb
sjl: I would be careful with mixing conventions. perhaps choosing between (defconstant account-state.active 1) (defconstant account-state.inactive 2) or (defconstant +account-state-active+ 1) (defconstant +account-state-inactive+ 2) would be preferable.
19:15:39
pjb
foo.bar has a conotation of functional abstraction (accessing a slot in a class or structure). So there's very little probability of anybody trying to bind such a symbol.
19:16:04
Colleen
Bike: drmeister said 13 hours, 54 minutes ago: I disabled cl:row-major-aref and cl:row-major-ast temporarily
19:21:08
jmercouris
I'm trying to add hooks into my program, I was thinking about making them exist for every defined-command (user invokable defun)
19:21:51
jmercouris
another thought I had was creating some macro like (define-hook :hook-name) that you can place inline, and any things registered to :hook-name will be invoked after that line of cod
19:23:02
jmercouris
the only issue with (define-hook) is that as it may be within a defun body, it won't be a top level form so (defun register-to-hook (function hook) ...) may not necessarily be able to register against a non-existent hook
19:23:36
jmercouris
though I guess that register-to-hook may make a binding for the hook if it does not exist, and then (define-hook) will just use that hook
19:27:36
phoe
client code can either push to the toplevel value of *something-hooks* for a global effect or rebind that for a dynamically scoped effect
19:28:41
jmercouris
the question was about how will users declare new hooks and register where the hook gets invoked
19:29:00
jmercouris
what if I want to add more logic down the road in what happens during a hook declaration
19:30:10
jmercouris
so that number could grow out of control and I may need to do some magic down the road
19:31:31
phoe
somewhere in code that opens a new tab, (mapc #'funcall (gethash :on-new-tab *hooks*))
19:31:42
dlowe
so, I have a hook mechanism in tcl I did myself. The things you'll want to do: have two identifiers for the hook - the hook trigger and a descriptive id
19:32:47
dlowe
so that (define-hook connected foo ...) will replace the foo proc in the connected hook
19:33:44
phoe
so if your hook is (lambda () (print "haha")) then the print will happen 10 times in a row.
19:34:30
phoe
that's why dlowe introduces a second identifier, so you can identify hooks by *their* identifier and replace them instead of pushing new ones.
19:35:31
dlowe
you can mess about with order inside the hook list, but if you want an abstraction layer that supports redefinition, the numeric priority is the way to go
19:36:56
jmercouris
I don't think i'll worry about priority just yet, that seems to be a more sophisticated problem
19:37:18
jmercouris
and then it could automatically calculate the order in which hooks should be invoked
19:38:20
_death
in my opinion, the function running the hooks should first copy the list and use that copy.. so that actions can change the list without issue
19:39:08
jmercouris
if it makes a copy of that list, why would it matter if actions change the list?
19:39:10
dlowe
in my hook implementation, hook functions can modify the argument list for successive functions or break out of the hook completely
19:41:08
_death
hook is a symbol that names a special variable.. (defvar *my-hook* '()) (add-hook '*my-hook* 'some-function)
19:41:16
jmercouris
dlowe: no way, I mean the trees are far and more complex, I'm just thinking, that either solution right now is not important for a first round implementation
19:41:40
jackdaniel
not sure if it fits your problem, but is a very interesting approach to propagating events
19:42:51
_death
there are more elaborate libraries for hooks, but this implementation suffices for what I need
19:43:20
jmercouris
_death: seems clean, I'll do something similar, but introducing the list that phoe and I spoke about
19:45:22
jmercouris
thank you all for your feedback, I'll have to spend sometime thinking about while not exhausted, and hopefully I'll have an implementation soon, and then my first version of hydra :) (https://github.com/abo-abo/hydra) for next
19:46:13
jmercouris
_death: right, which is why I was saying I wanted a macro originally, so that I can make decisions like that in the future without breaking everyones code like an angry child with legos
20:47:04
Xach
Shinmera: https://gist.github.com/xach/5e623744fa4777159719619c9eabb4d5 shows some behavior that is confusing to me.
22:42:42
Shinmera
If you want to preserve the package that is used during compilation you need to, well, capture it.
22:45:55
pjb
Shinmera: this doesn't work: the current package is not necessarily available at load or run-time.
22:46:35
pjb
Shinmera: better use something like (load-time-value (or (find-package "FOO") (error "No package FOO")))
22:47:00
pjb
Shinmera: or if you insist, (load-time-value (or (find-package #.(package-name *package*")) (error "No package FOO")))
22:47:10
Shinmera
pjb: I assume this is placed in a file with (in-package ..) at the top. In that case it's just fine.
22:54:36
pjb
Well, what bothers me most, is that you have there a literal package that needs to be serialized in the fasl file, while in another fasl file, there's a defpackage for that will be creating a new package with the same name (assumedly before loading the fasl with the serialized package).
22:56:21
Shinmera
pjb: http://www.lispworks.com/documentation/HyperSpec/Body/03_bdbb.htm "Two packages S and C are similar if their names are similar.
22:56:36
Shinmera
Note that although a package object is an externalizable object, the programmer is responsible for ensuring that the corresponding package is already in existence when code referencing it as a literal object is loaded. The loader finds the corresponding package object as if by calling find-package with that name as an argument. An error is signaled by the loader if no package exists at load time.
22:56:56
pjb
Shinmera: ok. Also, it seems that implementations implement that by using find-package at load time.
22:58:13
pjb
Notice that those are special rules. In general be warry of using #. with complex objects. It doesn't always work.
23:02:10
Shinmera
oleo: This is what I explained to you already. The run-time package is not the same as the compilation package. You need to capture the package that is used during compilation and bind it at run-time around READ.