jackdaniel changed the topic of #commonlisp to: Common Lisp, the #1=(programmable . #1#) programming language | Wiki: <https://www.cliki.net> | IRC Logs: <https://irclog.tymoon.eu/libera/%23commonlisp> | Cookbook: <https://lispcookbook.github.io/cl-cookbook> | Pastebin: <https://plaster.tymoon.eu/>
troojg has joined #commonlisp
zyd has joined #commonlisp
Volt_ has joined #commonlisp
eddof13 has quit [Quit: eddof13]
waleee has quit [Ping timeout: 252 seconds]
random-nick has quit [Ping timeout: 264 seconds]
istewart has joined #commonlisp
troojg has quit [Ping timeout: 260 seconds]
amb007 has joined #commonlisp
amb007 has quit [Ping timeout: 248 seconds]
<kagevf> [/map
<kagevf> sorry ... disregard that last one ...
RavenJoad has joined #commonlisp
<RavenJoad> Hey all, I am facing an issue with string formatting and outputting a string to a stream. The following is the minimum to reproduce this. (let ((stream 'nil)) (format stream "~a" "#(") (format stream "~a" ")")) I expect "#()" to be the final string, but SBCL return just ")", losing the leading "#(".
<RavenJoad> Oh... As soon as I post the question, I solve it. Only the final string was being returned from the progn. Duh. I needed a uiop:strcat to make this work.
<aeth> because format nil turns it into returning a string instead of writing to a stream
<aeth> use with-output-to-string stream instead of nil
<RavenJoad> aeth: I should rewrite the function to use that, for sure. That would make the block easier. Inside a with-output-to-string form, what should the destination of FORMAT be?
<aeth> whichever stream you bind it as
<aeth> ,(with-output-to-string (output) (format output "a") (formt output "b"))
<ixelp> ERROR: Undefined function FORMT called with arguments (#<STRING-OUTPUT-STREAM :CLOSED #x144102BE> "b") .
<aeth> ugh
<aeth> ,(with-output-to-string (output) (format output "a") (format output "b"))
<ixelp> => "ab"
<RavenJoad> Right. I need to more closely read CLHS before asking these questions. I'm doing code-gen and want to have the final destination be a string for unit testing and a file for actual output, so I guess I accidentally hacked together the same macro.
lucasta has quit [Remote host closed the connection]
Pixel_Outlaw has quit [Quit: Leaving]
<RavenJoad> I guess what I really want is with-output-to-stream, so I can plug in either *standard-output* or a file stream.
mrcom_ has joined #commonlisp
mrcom has quit [Ping timeout: 260 seconds]
spdegabrielle has quit [Quit: Connection closed for inactivity]
<RavenJoad> Does such a macro exist? I cannot seem to find one. I can do (princ (with-output-to-string ...) stream), but that always produces something on *standard-output*, which I don't want.
<pranav> RavenJoad: FORMAT can write formatted output to a given stream.
<shawnw> Look into UIOP's with-output and friends.
<RavenJoad> I think I may have an XY problem/desire here. I want my method to explicitly accept a stream, and produce the contents to that stream. Unit tests need this stream to be a string buffer, actual usage requires this stream to be connected to a file.
jweeks` has quit [Read error: Connection reset by peer]
Lord_of_Life_ has joined #commonlisp
Lord_of_Life has quit [Ping timeout: 252 seconds]
Lord_of_Life_ is now known as Lord_of_Life
istewart has quit [Quit: Konversation terminated!]
gorignak has joined #commonlisp
<Noisytoot> ,(let ((*standard-output* (make-string-output-stream))) (format t "a") (format t "b") (get-output-stream-string *standard-output*))
<ixelp> => "ab"
X-Scale has joined #commonlisp
<Noisytoot> RavenJoad: like that?
amb007 has joined #commonlisp
<RavenJoad> Noisytoot: I realized I XY-d myself into a writing format. I removed a uiop:strcat and have my unit tests use (uiop:with-output (str 'nil) (generate str)), which does what I want. I forgot I wrote a helper function to make calling generate easier in tests.
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
amb007 has quit [Ping timeout: 248 seconds]
troojg has joined #commonlisp
amb007 has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
<RavenJoad> I'm using trivia, and want to match against lists of either 1 or 2 elements, and throw an error otherwise. Reading the documentation does not show an "else" or
<RavenJoad> 't condition that I can use. Am I just missing something?
<char> RavenJoad: (_ ...) is the else case for trivia:match.
<RavenJoad> char: Perhaps I am missing something, but (trivia:lambda-match ((_ ...) (print "this is an error"))) fails to compile due to "too many dots".
<char> the dots are meant to be your code.
<|3b|> there is also ematch if you don't care about the specific error
<char> (trivia:lambda-match (_ (print "this is an error")))
<|3b|> and OTHERWISE if you want something that looks more like CASE etc
<RavenJoad> Whoops. I am too used to Scheme/Racket syntax. I thought it was a special thing here like over there.
amb007 has quit [Ping timeout: 252 seconds]
amb007 has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
X-Scale has quit [Quit: Client closed]
rozenglass has quit [Ping timeout: 255 seconds]
RavenJoad has quit [Ping timeout: 258 seconds]
Alfr has quit [Quit: Leaving]
char has quit [Remote host closed the connection]
decweb has quit [Ping timeout: 252 seconds]
aeth_ has joined #commonlisp
aeth has quit [Quit: ...]
jon_atack has joined #commonlisp
jonatack has quit [Ping timeout: 245 seconds]
Alfr has joined #commonlisp
aeth has joined #commonlisp
aeth_ has quit [Quit: ...]
rtypo has quit [Ping timeout: 248 seconds]
benjaminl has joined #commonlisp
amb007 has quit [Remote host closed the connection]
amb007 has joined #commonlisp
younder has quit [Remote host closed the connection]
younder has joined #commonlisp
JuanDaugherty has joined #commonlisp
amb007 has quit [Ping timeout: 244 seconds]
amb007 has joined #commonlisp
semarie has quit [Quit: WeeChat 4.3.5]
semarie has joined #commonlisp
wacki has joined #commonlisp
troojg has quit [Ping timeout: 248 seconds]
cmack` has joined #commonlisp
cmack has quit [Ping timeout: 252 seconds]
mgl has joined #commonlisp
donleo has joined #commonlisp
pve has joined #commonlisp
cage has joined #commonlisp
cage has quit [Excess Flood]
cage has joined #commonlisp
attila_lendvai has joined #commonlisp
rozenglass has joined #commonlisp
beach` has joined #commonlisp
beach has quit [Killed (NickServ (GHOST command used by beach`!~user@2a01:cb19:682:4600:7421:d5b5:783d:4eb2))]
beach` is now known as beach
shka has joined #commonlisp
JuanDaugherty has quit [Quit: JuanDaugherty]
awlygj has joined #commonlisp
Volt_ has quit [Quit: ]
alcor has joined #commonlisp
wacki has quit [Read error: Connection reset by peer]
wacki has joined #commonlisp
attila_lendvai has quit [Ping timeout: 252 seconds]
mgl has quit [Ping timeout: 272 seconds]
random-nick has joined #commonlisp
chkhd has quit [Quit: zzzZZZzzzzZZZZzzz...]
chkhd has joined #commonlisp
mwnaylor has quit [Remote host closed the connection]
mwnaylor has joined #commonlisp
johnjaye has quit [Ping timeout: 276 seconds]
johnjaye has joined #commonlisp
donleo has quit [Remote host closed the connection]
donleo has joined #commonlisp
donleo has quit [Client Quit]
random-nick has quit [Ping timeout: 248 seconds]
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
mwnaylor has quit [Ping timeout: 248 seconds]
X-Scale has joined #commonlisp
AetherWind has joined #commonlisp
awlygj has quit [Ping timeout: 248 seconds]
AetherWind has quit [Ping timeout: 244 seconds]
awlygj has joined #commonlisp
AetherWind has joined #commonlisp
X-Scale has quit [Ping timeout: 256 seconds]
random-nick has joined #commonlisp
awlygj has quit [Quit: Lost terminal]
Inline has joined #commonlisp
brokkoli_origin has quit [Ping timeout: 252 seconds]
brokkoli_origin has joined #commonlisp
chkhd has quit [Quit: zzzZZZzzzzZZZZzzz...]
Mandus has quit [Ping timeout: 255 seconds]
Mandus has joined #commonlisp
amb007 has quit [Ping timeout: 260 seconds]
amb007 has joined #commonlisp
decweb has joined #commonlisp
Inline has quit [Ping timeout: 276 seconds]
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
waleee has joined #commonlisp
edgar-rft_ has joined #commonlisp
waleee has quit [Ping timeout: 245 seconds]
edgar-rft has quit [Ping timeout: 252 seconds]
ElKowar has quit [Quit: Ping timeout (120 seconds)]
ElKowar has joined #commonlisp
edgar-rft_ is now known as edgar-rft
JuanDaugherty has joined #commonlisp
attila_lendvai has joined #commonlisp
rtypo has joined #commonlisp
amb007 has quit [Ping timeout: 276 seconds]
amb007 has joined #commonlisp
yitzi has joined #commonlisp
mgl has joined #commonlisp
JuanDaugherty has quit [Quit: JuanDaugherty]
brokkoli_origin has quit [Ping timeout: 252 seconds]
brokkoli_origin has joined #commonlisp
mrcom_ has quit [Remote host closed the connection]
mrcom_ has joined #commonlisp
rainthree has joined #commonlisp
<ixelp> Rondam Ramblings: Global variables done right
shawnw has quit [Ping timeout: 258 seconds]
<mrcom_> So Lisp2 for variables?
mrcom_ is now known as mrcom
Lord_Nightmare has quit [Quit: ZNC - http://znc.in]
Lord_Nightmare has joined #commonlisp
lucasta has joined #commonlisp
green_ has joined #commonlisp
<alcor> rainthree: Regarding point #3, I believe this is why the *mufflers* convention is used for naming dynamic variables, so the risk of accidential rebdinding is reduced.
<|3b|> it is, and #3 notes that the ** convention is a sign there is a problem
yitzi has quit [Remote host closed the connection]
<alcor> I've also seen people use +constant-variable-name+ for constants, to indicate that the variable is (semantically) used as a constant and should not be rebound.
* |3b| agrees that there should be separate namespaces for constants and specials
<|3b|> ++ is more intended to indicate the variable was bound with DEFCONSTANT and that attempting to rebind it is undefined behavior. indicating it is semantically constant is just a derivative of that
AetherWind has quit [Quit: leaving]
<alcor> I have an issue with the way defconstant is implemented in some CL implementations, actually – it impedes my "live coding" workflow where I write code do the "eval as you go" thing, evaluating definitions of the program while writing it – Doing SLIME's `slime-eval-buffer' on a buffer with defconstant in it results in an error condition being raised (at least with SBCL) :(
<|3b|> would you rather it leave old code using the old value without telling you?
<alcor> Of course not, but I wish there was a way to just reevaluate the defconstant form without it complaining. I mean explicitly, on user request.
<|3b|> you can teach slime how to do that if you really want to, if picking the "do it anyway" restart is too much work
<alcor> Something like a hypothetical M-x slime-force-eval-buffer would be useful in this case, yes.
<|3b|> or just use defparameter until you think the value is stable :)
<alcor> Well, yes, that's what I usually do now.
<alcor> Either that, or I elect to put the constant in a separate file.
<|3b|> also, in cases where you didn't actually intend to change the value, but the value is one that isn't EQL on reloads, consider alexandria:define-constant or similar
<|3b|> defconstant doesn't complain if the value didn't change
<alcor> Yes, for simple constants everything is fine. It's only annoying if the value is a class instance.
yitzi has joined #commonlisp
<|3b|> right, use alexandria:define-constant or similar for that
<alcor> I see. alexandria:define-constant allows one to specify the equality predicate. That is indeed a more elegant solution, thanks |3b|.
<alcor> Regarding special variables: It's hard to find resources related to the performance implications of using them. My mental model the abstraction const is that they are equivalent to a thread-local variable, but I'm not entirely sure.
<|3b|> they pretty much are thread-local variables if threads are available on all the CL i'm aware of
<|3b|> they have an extra indirection compared to lexical variables, since they usually have to actually exist, and they also usually need extra work to remove the binding, which might prevent tail-call elimination
eddof13 has joined #commonlisp
<|3b|> theoretically a compiler could figure out that a particular binding can never be accessed non-locally and make it as fast as a lexical, but i don't know if anyone actually tries to do so
<alcor> It's been a while since I used thread-local storage in C & C++, but I remember there was a subtle footgun with threadlocals in the sense that they
<|3b|> particularly since anything that errors could allow a handler to try to access it
<alcor> … are lazily initialized, and the initialization is protected with a mutex.
<|3b|> (and that is before considering things like interactive debugging)
<bike> specials won't have that, since if they have global bindings that's not initialized per thread or whatever, they're actually global
<bike> of course there's the other footgun in that accessing them concurrently could be a race, but at least it won't be a slow one!
<|3b|> yeah, i wouldn't expect them to match any particular implementation of thread-local variables in other languages/runtimes
* alcor tries to dig into SBCL's internals
JuanDaugherty has joined #commonlisp
eddof13 has quit [Quit: eddof13]
<alcor> https://github.com/sbcl/sbcl/blob/master/doc/internals/specials.texinfo – "With multithreading it's slightly more complicated. The symbol's value slot contains the global value and each symbol has a TLS-INDEX slot that - when it's first bound - is set to a unique index of the thread local area reserved for this purpose."
<ixelp> sbcl/doc/internals/specials.texinfo at master · sbcl/sbcl · GitHub
shawnw has joined #commonlisp
<alcor> So yes, it does use TLS, but no mutexes are involved fortunately.
<bike> cos there's no way to specify a thread local initializer
<bike> well
<bike> i guess that's what that default thing is for actually, but those are run when the thread starts
<bike> probably since they're specified per-thread, unlike thread-locals in C and C++.
triffid has quit [Remote host closed the connection]
triffid has joined #commonlisp
waleee has joined #commonlisp
char has joined #commonlisp
xlymian has joined #commonlisp
randm has quit [Remote host closed the connection]
zxcvz has joined #commonlisp
randm has joined #commonlisp
zxcvz has quit [Client Quit]
JuanDaugherty has quit [Quit: JuanDaugherty]
thuna` has quit [Ping timeout: 252 seconds]
mgl has quit [Ping timeout: 272 seconds]
jrx has joined #commonlisp
rainthree has quit [Quit: Leaving]
zxcvz has joined #commonlisp
mgl has joined #commonlisp
lonjil has quit [Quit: Quit.]
zxcvz has quit [Quit: zxcvz]
<lagash> I finally got my hands on Common Lisp Recipes, and was not expecting so large of a book!
yitzi has quit [Remote host closed the connection]
McParen has joined #commonlisp
lagash has quit [Remote host closed the connection]
lagash has joined #commonlisp
yitzi has joined #commonlisp
mgl has quit [Ping timeout: 265 seconds]
cage has quit [Quit: rcirc on GNU Emacs 29.4]
amb007 has quit [Read error: Connection reset by peer]
mgl has joined #commonlisp
amb007 has joined #commonlisp
eddof13 has joined #commonlisp
younder has quit [Ping timeout: 248 seconds]
jrx has quit [Quit: ERC 5.5.0.29.1 (IRC client for GNU Emacs 29.4)]
<bjorkintosh> lagash: how disappointed would you be if it were a mere 40 pages long?
eddof13 has quit [Ping timeout: 272 seconds]
mgl has quit [Ping timeout: 252 seconds]
thuna`` has joined #commonlisp
mgl has joined #commonlisp
JuanDaugherty has joined #commonlisp
pve has quit [Quit: leaving]
lucasta has quit [Quit: Leaving]
yitzi has quit [Remote host closed the connection]
McParen has left #commonlisp [#commonlisp]
mgl has quit [Ping timeout: 265 seconds]
mwnaylor has joined #commonlisp
varjag has joined #commonlisp
JuanDaugherty has quit [Quit: JuanDaugherty]
zxcvz has joined #commonlisp
zxcvz has quit [Client Quit]
attila_lendvai has quit [Ping timeout: 244 seconds]
troojg has joined #commonlisp
istewart has joined #commonlisp
mala has quit [Quit: ZNC 1.6.1 - http://znc.in]
<Alfr> bjorkintosh, if it's 40 pages of macros, that might be rather frightening.
robin has joined #commonlisp
gorignak has quit [Quit: quit]
mala has joined #commonlisp
troojg has quit [Ping timeout: 276 seconds]
xlymian has quit [Ping timeout: 276 seconds]
King_julian has joined #commonlisp
troojg has joined #commonlisp
shka has quit [Ping timeout: 248 seconds]
<bjorkintosh> or. the necessary spell to awaken cthulu
King_julian has quit [Ping timeout: 260 seconds]
amb007 has quit [Ping timeout: 272 seconds]
istewart has quit [Quit: Konversation terminated!]
wacki has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
alcor has quit [Ping timeout: 258 seconds]
varjag has quit [Ping timeout: 248 seconds]
xlymian` has joined #commonlisp
donleo has joined #commonlisp
xlymian` has quit [Client Quit]
bilegeek has joined #commonlisp
King_julian has joined #commonlisp
X-Scale has joined #commonlisp
King_julian has quit [Ping timeout: 258 seconds]
X-Scale has quit [Ping timeout: 256 seconds]
donleo has quit [Ping timeout: 258 seconds]
troojg has quit [Remote host closed the connection]
amb007 has joined #commonlisp
wobbol has joined #commonlisp
amb007 has quit [Ping timeout: 252 seconds]