libera/#commonlisp - IRC Chatlog
Search
19:51:58
thuna`
Does anyone know why I am getting "Failed to find the TRUENAME of /tmp/packages.lisp" when doing (asdf:load-system)?
19:53:04
Bike
you're loading a system in /tmp that includes a packages.lisp but there is no such file?
19:56:40
Bike
i mean, kind of anything? what's in tmp, what system you're loading, what the definition of that system is, where asdf is looking for the system, what you are trying to do overall, etc
20:08:05
thuna`
Bike: I shouldn't be doing anything out of the ordinary. I have a .asd file in a directory with the other components and I'm trying to load it using load-system from the Slime repl. The tmp folder doesn't have anything interesting
21:12:33
jackdaniel
thuna`: you probably compiled asdf:defsystem with C-c C-c, temporary file got placed in /tmp/ and the base path were set invalid
1:06:17
Guest74
I don't know how people write java. I thought I'd take a look at the code of Languagetool that mfiano mentioned. My eyes are confused.
2:33:04
ck_
Guest74: only briefly, so I don't get slapped with the off-topic parenthesis, I'll say that for most of these very ritualistic languages, tooling probably plays a major role; it's why "the IDE" is so important there
5:35:07
contrapunctus
I saw the `<slot>-of` convention for accessors on Cliki yesterday, and was thinking of using it...any reason not to?
5:38:21
mfiano
There was a lengthy discussion about this yesterday in #clschool that I really don't want to repeat, but the short answer is, don't. Always %-prefix your slot names, and never export %-prefixed symbols.
5:45:30
contrapunctus
I've noticed the %slot convention, but don't understand the reason for it. Is it to act as a warning sign for code depending on implementation details?
5:45:47
pranavats
I hadn't thought of %-prefixing my slot names. That might solve some name clash issues for me.
5:45:53
Nilby
but people who like to follow opinionated style pronouncements probably won't be using lisp in the first place
5:46:56
mfiano
contrapunctus: The rationale is simple. Slots are implementation details. They should _never_ be exposed to consumers of your code.
5:47:34
mfiano
By %-prefixing slot names and remembering never to export % prefixed symbols, you are protecting yourself and your users from bypassing protocols.
5:48:32
mfiano
Also, every experienced Lisper knows that %-prefixed symbols already means dangerous, or low-level.
5:49:58
mfiano
It is the most important style convention in my opinion. Unlike most other languages, constructs such as accessors, classes, etc are not exported, but _symbols_ are.
5:52:58
contrapunctus
I've heard about never exposing slots to consumers, and I can see how it makes code brittle, but so far I've accessed slots directly all the same...mainly because `with-slots` is much more concise than `with-accessors` x-P
5:53:49
mfiano
contrapunctus: That is a problem if your users want to extend an accessor that sets a slot value in their code, by adding an auxillary method.
5:54:16
mfiano
and if you don't want them to, you don't export that accessor, and add another %-prefixed accessor for your own internal use.
5:55:38
pillton
You can also specify more than one reader, writer and/or accessor e.g. ((name :initarg :name :reader name :accessor %name)).
5:58:31
contrapunctus
I'm talking the increased verbosity of `(with-accessors ((a a) (b b) (c c)) obj ...)` vs `(with-slots (a b c) obj ...)` ...but I suppose it's no worse than `let`.
5:59:06
mfiano
contrapunctus: My recommendation is to prefer explicitness over with-slots/with-accessor/symbol-macrolet. It is easier to understand, and you don't run into performance traps by eg; evaluating an expensive accessor more than once.
6:03:06
mfiano
Indeed I am. Considering an accessor can be any arbitrary method that performs any amount of work as part of its logic, using such a thing would result in redundant computations, which is a problem both for performance reasons, and that of side-effects.
6:03:53
mfiano
But moreso because (accessor foo) just reads better than some symbol that you have to scan backwards to see how it was defined and its value mutated along the way.
6:07:45
mfiano
I'm not saying symbol macros (which includes with-slots and with-accessors), but their utility is limited in my opinionated idea of good code.
6:12:48
mfiano
If you don't know what they are, don't worry; you're not missing much. Just read Let Over Lambda some time.
6:13:41
mfiano
That book is very much a "hey, look what macros can do" rather than a practical book.
6:18:52
beach
contrapunctus: WITH-ACCESSORS rarely have entries like (a a) (b b). More likely it will be (a some-package-prefix:a) (b some-package-prefix:b).
6:19:23
mfiano
Sure. Like most Lispers, I have different advice on good style than others. I would suggest you not to blindly apply this style to your code, but to think of why it is preferred by me (and some others)
6:22:57
pjb
contrapunctus: consider: (defpackage "POO" (:use "CL") (:export "KOO" "SOO")) (in-package "POO") (defclass koo () ((soo :initarg :soo :accessor soo)))
6:23:23
pjb
then since soo is exported, a client can write: (setf (slot-value (make-instance 'koo) 'soo) 42)
6:24:13
pjb
accessing the slot directly! But perhaps you have additionnal methods on the accessor soo to validate or synchronize the the slot. With (setf slot-value) those methods wouldn't be called, and the client would have broken your class.
6:24:32
pjb
contrapunctus: instead with: (defpackage "POO" (:use "CL") (:export "KOO" "SOO")) (in-package "POO") (defclass koo () ((%soo :initarg :soo :accessor soo)))
6:24:32
beach
contrapunctus: The -of convention suggests that it accesses a slot. But you want to do everything you can to prevent a slot from being even suggested. So this convention has the same problem as the get- and set- convention in other languages. You want to leave the flexibility of changing the implementation from accessing a slot to computing the value, or vice versa.
6:25:12
beach
contrapunctus: Or else, you would have to name all the functions in your protocol with the -of convention, which would be truly silly.
6:25:25
pjb
(he can stil use it, but now he must write: (setf (slot-value (make-instance 'koo) poo::%soo) 42), with both :: and % clear markers that he shouldn't.
6:25:54
pjb
In any case, the reader of the source will know that something iffy is occuring with this ::%
6:27:25
beach
pjb: Though if you saw the discussion in #clschool yesterday, you know that if you have a protocol package that contains only exported symbols, then the implementation package need not have any exported symbols at all, so no need for the % convention.
6:28:22
pjb
beach: exactly, but we still have two different symbols POOapi:SOO and POOimplementation::SOO
6:29:09
beach
contrapunctus: Imagine you have DATE-OF-BIRTH-OF as a slot reader, but you have AGE as a function that computes the age from the date of birth and today's date. Now if you decide to cache that computation, do you then change the name of the protocol function?