freenode/#lisp - IRC Chatlog
Search
9:17:36
pve
beach: ok, so the discrepancy must have been caused by something I was loading into my slime session (need to investigate that), because if I compile and load my example from the shell without loading any init files or libraries it prints COMMON-LISP-USER::ARRAY in both cases
9:18:39
phoe
I mean, PACKAGE-NAME SYMBOL-PACKAGE should *not* return CL-USER in this case because ARRAY is imported from CL
9:21:11
no-defun-allowed
The two (or three?) means of compiling and/or loading that code appear to do different things though.
9:22:05
phoe
"For each such name, if a corresponding symbol is not present in package (directly, not by inheritance), then a corresponding symbol is created with that name, and inserted into package as an internal symbol."
9:27:06
White_Flame
hmm, nevermind, I think that the eval-when should guarantee the shadowing before the format expression is read
9:28:22
White_Flame
this is why it's important to have a separate package.lisp to set everything up in a separate file
9:29:22
phoe
the SHADOW call should be a part of DEFPACKAGE, that's my only real gripe with this code
9:31:08
pve
my original problem was probably caused by some package-fu I'm doing in the project I'm working on
10:09:02
beach
Am I reading the dictionary entry for DEFCONSTANT right in that the constant is not defined at compile time?
10:09:46
beach
It says that the compiler must recognize that the name names a constant variable, but not that the value is available at compile time.
10:11:14
phoe
"An implementation may choose to evaluate the value-form at compile time, load time, or both."
10:11:43
phoe
if the value is allowed to be available only at load time, then it may *not* be available at compile time
10:12:24
phoe
it is allowed not to be available at compile-time, BUT it also says that this behavior is implementation-dependent
10:12:46
phoe
so as an implementer you can do e.g. what SBCL does which is to EVAL-ALWAYS %DEFCONSTANT
10:13:15
phoe
but it seems that as a user you cannot really depend on the constant being available at compile time.
10:13:19
beach
Right, so a file containing (defconstant bla ...) (defun foo (..) bla) may or may not work.
10:14:21
phoe
"If a defconstant form appears as a top level form, the compiler must recognize that name names a constant variable."
10:16:39
phoe
but this way is trivial to implement and preserves language semantics, since constant redefinition is undefined
10:17:31
beach
I would tend to signal an error, or at least a warning, but I can't see whether it would be allowed to do that.
10:20:01
beach
That the compiler did not have access to the value so it had to compile it as an access to a variable defined at run time.
10:21:50
beach
That the compiler did not have access to the VALUE at compile time, so it could not compile the code as if BLA were the constant that it is defined to be. And instead it had to compile it as an access to a variable at run time, thereby degrading performance.
10:23:03
phoe
I think I partially understand... why would it not have access to VALUE at compile-time? an implementation is allowed to evaluate the DEFCONSTANT value at compile-time, so signaling a warning in that case sounds like a making bugticket for your own self
10:23:38
phoe
and if user code is built in a way that doesn't make it possible, *then* it's a bug on the user side
10:23:43
beach
Because the implementation chose not to evaluate the initialization at compile time, or at least chose to not store that value for compile-time availability.
10:24:11
phoe
but then it's allowed to do that, so I guess that the only warning it can signal would be a STYLE-WARNING
10:28:05
iissaacc
i redefined a method from a library in some code, and I don't get any warnings and the redefinition works as expected in a REPL session. But when I tested it in a fresh REPL session the old behaviour associated with that method happens, i.e the redefinition doesnt seem to have taken effect. Does anyone know why this could be?
10:29:24
phoe
but it is also allowed to *silently* create a brand new generic function BAR:QUUX and then define a method on this
10:30:09
iissaacc
right, so my redefinition is actually creating a new generic function in my package
10:30:49
phoe
that's why I wish there was a toggle to cause DEFMETHOD to error if the respective generic function is not found.
10:33:58
phoe
one of the few cases where Lisp is allowed to completely silently do The Wrong Thing™ and the blame is fully on the programmer for not checking their symbols.
10:35:11
iissaacc
what would be cool would be being able to inspect function definitions, but afaik this isnt possible because things get compiled straight away
14:55:32
mseddon
has any lisp implementation used the recursive-p argument for read-char? What is it supposed to do there? It only makes sense for me within read
15:00:39
beach
Yes, it is meant for use when READ calls READ recursively. You can use it when you call READ from one of your reader macros, for instance.
15:00:50
_death
"It is also necessary to distinguish betwene top-level and internal calls to READ-CHAR and READ-LINE and others for the purposes of EOF handling."
15:05:52
beach
mseddon: One example is the handling of #= and ##. When RECURSIVE-P is false, a new dictionary for those is created. But you don't want to create a new dictionary for a recursive call.
15:07:21
mseddon
beach, yes, but since read-char is not reentrant, and just returns a character, eof-error or signals an error, I don't see what read-char needs recursive-p for, since I figure the recursive-p would be handled by the macro character #=
15:08:04
mseddon
ah yeah, that's the odd one. read-char, peek-char and unread-char all take recursive-p who's purpose is a mystery
15:08:30
_death
mseddon: make sure you include the [...] part.. I also put up a gnus friendly version in a single file (cl-su-ai) at https://github.com/death/gnus-friendly-archives
15:12:40
edgar-rft
cltl2 has some lengthy explanations about recursive-p under https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node195.html
15:14:59
edgar-rft
in particular 1) #n= and #n# syntax 2) whitespace presevation and 3) end-of-file handling
15:18:01
flip214
is there a way to make QL fetch a tarball of FASLs instead of source files? I'm thinking about pre-compiling all (or at least most) required libraries for a container setup.
15:18:52
flip214
QL because then the dev and release code would be the same, only the config (which base URL to fetch from) would be different
15:54:02
phoe
random rant: :BEFORE and :AFTER methods should be capable of returning the list of arguments that is then passed into/out of the primary method
15:54:35
phoe
I need to do literally everything in :AROUND if I want to validate arguments while providing valid STORE-VALUE restarts that will mutate the *proper* place
15:56:31
shka_
if only before bothers you, it can be solved by adding separate generic function before-foo which will call the foo in :AFTER
15:57:34
phoe
(defgeneric frob (thing)) (defmethod frob :before (thing) (check-type thing integer)) (defmethod frob (thing) thing) (handler-bind ((type-error (lambda (c) (declare (ignore c)) (invoke-restart 'store-value 42)))) (frob :forty-two))
16:03:00
phoe
I'm just annoyed that :BEFORE is the wrong tool for this job, it would have been much cleaner in my eyes
16:07:19
p_l
among today's internet woes, I'd like to give a honorable and channel-related mention that AS 5 is apparently still alive and took part in the brouhaha (AS 5 = Symbolics :D)
16:07:30
phoe
this is going to fail in case of the effective method being precomputed and then applied
16:08:25
phoe
this is a dangerous idea, still, mutating the arglist is kinda like pulling the rug that my GF is standing on
16:29:08
phoe
Krystof: that's one idea, I'd need to pass types/validation into the method combination though, somehow
16:54:56
hendursaga
Can anyone recommend a good library for manipulating XML? Not just parsing or processing, but manipulating and then outputting back to XML. Preferably with XPath or DOM/CSS selector support.
16:57:51
hendursaga
So far it seems lquery is my best bet, but I'm not sure how to replace XML with something like S-XML which would then be serialized back to XML.
17:23:20
hendursaga
There's just so many different libraries out there, so many Lisps, so little documentation.
17:59:56
VincentVega
Hi guys. I have stumbled upon this weird compilation vs evaluation deal, not sure what I am doing wrong: https://pastebin.com/J0A2sWYB
18:06:41
phoe
DEFCLASS or ENSURE-FINALIZED is not evaluated in such case because the error happens when macroexpanding the form
18:12:40
VincentVega
It also seems to be the case when quickloading a project. If the file has an error, it's as if no definition before the error ever got evaluated so I have to eval manually till the error. It's a bit annoying. tbh.
18:13:41
phoe
you should be able to click on the line in *slime-compilation-errors* and jump to the file position
18:17:10
VincentVega
Well, it's still weird, because if no changes should take effect, then the second compilation of the progn should yield the same result, shouldn't it?
18:19:32
phoe
the no-class-found error I get is consistent if I answer N to loading the created/broken fasl file
18:34:06
hendursaga
How might I use lquery to, say, append a string to the text of every <p> node? replace-with looks like it might work but I'm new to CL
18:36:29
hendursaga
I've been looking through sample code on Github but I can't see anything that might fit.
18:41:09
hendursaga
Basically, how do I refer to the current set of elements being acted upon inside replace-with?
20:50:12
macoy
Hi, I'm writing a Lisp-like language and was wondering if you guys could help me with a detail: In macro expansion time, does the interpreter basically traverse the entire AST recursively, and evaluate anything which happens to have a macro name by an open paren, regardless of any context? e.g. if I make up a DSL, but it wants to use a name which a macro also has, there's nothing to stop that macro from being expanded?
20:51:24
macoy
(because macro expansion time has no idea we're supposed to be interpreting it as a DSL marker)
20:54:03
phoe
"regardless of any context" is not really true, e.g. (case 42 (defun foo () ...) ...) will not macroexpand DEFUN
20:55:05
phoe
if your DSL performs some sort of code walking, then it can introduce its own macro system when it compiles your DSL down to your Lisp
20:58:16
macoy
phoe: Ah, I think I see what I was misunderstanding: I was imagining macro expansion would happen like function argument evaluation, where if you invoke a macro within another macro's arguments, the invoked macro (deepest) will be expanded first.
20:58:16
macoy
With the case example, it makes sense that macros actually need to be generated immediately once encountered, then that generated code is evaluated for further macro expansion.
20:58:17
macoy
So my DSL won't have problems with macro name collisions because I convert all the DSL symbols into something else (otherwise it wouldn't be a DSL, it'd just be Lisp)
21:02:12
phoe
and the macroexpansion may not even contain the form (BAR (BAZ ...)) or any form like it
21:04:53
macoy
phoe: That makes much, much more sense than what I was thinking. Thanks a lot, you've saved me a lot of heartache had I tried the other approach first! :)