libera/#commonlisp - IRC Chatlog
Search
20:08:29
foxfromabyss
1) is it possible to extend existing methods(?), such as `+` or `eq` for new classes, without jumping through too many hoops?
20:08:29
foxfromabyss
2) let's say I have 2 classes. Class A and Class B. Class B has a field with value of Class A. I have written a comparator for Class A. Is it possible to piggyback on that comparator for `sort`?
20:11:13
pjb
foxfromabyss: yes: (shadow '+) (defgeneric + (a b)) (defmethod + (a b) (cl:+ a b )) (defmethod + ((a string) (b string)) (+ (parse-integer a) (parse-integer b)))
20:12:42
foxfromabyss
too many hoops is just me being lazy, and shadowing feels like smth that would break a lot of stuff, but maybe not
20:13:54
foxfromabyss
unrelated, is there an example somewhere of how people use SLIME/SLY? So far i've been just pasting stuff from the source file and testing it there, but it feels like I am underutilizing a lot of features
20:18:51
contrapunctus
foxfromabyss: `M-x slime` -> `(ql:quickload :my-project)` -> edit code in buffer -> `M-x slime-eval-defun`
20:20:38
pjb
foxfromabyss: you can avoid shadowing, by using symbols with a different name: (defgeneric plus (a b)) …
20:25:45
frodef
Hi all, is there some package that provides a compatibility layer for the MOP? Such that I can call e.g. sb-mop:class-slots without relying explicitly on sbcl/sb-mop ?
20:27:00
jackdaniel
c2cl supplements implementation-specified operators like defmethod with wrappers when the implementation doesn't implement fully the mop protocol and that can be fixed with a wrapper
22:01:29
yottabyte
why would one use flat instead of let? you can define functions (lambdas) with let, no?
22:03:03
semz
If you define a function with (let ((f (lambda ...))) ...) you have to call it with (funcall f ...) rather than being able to use (f ...)
1:22:12
Bike
https://plaster.tymoon.eu/view/2874#2874 can i get a sanity check here? sbcl gives me a type warning about this, but I don't see the problem
1:31:03
moon-child
perhaps it is assuming that CONS might be nil? Obviously that can never happen, but
1:56:42
lagash
What do folks here use for a linter/code formatter for CL, particularly as a pre-commit hook?
1:57:23
moon-child
pre-commit hooked autoformat is dumb. Formatting can not always be applied automatically
1:59:13
moon-child
mfiano: it also depends on the smarts of the formatter. Slime still can not indent moderately complex loops
2:00:03
lagash
mfiano: I have been using Sly, although come to think of it, not every time I've formatted my CL code, was Sly running.. that might be the issue?
2:00:19
mfiano
Stemming from its piggy-backing off of emacs-lisp, which does not have the concept of packages.
2:01:25
mfiano
Sly can indent moderately complex LOOPs just fine though, so I'm not sure about SLIME in this regard.
2:02:13
mfiano
I have written hundreds of line loops before, and indentation has never been an issue.
2:02:18
EdLangley[m]
Because, even if the formatting isn’t always great, it reduces diffs if you apply it consistently
2:02:26
lagash
It's just that Emacs and/or Sly can't seem to make up its mind when I, say, format an entire file..
2:04:25
mfiano
I also use aggressive-indent-mode, but should point out that the code and its dependencies should also be loaded; it isn't enough to just have SLIME/SLY running due to macro definitions.
2:05:19
lagash
mfiano: so depending on if I had Sly running or had the code loaded or whatnot, Emacs might format things differently?
2:06:42
EdLangley[m]
SLIME/Sly indentation is based on introspection of function and macro information
3:19:04
EdLangley[m]
Unless it was declared inline or you have other saved references to the old definition (e.g. `(funcall #'foo …)`)
3:19:39
EdLangley[m]
If you always refer to the function by name rather than with #', it should just work.
3:24:29
Bike
redefining a function is undefined if it was part of a compilation unit. otherwise it's fine
3:39:03
seragold[m]
If in CL redefining CLOS class just works across existing instances it would be weird if redefining a normal function did not IMHO
3:43:05
Alfr
unixlisp, it's defined quite in detail, it replaces the function binding in the global environment; mostly subject to the constraints listed in
3:44:07
Bike
if you continue this routine of insisting everything is undefined despite all reason i'll ban you, alright?
3:44:40
Alfr
unixlisp, 3.2.2.3 also says that, apart form the listed exceptions the new definition takes precedence.
4:00:51
beach
unixlisp: Why do you think that? I.e., that redefining a function is always undefined. I mean, is that an opinion of yours? Or something you concluded from reading the standard?
4:03:42
unixlisp
beach: I should carefully read 3.2.2.3, redefining function is not always undefined.
4:06:49
beach
unixlisp: So let me ask you again. When you said "I think redefining function is always undefined", was that an opinion of yours, or something you concluded form reading the standards document?
4:09:55
unixlisp
Oh, I said the reading is not complete, so the conclusion is wrong. (that is my opinion from read spec.)
4:12:05
unixlisp
In general, I always wonder redefining is a defined behavior or not. uch as defparameter, etc.
4:13:39
beach
It would be very strange for a language to include operators that always have undefined consequences.
4:18:03
EdLangley[m]
As a rule, Common Lisp is defined for a workflow that involves building up a program incrementally.
4:18:54
EdLangley[m]
There are exceptions (defstruct, defconstant), but it would be strange for most of the fundamental operations not to have well-defined redefinition semantics.
4:20:59
beach
unixlisp: So here is a suggestion. The next time you "think" something like that, maybe phrase it as a question instead, like "Is redefining a function always undefined behavior"?
4:36:34
beach
masinter: It could be defined behavior only if the function is currently undefined. Also, consider SYMBOL-FUNCTION obsolete in favor of FDEFINITION.
4:37:54
beach
masinter: DEFSTRUCT is pretty much like that. The first time you use it, it is defined behavior.