freenode/#lisp - IRC Chatlog
Search
3:09:13
aeth
Alternatively, if you have to have a constant and don't need it to be global, you can generate the resulting form (e.g. the resulting defun) via a macro to essentially be the same thing as what a constant is.
3:10:22
aeth
yes, you would essentially be writing a macro that uses symbol-macrolet internally to produce a "constant"
3:17:26
aeth
pjb: I disagree with what you said about literals, though. A literal (well, a literal sequence like "foo" or #(1 2 3) or '(1 2 3)) is a de facto constant, and can be detected as such within function scope with some compilers, such as SBCL. So you can use a literal created within a macro or created by '#. (preferably the macro route, it's cleaner) and it's de facto constant as long as it doesn't leave the function.
3:17:49
aeth
pjb: And it might have all of the optimizations that a constant has, but you have to make sure that it doesn't leave the function, since out of the function the information that it's a literal is lost.
3:19:34
aeth
(The macro or '#. to portably create one is only necessary when it's more complicated than what ", '(, and #( can give, of course)
3:21:02
aeth
e.g. (defun foo () (let ((s "foo")) (setf (aref s 0) #\a) s)) ; SBCL complains, and if your CL compiler doesn't, complain to your compiler's authors.
3:21:33
pjb
aeth: (values (eql (read-from-string "42") (read-from-string "42")) (eql (read-from-string "\"42\"") (read-from-string "\"42\""))) #| --> t ; nil |#
3:22:22
aeth
pjb: "SBCL complains, and if your CL compiler doesn't, complain to your compiler's authors."
3:23:47
pjb
To be precise, (let ((foo #(1 2 3))) (setf (aref foo 0) 0) foo) is implementation dependent. But the point is that #(1 2 3) may be not immutable.
3:24:24
aeth
pjb: That's funny that you said that SBCL diverges from CL because it cites the spec in its warning, so I'm sure they've heard that criticism before.
3:26:28
aeth
pjb: Anyway, my point is that #(1 2 3) can be treated as a constant as long as it's in limited scope (usually function scope, but your LET at a top level is also detected by SBCL). Once it's passed around to some random functions doing whatever, the information is lost because it's not tagged as such. Of course, mutating can still cause issues, you're just going to get unexpected bugs on some implementations.
3:28:04
aeth
Mutating literals in SBCL, which you can do once you pass it around enough to make the compiler lose track, is a bad thing and that's how e.g. you get objects with some point-vector #(0 0 0) starting at a different spot every run instead of starting at the point (0, 0, 0)
3:29:17
moldybits
pjb: well, i want to communicate that it won't be changed, which is why i used defconstant originally.
3:29:33
loke
aeth: But mutating #(1 2 3) is undefined beahviour according to spec. SBCL could very well throw an _error_ instead of just a warning.
3:31:18
moldybits
what does +foo+ signify that's incompatible with (defparameter +foo+ 42) (or symbol-macro)?
3:31:26
loke
pjb: wouldn't that give you all sorts of problems if you try to do, say: (flet ((foo () ...)) ...)
3:33:53
aeth
(alexandria:define-constant +foo+ "foo") (setf (aref +foo+ 0) #\a) ; well, SBCL warns here, too, but it still goes ahead and turns it into "aoo", just like the function
3:37:42
aeth
define-constant is probably the best way to do it. Someone setting an element of +foo+ is doing something visually quite wrong to any informed reader, just by the +s in the name of the constant.
3:38:20
moldybits
(defparameter +magic+ "FOO") ; i'm using ++ to say +magic+ won't be bound to anything else. "FOO" won't be modified either but i don't care to communicate that.
3:44:50
aeth
moldybits: I think it's safe to use (alexandria:define-constant +magic+ "FOO" :test 'string=) for that because any non-trivial project is going to have alexandria and uiop loaded into the image already, so they're effectively free dependencies.
3:46:35
pjb
moldybits: +foo+ means that you cannot rebind it. (setf +foo+ …) and (let ((+foo+ …)) …) will fail.
3:46:57
pjb
moldybits: but with symbol macros, you cannot (setf foo …) but you can (let ((foo …)) …).
4:08:39
aeth
loke: Afaik it isn't if the symbol macro is "foo"... but it's still not ideal because you can still set elements of it with aref
4:12:59
loke
aeth: well, you wouldn't be if you defined it with DEFCONST anyway. Wasn't the point that you'd be replacing DEFCONST with D-S-M?
4:23:53
drmeister
I can get a monolithic fasl to build but it has problems loading - I'm looking for insight.
5:12:07
akater
pjb: constantp returns t for my constant. Does it still mean defconstant is useless? I also don't see any warnings even though it seems to be used in code.
5:16:06
loke
Here is a place I'm using it: https://github.com/lokedhs/maxima-client/blob/master/infoparser/infoparser.lisp#L35
8:49:41
flip214
drmeister: I heard that (at least SBCL) allows to just "cat" FASLs together -- that would give one monolithic file, too.
9:07:37
splittist
shka__: see also the *-bundle-op ASDF operations (and relatives) e.g. monolithic-compile-bundle-op
9:41:11
schweers
(swank:create-server) returns immediately, does anyone have an idea why? This is regardless of whether I specify :dont-close or not. I have a shellscript which calls sbcl like this, which works:
9:41:11
schweers
sbcl --dynamic-space-size ${HEAPSIZE} --eval '(asdf:load-system "swank")' --eval "(swank:create-server :dont-close t :port ${PORT})"
9:42:09
pjb
schweers: swank server may run in the background, depending on swank:*communication-style*
9:55:26
schweers
How that I’ve loaded swank via asdf, the dumped executable seems to no longer work on another machine. I’m probably missing something really obvious, can anyone point me in the right direction?
9:57:46
schweers
I get an error message on the terminal claiming that the process exited with exit code one. This happens when I call create-server (as far as I can tell).
10:00:20
jdz
schweers: I have this in my build script before dumping an image: (swank-loader:init :load-contribs t :setup nil :reload t)
10:01:52
schweers
It seems that the ASDF system already does the init call, if I understood the manual correctly.
10:02:16
schweers
I inserted format forms before init and create-server, and neither are executed (as far as I can tell).
10:03:31
schweers
On the machine where I build the executable said format forms are executed and I can see the result
10:05:46
schweers
This is really weird. I have a mapping from strings to functions (all with zero arguments). Every argument passed from the shell is used to call such a function. They all work fine, apart from the new one for swank, which only works on my local machine.
10:13:09
schweers
Okay, there seems to be some other problem. I commented all the swank code out, and I still have this problem.
12:13:32
jmercouris
Hi everyone, I'm having trouble adding :perform test-op with FiveAM to my ASD file and having my system load properly
12:13:39
jmercouris
I've made a gist with the information here: https://gist.github.com/jmercouris/e960b200962f640b67f778e23d48e4df
12:14:03
jmercouris
jackdaniel: I tried to follow the guide on your website, but I must be doing something wrong, as it is not working for me :\
12:15:31
schweers
jmercouris: you need a :in-order-to ((test-op (test-op "app/test"))) in your "app" defsystem
12:17:21
scymtym
jmercouris: also, you typically use (uiop:symbol-call '#:app-test '#:test-all) in the asd file and (in-package #:app-test) (defun test-all () (fiveam:run! 'SUITE-NAME)) in tests/app.lisp
12:17:25
schweers
Oh, I didn’t see you added your error at the end. I guess you have a different problem.
12:18:20
scymtym
but what schweers says is also good since otherwise (asdf:test-system "app/test") will work, but not (asdf:test-system "app")
12:19:36
scymtym
(uiop:symbol-call :fiveam :run! #'app.test:test-all) tries to intern app.test:test-all when READing the asd file
12:21:49
schweers
uiop has some weird tricks to circumvent the problem. This is why my code is also quite ugly. But it works
12:22:41
jackdaniel
I think that the right solution (in a parallel universe) would be that system definitions are read by a reader which is not the Common Lisp reader
12:24:37
jackdaniel
as of the guide on my website, yes, ASDF integration section is wrong (for this very reason)
12:28:20
scymtym
jmercouris: typically yes. you could also have a separate file like test-package.lisp or something. but the package is defined when your test files are loaded, not when the system definition is loaded
12:28:29
jmercouris
new asd file, new errors: https://gist.github.com/jmercouris/0b08961b11b6b0db38534201d0a23180
12:31:23
scymtym
add :in-order-to ((test-op (test-op "add/test"))) to the main system, then try (asdf:test-system "app")
12:32:23
jmercouris
I don't feel like it should be called inferior lisp, cl is way better than elisp
12:32:46
jmercouris
I'm aware of the reasoning behind the name inferior lisp, to be clear I am making a joke
12:35:13
jmercouris
however it did not automatically load fiveam even though the system app/test depends on it
12:35:44
jmercouris
do I have to first do (ql:quickload "app/test")? and then (asdf:test-system "app")?
12:37:17
scymtym
it should work once fiveam is installed. i think ASDF:TEST-SYSTEM is not hooked up to install systems via quicklisp
12:42:18
ecraven
maybe check the source? I'm no expert, but I've found some information I sought in the sources, they seem approachable
12:43:43
phoe
I don't really know where to start in the source. All I know that slime-company shows "function" as being bound as a type, and I don't know where it gets that information from.
12:45:13
jackdaniel
phoe: grep for "defimplementation find-definitions" and "defimplementation find-source-location"
12:48:28
phoe
jackdaniel: this still doesn't answer my question. For instance, (swank::find-definitions 'member) only lists a DEFUN, a DEFTRANSFORM for sequences, and SBCL's DEFKNOWN.
12:49:45
phoe
And swank obviously knows which symbol is defined as a type and which are not. That knowledge doesn't seem to come from SWANK::FIND-DEFINITIONS though.
12:54:32
moldybits
ah, when i update a macro i need to reevaluate all the procedures that use it, too.
12:58:12
phoe
okay, found it: https://github.com/slime/slime/blob/e6d215d77148079799d2fc3253ef402b5d9ed4d7/contrib/swank-util.lisp#L42
13:00:33
schweers
I build my program with asdf:make. Is there a way to use core compression when using sbcl?
13:05:54
schweers
Sorry, I (sorta) lied. I have a :build-operation and :build-pathname directive (is that the correct term?) in my system definition
13:07:41
schweers
I must have copy and pasted this from somewhere. I’m afraid I never really understood how asdf does these things.
13:09:23
phoe
I use Shinmera's deploy that has this baked in: https://github.com/Shinmera/deploy/blob/7bd96ba3f88a424e03394de1adadf4a4993f849c/deploy.lisp#L153