freenode/lisp - IRC Chatlog
Search
9:45:16
theothornhill
Hello! How do you decide between separate defmethods, or use the (:method) syntax on generic functions? Are there any tradeoffs with one or the other?
9:46:51
no-defun-allowed
Usually I put a class definition and any methods in the same file, so I would rarely be able to use :method syntax if I wanted.
9:47:07
beach
The latter requires the method definition to be in the same file as the DEFGENERIC form, so that's already a limitation. If you modularity requires them to be in a separate file you have no choice.
9:47:28
no-defun-allowed
But I use :method for "default" methods which the programmer should know about immediately sometimes, and whenever I use DEFGENERIC as a lazy person's pattern matcher.
9:48:03
beach
Or, you can use :METHOD when you have only a few methods that specialize to built-in classes.
9:49:43
beach
Methods defined with :METHOD are removed when the DEFGENERIC form is re-evaluated. Not so with separate methods defined using DEFMETHOD.
9:51:05
theothornhill
You mean the "old" version is removed if you change a :METHOD method and re-evaluate?
9:51:17
beach
But, yeah, I agree with no-defun-allowed. Often, the best place for a method specializing to some class C is in the same file as the DEFCLASS form for C, whereas DEFGENERIC forms are usually in a separate file.
9:52:26
beach
Or if you change some other aspect of the generic function, like the method combination.
9:58:22
vydd
Hey! I'm trying to do some CL programming after a relatively long time, and for my project I'd like to use https://github.com/plkrueger/CocoaInterface. However, it doesn't seem to play nice with asdf (or at least that's how it looks to me). There are docs on how to setup the environment using the ccl-ide-init.lisp file, in which *module-search-path* is updated to contain CocoaInterface, but when I quickload my project from sly, it
10:37:25
vydd
jmercouris: googling around, your named popped up in a discussion related to migrating CocoaInterface to use a system. https://github.com/nEXT-Browser/CocoaInterface doesn't seem to be available anymore. Did you ever manage to make it work, or did you hit a road block?
11:12:42
rumbler31
once long ago I played with something like that on windows, but the experience wasn't great, mainly because the cocoa interface on windows was likely incomplete
11:52:10
jmercouris
vydd: you’ll have to look at this repository : https://github.com/atlas-engineer/nyxt
11:53:26
jmercouris
I actually more or less use the objective c bridge independently of the cocoa interface after some point in time
13:30:59
nij
Hello! I can ql:quickload :sb-cltl2 from an sbcl repl. But when I put that in my stumpwm config, it doesn't know where to find.
13:32:28
no-defun-allowed
I think that would call (require :sb-cltl2) and not ASDF, so it is up to how SBCL finds its own modules.
13:39:48
no-defun-allowed
Quicklisp doesn't control how SBCL stores its contrib(?) modules, so it is understandable how any other module would load correctly.
13:42:03
Bike
i think sbcl loads contribs by looking at $SBCL_HOME, which might be different between the repl and stumpwm
13:52:18
Bike
ok, well, i was looking at module-provide-contrib, which says it "[stringifies] and [downcases] NAME, then [attempts] to load the file $SBCL_HOME/name/name". but it seems to do a little more than querying the shell variable
13:58:43
lotuseater
is it equivalent to say (defun sqr (x) (* x x)) and (compile 'sqr '(lambda (x) (* x x))) ? :)
13:59:44
Bike
and the second one will probably lack (implementation-defined) compile time side effects like suppressing undefined function warnings for sqr, and such.
14:03:05
nij
Unalbe to load any of the alternatives: ("libssl.so.1.1" "libssl.so.1.0.2m" ...) [Condition of type CFFI:LOAD-FOREIGN-LIBRARY-ERROR]
14:03:36
Bike
sbcl uses dlopen to find libraries, and as far as i can tell from people being confused here, guix totally hoses it
14:06:19
lotuseater
but don't worry, loading drakma in SBCL also throws me into "libssl not found" :D
14:06:48
Bike
i haven't used these systems myself. i'm just going off of what people have said here in the past.
14:08:26
lotuseater
i worked around that with other packages by pushing some paths to cffi:*foreign-library-directories* in .sbclrc
14:11:03
nij
Now that variable is NIL in my repl. I gotta ask the guix community where those .so files are.
15:21:19
alanz
I am liking that instead of writing comments about what I am doing, I can put :documentation and then it shows up in the info requests
15:30:42
beach
alanz: Except that comments and documentation strings have different target audiences.
15:31:53
alanz
I am still working that out. I am using the documentation more on fields, and for defun's
15:33:33
beach
Still, the documentation string and the comment would contain different things. First of all, a documentation string for a slot doesn't make much sense, since slots are implementation details. And for functions, the comment would mention why it is implemented the way it is, and the documentation string would mention how it is to be used.
15:36:19
alanz
Right now I am using defclass to create a thing that I intend to be a summary of information I know from various sources, which can be used as the basis of a thing to render in CLIM. So I am documenting per slot what it is sumamrising
16:26:57
jackdaniel
beach: but if you inspect the object, comment won't be (usually) accessible, while the docstring could provide some context
16:30:10
beach
Yes, I see what you mean. I need to think about what target audience would be most likely to inspect an object.
16:35:26
Nilby
Unless you want to specialize #'documentation on target audience, I say just write copious reasonable docstrings for everybody.
16:39:20
Nilby
I know slots are like the divergent base case, but sometimes there could be quite useful inoformation about a slot.
16:40:37
Nilby
e.g (defclass container () (... (damage :documentation "A list of bounding boxes whose area may need to be redraw.")))
16:41:21
jackdaniel
you are right, there may be a useful information. the question is whether it should be put in a comment, in a docstring or in a documentation
16:43:53
jackdaniel
I don't have a strong opinion on the topic. if the slot's accessor is exported, then it should be documented in the external document. as of whether a slot itself should be documented in a comment or via documentation - I suppose it heavily depends on the programming style
16:44:37
jackdaniel
when someone mainly operates on a living image (i.e by relying heavily on introspection), then the documentation option sounds fine; when they work solely based on a source code for clean builds, then a comment is good
16:45:37
jackdaniel
mind, that documentation strings in lisp are not very nice. for instance when you have more information to cover, they just clutter the code
16:46:03
jackdaniel
you can't also associate with them any semantic information (it is a string after all)
16:47:08
Nilby
My view is there is no external. The documentation is an object accessible from the repl.
16:47:48
jackdaniel
ACTION burns his books and printed manuals yelling "burn! thou is not accessible from the repl"
16:48:42
jackdaniel
that said, a live documentation writing and reading system in clim is a nice idea :)
16:49:09
jackdaniel
if I had a source code of unfinished thing in my repositories directory, I'd call it "London" after a famous writer
16:49:37
dieggsy
I've been in scheme world for a long time and am revisiting my old project euler problems in CL - what am I doing wrong in the CL defun here?: https://paste.dieggsy.com/2021-04-11T12:50:05
16:50:34
loke[m]
dieggsy: I'm afraid you have to be a bit more precise than just asking "what's wrong".
16:52:49
dieggsy
jackdaniel: I have slime installed and slime-mode enabled, doesn't seem to make a difference
16:54:20
jackdaniel
so, based on responses here: 1) fix the indentation, 2) provide more context of what is wrong
16:55:36
dieggsy
Ok, but indentation is /not/ a factor in the code results lol, thats' part of why i like lisp
16:56:32
dieggsy
Hmm. Well, if slime-mode is supposed to fix my indentation and it simply isn't ... ?
16:57:50
_death
dieggsy: slime sets up a lisp-mode hook (slime-lisp-mode-hook) that sets the lisp-indent-function to common-lisp-indent-function
17:00:47
dieggsy
sweet, yeah, i had done some gobbledygook with indentation ages ago. I actually used to use CL a good amount heh, it's just been a long time since i've revisited
17:03:17
dieggsy
And i think I found out what's wrong with my code. Every loop, i should be taking the previous value of j, but i'm also modifying j every loop and i think it's taking that. dunno, will investigate further
17:06:23
dieggsy
_death: that's probably part of the problem, but i think i'm still running into what i described above ? if i starts at 1 and j starts at 2, the next time i should be 2 (old j) and j should be 3 (old i + old j)
17:07:05
sm2n
(ql:quickload :mcclim) is failing for me on the package 3bz, with the error "The function SB-VM::MAKE-EA is undefined."
17:08:03
jackdaniel
sm2n: it seems to be a problem with sbcl changing its internals (i.e downgrade sbcl). the real problem is a library that depends on the implementation internals
17:08:15
_death
dieggsy: (loop for i = 1 then j #.(read) j = 2 then (+ i j) repeat 10 collect (list i j)) ;; evaluate two times; first enter FOR, then enter AND
17:12:15
dieggsy
_death: the problem statement is basically just sum all even fibonacci numbers until some limit FWIW. I can do it using a recursive function but i'm trying to figure it out using loop. not sure why input should be involved.
17:12:56
_death
dieggsy: input is involved because I want to show you how FOR and AND differs, so the form I gave asks you what to use
17:14:01
dieggsy
_death: oh, no. i got you. I missed the 'ENTER' bit, you're right. my bad again. thanks, this is great and a rather fascinating way to demonstrate the difference heh
17:14:31
_death
#. is read-time evaluation.. so while the form is read, it asks you for the value to use
17:15:41
dieggsy
interesting. cool. and does indeed solve my problem in this case actually, i think i was just modifying bits of the code carelessly. thanks!
17:18:54
dieggsy
How uncommon or looked down upon is it to use keywords in loop e.g. (loop :for ... :then )
17:19:10
dieggsy
it works, and it kind of separates the keywords with highlighting from the rest of the code. but is this considered bad style?
17:35:30
mfiano
I like it because a) it highlights it differently which is (imo) easier to read, and b) it doesn't intern symbols into my package, which might make completion of similar symbols more annoying.
18:01:29
fiddlerwoaroof
I don't like keywords because all the extra colons are too much syntax for me :)
18:18:20
jasom
Let me know if this is too off-topic, but woud you call the traditional lisp implementation of incremental compilation a jit or not? To me, requiring explicit compilation disqualifies something as a JIT, so the traditional implementation is not, but a case could be made for e.g. SBCL where it will sometimes (previously always) compile at EVAL time.
18:20:33
jasom
The 3 sides were roughly "All runtime compilation qualifies as JIT" "Compilation must be implicit to qualify as JIT" and "Some form of dynamic recompilation is necessary to qualify as JIT"
18:23:42
_death
I think the JIT buzzword was mainly associated with bytecode that gets compiled to native code
18:26:22
_death
then there was AOT that had the bytecode translated and the final result delivered, and dotnet had that GAC..
18:37:26
asarch
How do you destroy objects? I mean, I have (defun foo () ...) and then I use (foo ...) and then I no longer need foo. How would I deleted it? (setf foo nil)?
18:40:00
lotuseater
and giving the same function another symbol name eg ^ for expt does (setf (symbol-function '^) #'expt)
18:41:07
phadthai
yes removing references to the object should allow it to eventually be freed, the time when it'll actually be done is implementation dependent however, with some implementations allowing to force a GC run or to explicitly free/destroy specific objects
18:48:32
_death
you can add a function that tells swank to tell slime to visit a file, perhaps at some position if source info is available for a function name you might give