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/>
Lord_of_Life has quit [Ping timeout: 258 seconds]
Lord_of_Life has joined #commonlisp
waleee has quit [Ping timeout: 264 seconds]
deriamis has quit [Quit: ZNC - https://znc.in]
deriamis has joined #commonlisp
gilberth has joined #commonlisp
pfdietz has quit [Quit: Client closed]
yosef` has joined #commonlisp
igemnace has joined #commonlisp
pfdietz has joined #commonlisp
rtypo has quit [Ping timeout: 248 seconds]
b00p has joined #commonlisp
jonatack has quit [Ping timeout: 244 seconds]
pfdietz has quit [Ping timeout: 245 seconds]
jonatack has joined #commonlisp
dcb has quit [Quit: MSN Messenger 4.0.4]
bilegeek has joined #commonlisp
tboros has joined #commonlisp
Brucio-61 has quit [Ping timeout: 244 seconds]
Brucio-61 has joined #commonlisp
tboros has quit [Ping timeout: 245 seconds]
pfdietz has joined #commonlisp
yosef` has quit [Ping timeout: 245 seconds]
tyson2 has joined #commonlisp
igemnace has quit [Remote host closed the connection]
tboros has joined #commonlisp
jcowan has quit []
jcowan has joined #commonlisp
b00p has quit [Quit: Leaving.]
b00p has joined #commonlisp
tyson2 has quit [Remote host closed the connection]
igemnace has joined #commonlisp
NotThatRPG has joined #commonlisp
gxt has quit [Remote host closed the connection]
gxt has joined #commonlisp
tboros has quit [Ping timeout: 245 seconds]
NotThatRPG has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
NotThatRPG has joined #commonlisp
NotThatRPG has quit [Client Quit]
azimut has quit [Ping timeout: 252 seconds]
igemnace has quit [Remote host closed the connection]
b00p has quit [Quit: Leaving.]
greaser|q has quit [Changing host]
greaser|q has joined #commonlisp
greaser|q is now known as GreaseMonkey
anticomputer has quit [Remote host closed the connection]
anticomputer has joined #commonlisp
bjorkint0sh has quit [Remote host closed the connection]
bjorkint0sh has joined #commonlisp
rgherdt has joined #commonlisp
tboros has joined #commonlisp
mmk2410 has quit [Quit: ZNC - https://znc.in]
mmk2410 has joined #commonlisp
habamax has joined #commonlisp
rgherdt_ has joined #commonlisp
rgherdt has quit [Read error: Connection reset by peer]
rgherdt has joined #commonlisp
rgherdt_ has quit [Ping timeout: 245 seconds]
thuna` has quit [Remote host closed the connection]
rgherdt_ has joined #commonlisp
rgherdt has quit [Ping timeout: 245 seconds]
pve has joined #commonlisp
rgherdt__ has joined #commonlisp
jonatack has quit [Ping timeout: 258 seconds]
rgherdt_ has quit [Ping timeout: 246 seconds]
igemnace has joined #commonlisp
shka has joined #commonlisp
jonatack has joined #commonlisp
habamax has quit [Quit: ERC 5.5.0.29.1 (IRC client for GNU Emacs 29.1.50)]
notzmv has quit [Ping timeout: 264 seconds]
tboros has quit [Quit: Client closed]
tboros has joined #commonlisp
yosef` has joined #commonlisp
jonatack has quit [Ping timeout: 245 seconds]
thuna` has joined #commonlisp
jonatack has joined #commonlisp
rgherdt__ is now known as rgherdt
notzmv has joined #commonlisp
tboros has quit [Ping timeout: 245 seconds]
tboros has joined #commonlisp
pranavats has quit [Ping timeout: 255 seconds]
contrapunctus has quit [Ping timeout: 264 seconds]
contrapunctus has joined #commonlisp
rgherdt has quit [Ping timeout: 240 seconds]
rgherdt has joined #commonlisp
bendersteed has joined #commonlisp
LW has joined #commonlisp
LW has quit [Client Quit]
jonatack has quit [Ping timeout: 244 seconds]
random-jellyfish has joined #commonlisp
varjag has joined #commonlisp
igemnace has quit [Read error: Connection reset by peer]
<random-jellyfish> I want to implement a custom debugger for cl-generators, because if I try to (step (funcall (inter-next my-generator-object))) the debugger won't step over each line in the generator body but it will walk me through this incomprehensible web of lambdas that was generated behind the scenes
<random-jellyfish> I was thinking to put a (restart-case ...) before each form that is about to be evaluated(I know, I have to decide somehow what granularity to use), and list some restarts to step over, step into, step out, continue, etc.
<random-jellyfish> how do I implement these restarts?
<random-jellyfish> is there some api that allows me to step next, step into, step out, continue, etc.?
Cymew has joined #commonlisp
igemnace has joined #commonlisp
jonatack has joined #commonlisp
rgherdt_ has joined #commonlisp
bendersteed has quit [Quit: bendersteed]
rgherdt has quit [Ping timeout: 258 seconds]
thuna` has quit [Remote host closed the connection]
<beach> For starters, you probably want RESTART-BIND rather than RESTART-CASE.
bendersteed has joined #commonlisp
<random-jellyfish> when you call (step ...) and you end up in the debugger, where do those step next, step into, etc. restart come from?
<random-jellyfish> is there an api behind the scenes that I can access?
tboros has quit [Ping timeout: 245 seconds]
bilegeek has quit [Quit: Leaving]
* beach doesn't know.
msavoritias has joined #commonlisp
<cpli> for cl-async, how do i register my own events?
<ixelp> Event callbacks and error handling | Documentation | cl-async (Asynchronous operations for Common Lisp)
<cpli> (MAKE-EVENT CALLBACK &KEY EVENT-CB) exists
<cpli> and i assume i can trigger a callback registered that way using ADD-EVENT
<cpli> but is there an example of that?
v88m has quit [Ping timeout: 264 seconds]
v88m has joined #commonlisp
dino_tutter has joined #commonlisp
pfdietz has quit [Quit: Client closed]
jon_atack has joined #commonlisp
jonatack has quit [Read error: Connection reset by peer]
<Shinmera> random-jellyfish: from the implementation. it's completely up to the impl what STEP does and how useful it's going to be.
<Shinmera> and in many cases it's going to be very unuseful, as you've found
<Shinmera> There's little you can do aside from direct, and quite advanced, implementation hacking to improve the situation.
<Shinmera> note that STEP doesn't even have to use the debugger or restarts or anything.
<Shinmera> There's a bit of a snake's tail situation going on too. Many people never use STEP because it's usually so useless, so nobody cares about improving it.
<random-jellyfish> yeah, that sucks
v88m has quit [Ping timeout: 245 seconds]
<random-jellyfish> I think I'll end up rolling out my own generator implementation that uses tagbody, it's more limited but at least I can step into it
rtypo has joined #commonlisp
<beach> random-jellyfish: I recommend sections 1 and 2 of this paper: http://metamodular.com/SICL/sicl-debugging.pdf
<beach> It won't help you, but it will confirm what Shinmera is saying, that the situation is not great in our FLOSS Common Lisp implementations.
<Shinmera> Also to be fair, the problem *is* not an easy one to solve, and in some senses it's impossible for the implementation to give a good stepper without somehow knowing what level of granularity you care about at any particular point, and also without being able to recompile functions on the go to inject necessary stepping points and other metadaa
<beach> Well, as the paper points out, it should be possible to set a breakpoint in the code, and then decide where to step from there, or where to set the next breakpoint. But no FLOSS implementation is able to set a simple breakpoint it seems.
<Shinmera> right
<Shinmera> I'm more talking about the issue of macros. Sometimes you *do* want to step inside of what the machinery of a macro spit out, other times you don't
<Shinmera> and navigating that can be hard
<beach> But people seem content with the current situation, and I think that's the main issue why things aren't better than they are.
<Shinmera> I don't think that's fair.
<Shinmera> I haven't seen anyone that's content. People just have other things to do, too.
<random-jellyfish> if all you want to do is get it to work you'll find a way with or without a debugger
<beach> No, I mean, users don't demand anything better, because they think things are great.
bendersteed has quit [Quit: bendersteed]
rgherdt__ has joined #commonlisp
<beach> So obviously, maintainers don't see the need for anything better, and they concentrate on other things. Like performance.
karlosz has joined #commonlisp
<random-jellyfish> it's a problem when you want to create a tool on top of common lisp that should also offer good debugging features
<beach> random-jellyfish: Hmm. I agree with Shinmera, that it takes hacking the implementation to do something acceptable.
rgherdt_ has quit [Ping timeout: 240 seconds]
tibfulv has quit [Remote host closed the connection]
habamax has joined #commonlisp
tibfulv has joined #commonlisp
random-jellyfish has quit [Quit: Client closed]
yosef` has quit [Ping timeout: 245 seconds]
xmachina has quit [Ping timeout: 260 seconds]
blop_ has quit [Ping timeout: 252 seconds]
bendersteed has joined #commonlisp
rainthree has joined #commonlisp
karlosz has quit [Quit: karlosz]
xmachina has joined #commonlisp
notzmv has quit [Ping timeout: 264 seconds]
yitzi has joined #commonlisp
rainthree3 has joined #commonlisp
rainthree has quit [Quit: Leaving]
rainthree3 is now known as rainthree
tboros has joined #commonlisp
random-nick has joined #commonlisp
anticomputer has quit [Ping timeout: 252 seconds]
anticomputer has joined #commonlisp
gxt has quit [Ping timeout: 252 seconds]
wonko-the-sane has quit [Ping timeout: 252 seconds]
triffid has quit [Ping timeout: 252 seconds]
gxt has joined #commonlisp
wonko-the-sane has joined #commonlisp
tboros has quit [Ping timeout: 245 seconds]
triffid has joined #commonlisp
yitzi has quit [Remote host closed the connection]
pyooque has joined #commonlisp
puke is now known as Guest7199
Guest7199 has quit [Killed (lead.libera.chat (Nickname regained by services))]
pyooque is now known as puke
agm has joined #commonlisp
tboros has joined #commonlisp
xmachina has quit [Ping timeout: 255 seconds]
<agm> hello! today i'm puzzled by yet another behavior: if I run (defparameter foo 0) and then (let ((foo 1)) (makunbound 'foo) foo), I unsurprisingly get an unbound variable error. but evaluating foo afterwards produces 0! why?
cstub has joined #commonlisp
agm has quit [Ping timeout: 264 seconds]
xmachina has joined #commonlisp
<pl> agm: the lexical binding is established at compilation time and no longer involves a symbol at runtime - and makunbound executes at runtime
<pl> Also, on recompilation, LET will create a temporary lexical binding that again won't care about makunbound
dino_tutter has quit [Ping timeout: 260 seconds]
anticrisis has quit [Read error: Connection reset by peer]
<beach> This is not a lexical binding though.
jjnkn has joined #commonlisp
yitzi has joined #commonlisp
vjalmr has joined #commonlisp
puke has quit [Ping timeout: 264 seconds]
agm has joined #commonlisp
bendersteed has quit [Quit: bendersteed]
azimut has joined #commonlisp
thollief has joined #commonlisp
jmdaemon has quit [Ping timeout: 260 seconds]
slyrus has quit [Ping timeout: 246 seconds]
<Shinmera> phoe: so how about them patches? :)
bendersteed has joined #commonlisp
tyson2 has joined #commonlisp
random-jellyfish has joined #commonlisp
notzmv has joined #commonlisp
karlosz has joined #commonlisp
b00p has joined #commonlisp
dino_tutter has joined #commonlisp
iska has joined #commonlisp
random-jellyfish has quit [Quit: Client closed]
jjnkn has quit [Ping timeout: 240 seconds]
tboros has quit [Quit: Client closed]
tboros has joined #commonlisp
waleee has joined #commonlisp
xmachina1 has joined #commonlisp
tboros has quit [Quit: Client closed]
xmachina has quit [Ping timeout: 244 seconds]
rgherdt__ is now known as rgherdt
xmachina1 is now known as Co2
Co2 has quit [Quit: WeeChat 4.0.4]
waleee has quit [Ping timeout: 245 seconds]
dino_tutter has quit [Ping timeout: 244 seconds]
b00p has quit [Quit: Leaving.]
b00p has joined #commonlisp
dlowe has quit [Remote host closed the connection]
dlowe has joined #commonlisp
pfdietz has joined #commonlisp
varjag has quit [Quit: ERC (IRC client for Emacs 27.1)]
xmachina has joined #commonlisp
xmachina has quit [Client Quit]
NotThatRPG has joined #commonlisp
Co2 has joined #commonlisp
dcb has joined #commonlisp
Co2 is now known as xmachina
kevingal has joined #commonlisp
habamax has quit [Quit: ERC 5.5.0.29.1 (IRC client for GNU Emacs 29.1.50)]
tyson2 has quit [Remote host closed the connection]
Cymew has quit [Ping timeout: 252 seconds]
blop_ has joined #commonlisp
bendersteed has quit [Quit: bendersteed]
notzmv has quit [Ping timeout: 240 seconds]
blop_ has quit [Ping timeout: 252 seconds]
pfdietz has quit [Quit: Client closed]
<phoe> Shinmera: I remember about themmmmmm
cstub has quit [Quit: Leaving]
<beach> agm: Did you figure out the reason for the behavior?
<Shinmera> pl: makunbound won't remove the special declaration, I'm pretty sure.
<beach> agm: FOO is a special variable, so the LET binding is not lexical but dynamic. So the LET introduces a new binding for FOO, and initializes it to 1. Then when you do the makunbound, it makes that new binding no longer have any value, so you get the error. But when you leave the LET scope, the old binding of FOO is restored.
<pl> I got rusty. Fortunately no crabs
<Shinmera> :)
<pl> Recently got back into programming in a proper language
agm has quit [Ping timeout: 248 seconds]
tyson2 has joined #commonlisp
cage has joined #commonlisp
msavoritias has quit [Remote host closed the connection]
yitzi has quit [Remote host closed the connection]
NotThatRPG has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
pfdietz has joined #commonlisp
b00p has quit [Quit: Leaving.]
igemnace has quit [Read error: Connection reset by peer]
b00p has joined #commonlisp
kevingal has quit [Read error: Connection reset by peer]
igemnace has joined #commonlisp
rainthree has quit [Remote host closed the connection]
rainthree has joined #commonlisp
xmachina has quit [Ping timeout: 258 seconds]
igemnace has quit [Remote host closed the connection]
blop_ has joined #commonlisp
NotThatRPG has joined #commonlisp
dino_tutter has joined #commonlisp
xmachina has joined #commonlisp
edr has joined #commonlisp
azimut_ has joined #commonlisp
NicknameJohn has joined #commonlisp
azimut has quit [Ping timeout: 252 seconds]
b00p has quit [Ping timeout: 240 seconds]
tyson2 has quit [Remote host closed the connection]
Alfr has quit [Remote host closed the connection]
dinomug has joined #commonlisp
NotThatRPG has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
notzmv has joined #commonlisp
pfdietz has quit [Quit: Client closed]
b00p has joined #commonlisp
Alfr has joined #commonlisp
yitzi has joined #commonlisp
NotThatRPG has joined #commonlisp
jon_atack has quit [Ping timeout: 246 seconds]
blop_ has quit [Ping timeout: 252 seconds]
blop_ has joined #commonlisp
zxcvz has joined #commonlisp
zxcvz has quit [Client Quit]
NicknameJohn has quit [Ping timeout: 240 seconds]
NotThatRPG has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
pve has quit [Remote host closed the connection]
b00p has quit [Quit: Leaving.]
tyson2 has joined #commonlisp
olnw has joined #commonlisp
NotThatRPG has joined #commonlisp
azimut_ has quit [Ping timeout: 252 seconds]
b00p has joined #commonlisp
flip214 has quit [Ping timeout: 260 seconds]
amb007 has quit [Ping timeout: 240 seconds]
olnw has quit [Remote host closed the connection]
amb007 has joined #commonlisp
flip214 has joined #commonlisp
NicknameJohn has joined #commonlisp
azimut has joined #commonlisp
azimut has quit [Ping timeout: 252 seconds]
azimut has joined #commonlisp
b00p has quit [Quit: Leaving.]
b00p has joined #commonlisp
b00p has quit [Client Quit]
b00p has joined #commonlisp
tyson2 has quit [Remote host closed the connection]
jjnkn has joined #commonlisp
jeosol has joined #commonlisp
dinomug has quit [Ping timeout: 245 seconds]
tyson2 has joined #commonlisp
rainthree has quit [Ping timeout: 264 seconds]
phadthai has joined #commonlisp
<jmercouris> when I do "read-line" what is the delimiter?
<jmercouris> what is considered a "line"?
<jmercouris> I read the CLHS already
<jmercouris> "Reads from input-stream a line of text that is terminated by a newline or end of file. "
<jmercouris> and it seems I can set the EOF... but I just don't get it
<dlowe> click on "newline"
<jmercouris> Aha
<jmercouris> dlowe: how would I encode "newline" in another language though?
<jmercouris> like JavaScript specifically
<jmercouris> where strings can't really have ^M in them
<dlowe> It's almost certainly "\n"
<jmercouris> Hm
<jmercouris> Yes
<dlowe> CL keeps it ambiguous because different encodings were more common
<jmercouris> Let me play with it and see if I can come up with some better ideas, I feel I am doing X Y problem here
<dlowe> ^M is "\r" in C-like escape strings
dinomug has joined #commonlisp
<dlowe> honestly it's a real shame you can't specify the delimiter because read-until-something would be really useful sometimes
<jmercouris> here is my problem: http://dpaste.com/93TPC8DUS
<ixelp> dpaste: 93TPC8DUS
<jmercouris> so I get Mr Lisp starting up a server
<jmercouris> I then connect to it with Mr JavaScript
<jmercouris> I send a whole bunch of strings, but ONLY when I kill the Lisp server, do the messages all come pouring in, seems not to be able to get past the read-line
<jmercouris> maybe I need to send \r\n or something
<dlowe> so a) read-line signals a condition on eof by default
<dlowe> pass NIL as the second argument
agm has joined #commonlisp
<jmercouris> OK
dinomug has quit [Remote host closed the connection]
<jmercouris> I tried that, same thing
<jmercouris> I just don't get why the server has to be killed to flush the messages through read-line
<dlowe> yeah, it doesn't fix your current problem just the next problem
<jmercouris> WHAT MUST I SEND FOR IT TO BE CONSIDERED A LINE
<dlowe> can you read bytes?
<jmercouris> I guess I could
<dlowe> just read-char instead of read-line and see what happens
<jmercouris> well I anticipate it'll lose its mind
<agm> beach: i would call it a genuine bug, but gcl and clisp do the same thing
<dlowe> that's fine, you're jst checking for communication
<jmercouris> dlowe: aha, OK
<jmercouris> then I shall one sec
<jmercouris> dlowe: it instantly printed everything
<jmercouris> as expected
<jmercouris> this is what I did http://dpaste.com/7S3B5ESGY
<ixelp> dpaste: 7S3B5ESGY
<jmercouris> I just dont understand what I must send for it to consider a line from the world of JavaScript
<jmercouris> it is a most foolish function this one
<dlowe> try \r\n from javascript
<jmercouris> or perhaps I am the fool
<jmercouris> I will try that
<dlowe> also you can inspect what char codes your read-char test was getting
<dlowe> see if 0x0a is represented
<jmercouris> dlowe: this is what I got back from my test
<ixelp> dpaste: 8CGWYJGAD
<jmercouris> from the read-char version
<dlowe> well, there's definitely a \n going there
<gilberth> Is that really what you got back? #\\ #\n instead of #\newline? I mean two characters '\' and 'n'?
<dlowe> yeah, you're getting a \ and an n
<jmercouris> yes, because I sent actually "\\n"
<jmercouris> or I think even "\\\n"
<gilberth> See.
<dlowe> I caught that on a second take but gilberth spotted it immediately
<jmercouris> I was trying different amounts
<jmercouris> just in case
<jmercouris> so I sent "\r\n" for example
<jmercouris> and what it sent me back was
<jmercouris> "{\"callback\":1852,\"value\":\"hello world\"} rn"
<dlowe> that's a shameful way to try and fix the problem
<jmercouris> perhaps :-D
<jmercouris> but this is a complicated problem and I want to verifiy some assumptions first
shka has quit [Quit: Konversation terminated!]
<jmercouris> so I have to send double slashes at a minimum
<dlowe> okay, if you put "\r\n" in lisp code, you will get "rn" but in javascript you will get CRLF
<jmercouris> yes, I am talking about in Lisp code
<jmercouris> I'm sorry, this is convoluted
<jmercouris> let me explain
<jmercouris> I send a string from Lisp to JavaScript to execute
<jmercouris> then JavaScript executes that string
<jmercouris> so in order to get the string I want I have to double up the backslashes in the Lisp world
<dlowe> that could have been specified at the beginning :p
<jmercouris> so here is what I am sending to javascript
<ixelp> dpaste: B8GN7Y6SS
<jmercouris> so it seems that \r was in fact converted to ^M
<jmercouris> but that was not yet enough to appease the gods of read-line
<jmercouris> this is what I've put for the create-server function in Lisp: http://dpaste.com/BYGA5U29P
<ixelp> dpaste: BYGA5U29P
<dlowe> You're using `` raw string syntax which doesn't interpret \r\n codes
<dlowe> in the javascript
<jmercouris> hm
<jmercouris> are you sure?
<jmercouris> OK I guess I will try creating the string another way
<dlowe> just use ""
<jmercouris> i'll try just setting it to "I AM FISH \\n"
<jmercouris> and see if it will send that immediately
<dlowe> or you could do `foo` + "\n"
<dlowe> You shouldn't need "\r\n" on this
<jmercouris> yes, but I *should* need "\\n"
<jmercouris> I think
<dlowe> yes
<jmercouris> give me a moment, I will report back
<jmercouris> still no luck
<jmercouris> had to kill the socket
<jmercouris> and then it printed "I AM A FISH \\n"
cstub has joined #commonlisp
<jmercouris> I also tried "\\\" and it still printed "\\"
<jmercouris> which is a mystery to me
<jmercouris> OH MY GOD I GOT IT TO WORK
<jmercouris> client.write(\"I AM A FISH \\\\n\"); from Lisp
<jmercouris> but then it printed
<jmercouris> "I AM A FISH \\"
<jmercouris> which doesn't make sense...
<jmercouris> because if I remove two slashes, then it won't work
<jmercouris> I don't know what to make of this
<ixelp> dpaste: EA57VWPGL
<jmercouris> Look, this obviously makes you think, let's remove two slashes from "I AM A FISH \\\\n"
<jmercouris> but when I do that, it doesn't work anymore, I am beyond perplexed
<jmercouris> even removing one slash doesn't work
<jjnkn> did your lisp server print "I AM A FISH \\" ?
<jmercouris> jjnkn: ye
<jmercouris> s/ye/yes
<jjnkn> you sent "I AM A FISH \\n" from lisp, i removed escaping backslashes
<jjnkn> so if JS read \n as newline character, then 1 backslash remains
<jjnkn> when lisp prints it, it escapes it additionally
<jjnkn> so in the end you get 2
<jmercouris> hm
<jjnkn> i'm not sure though
<jmercouris> so what if I sent "I AM A FISH \\\n" instead?
<jmercouris> I mean, it doesn't make sense to me
<jmercouris> like I understand the words you are saying, but what I am observing doesn't appear to follow those rules
<jmercouris> dlowe: by the way `string` can still enocde \n in JavaScript I think
<jmercouris> I reran the test like this: client.write(`${jsonString} \\\\n`);}) and it worked
<jjnkn> your lisp server prints like ~s format specifier would?
<jmercouris> jjnkn: it is literally just (print xyz)
<jmercouris> you can see it in the paste above
<jmercouris> on line 18
<jjnkn> well, then "I AM A FISH \\" is a printed representation of "I AM A FISH \"
<jmercouris> OK
<jmercouris> the how do we get rid of the single backslash then?
<jmercouris> s/the/then
<jmercouris> OH MY GOD I SEE THE PROBLEM
<jmercouris> it is with send-message manipulating strings
<jmercouris> it's because we are replacing \\n with \\\\n to solve another problem with the lisp reader
b00p has quit [Quit: Leaving.]
tyson2 has quit [Remote host closed the connection]
dinomug has joined #commonlisp
<jjnkn> also, you could use ~s instead of \"~a\" in the format string to make it more readable
<jjnkn> that is, if the argument to this format specifier is a string
<jmercouris> I see, thank you
<jmercouris> I have finally figured out this stupid shit
<jmercouris> well not stupid, but also stupid :-(
<jjnkn> mind sharing the working version of the code?
<jmercouris> jjnkn: yes, sure
<jmercouris> jjnkn: http://dpaste.com/GKJ3SGF2P
<ixelp> dpaste: GKJ3SGF2P
<jmercouris> that is what we needed to do
<jmercouris> basically not do this stupid string replacement
<jmercouris> the problem is that we needed to send "\\n" but we could not do so, we could not do so
<jmercouris> now you might be wondering why this hack to swap "\\n" with "\\\\n" it has to do with multiline strings in javascript
<jmercouris> that is when you are using "quotes", if you are using backticks, you can create multiline strings no problem
<jmercouris> HOWEVER, parenscript will *NOT* do this
<jmercouris> and so you are left with "\\n" in your javascript strings created by parenscript which are swallowed by the reader, hence this hack
<jmercouris> thank you dloweand jjnkn
<jjnkn> so "\\\\n" (2 backslashes + n) are necessary because parenscript will gobble one of them?
<jmercouris> jjnkn: almost, I'll show you a snippet
<gilberth> Where does the reader come into play? Are you refering to the Lisp reader? And do you try to read Javascript with it?
<jmercouris> I am referring to the Lisp reader, yes
<jmercouris> (ps:ps "hello^Mworld") --> "'hello\\nworld';"
<gilberth> And why do you apply it to something escaped in the JSish way? At least this is what I got is what you do.
<jmercouris> and of course "'hello\\nworld';" will FAIL because it will just be "hello^Mworld" which Javascript does not like!
<jmercouris> You must do "hello\^Mworld" for JavaScript
<gilberth> That's not a ^M. I get "'hello\\rworld';"
<jmercouris> gilberth: what do you mean?
<gilberth> ^M is carriage return and \r when escaped with JS.
<jmercouris> perhaps I mis spoke and didn't mean ^M literally
<jmercouris> what I am trying to say is that to represent a multiline javascript string you type backslash followed by RET
<jmercouris> so "something + backslash + RET + more"
<jmercouris> anyways, in order to get that backslash for the newline to work I must in Lisp land have "something\\\\nmore"
<jmercouris> I hope that makes sense
<gilberth> Perhaps. I may have borrowed that from C. But with C it's not part of the string syntax. It's handled earlier. But this doesn't matter.
<jmercouris> it makes sense to me at least
<gilberth> I don't get you. PS:PS already escapes strings just fine.
<jmercouris> but they are being reread in my case
<jmercouris> because I am doing an operation on them
<jmercouris> I am doing (write-line string-generated-by-ps)
<jmercouris> "reread" not literally, but yes
<gilberth> With what? With the Lisp reader? That's bound to fail. You need a routine that unescapes JS string literals.
<ixelp> dpaste: 5N4CJVPUS
<jmercouris> you see the problem?
<jmercouris> it is how I am writing to JavaScript, using write-line
<gilberth> I don't. This looks perfectly fine.
thollief has quit [Quit: Leaving]
<jmercouris> 'hello\nworld'; is an invalid javascript string!
<jmercouris> because it will be evaluated
<jmercouris> and it would have to look like this
<ixelp> dpaste: 4TAGEFVXX
jjnkn has quit [Ping timeout: 240 seconds]
<gilberth> Really?
<jmercouris> Yes, really
<jmercouris> I wish I was joking
<jmercouris> but I found this out a hard way
<gilberth> What are you trying to do? Generate JS that as a JS string literal includes more JS?
<jmercouris> THAT IS CORRECT
<jmercouris> sorry caps lock
<ixelp> JavaScript string with new line - but not using \n - Stack Overflow
pfdietz has joined #commonlisp
<jmercouris> I just realized I am writing almost a quine
<jmercouris> not even on purpose
<gilberth> Try (ps:ps* `(eval ,(ps:ps* #\newline)))
tyson2 has joined #commonlisp
<gilberth> I mean, you want to embed JS program text as a JS string literal in JS. Then say so.
<jmercouris> it is convoluted
<jmercouris> I need to focus, but can provide more background later
<jmercouris> thank you for your help
<jmercouris> you have deepend my understanding
<gilberth> You case is convoluted to begin with.
<gilberth> * your
<jmercouris> Yes, that is what I am saying
<jmercouris> it is very unfortunate
agm has quit [Ping timeout: 264 seconds]
<jmercouris> on a high level, I am using Lisp to call a JavaScript server to execute some code, that code returns a promise, which then calls Lisp code back with the value returned in that promise
<jmercouris> so I am making an asynchronous execution environment with closures across two languages
<jmercouris> it is however necessary for the port of Nyxt, to electron
<gilberth> Anyhow, the moment you type "(str:" you should feel physical pain.
<jmercouris> it hurts me, believe me
<jmercouris> I spent some time talking about it with bike and I will have to properly figure it out yes
<gilberth> Get a good picture of external versus internal representation. It's dangerous others. See SQL injection. See ebay thinking someone lives at "Bahnhofstra&amp;szlig;e"
<gilberth> * otherwise
<bike> it would be kind of cool to get a street named that (and then presumably get lynched by the postal service within the week)
<gilberth> Apply this to Chinese a street name. At least you can guess what "szlig" is. Do Chinese know the Unicode code points of their characters off the top of their head?
<gilberth> Wow! Is that UTF-8 rendered as ISO-8859-1?
<jmercouris> gilberth: http://dpaste.com/7LKPXXTVU
<ixelp> dpaste: 7LKPXXTVU
<bike> Something along those lines, yeah
<jmercouris> here I have tried my best to explain
cage has quit [Quit: rcirc on GNU Emacs 29.1]
<gilberth> PS is fine.
<jmercouris> OK, how would you suggest I take what PS suggests, and NOT mutate using STR
<jmercouris> and send it properly along?
<gilberth> I still don't know what exactly it is what you send.
<gilberth> Or want to send.
<jmercouris> because this is what PS produces
<ixelp> dpaste: FFNNT27BM
<jmercouris> and try doing write-line
<jmercouris> write-line will get us to "document.getElementsByTagName('html')[0].innerHTML = '<head>\n <meta charset=UTF-8>\n <style>body{\n background-color: #eeeeee;\n color: black;\n font-size: 12px;\n padding: 0;\n padding-left: 4px;\n margin: 0;\n}</style>\n</head>\n<body>fishes\n</body>';"
<jmercouris> sorry for the paste
<jmercouris> but you see now that we are missing a backslash, THUS MAKING THIS STRING INCORRECT
<jmercouris> it was correct, but write-line ruined everything that is sacred in this world
<gilberth> I don't see where a backslash is missing.
<jmercouris> literally everywhere in the string
<jmercouris> I am trying to tell you '<head>\n xyz' is not a valid string when expanded by in the JavaScript interpreter
<jmercouris> it has to be '<head>\\n xyz'
<jmercouris> this string will be evaluated!
<gilberth> Why would it be evaluated? '<head>\n' is a literal.
<ixelp> dpaste: 792XUDZYC
<gilberth> Or is what you send evaluated and would need to evaluate to another sting being JS program text?
<jmercouris> I am sending code to a javascript server to be evaluated
<jmercouris> that code that I am sending to the server is javascript being generated in the land of lisp
<jmercouris> javascript doesn't support multiline strings
<jmercouris> parenscript properly handles this by doing \\n which *would* be correct if it wasn't for pesky write-line
<jmercouris> if i could *LITERALLY* send the string without lisp doing mutations, it would be fine
<gilberth> write-line just writes a string as it is. It's the job or write-line.
<jmercouris> REALLY?
<jmercouris> then how come it mutates the value?
<gilberth> It doesn't.
<jmercouris> yes it does
<gilberth> No, it doesn't.
<jmercouris> yes it does
<jmercouris> it doesn't write what it says it will
<gilberth> Nope. It would be a bug.
<jmercouris> i'm telling you
<gilberth> It does write exactly what you say it should write.
<jmercouris> the return value is fine, what it writes is not fine
<gilberth> The return value is the very line that was send.
<jmercouris> gilberth: anywyas, I have to go for now
<gilberth> Trust me, WRITE-LINE is fine. And PS is fine as well.
<Alfr> jmercouris, how do you construct that \\n ?
b00p has joined #commonlisp
<bike> write-line definitely does not mutate a string.
<bike> you may be misinterpreting things because the reader and printer deal with escaping variously. but if you for example go through each character of a string with aref, you will see that write-line will write those characters in that order.
dlowe has quit [Ping timeout: 252 seconds]
<gilberth> Yep, as I pointed out: Confusion about internal and external representation.
<gilberth> However, I still don't get if the text of a JS string literal needs to be sent or the string itself.
<gilberth> Or nested, as I suspected at first.
Josh_2 has quit [Remote host closed the connection]
thuna` has joined #commonlisp
random-jellyfish has joined #commonlisp
son0p has joined #commonlisp
<jmercouris> probably it is a misunderstanding on my part
<jmercouris> i did log on the JS side what it receives though, and it had backslashes stripped
<gilberth> Really?
<gilberth> ,(length "\\")
<ixelp> (length "\\") => 1
<gilberth> "\\" is Lisp syntax for a string of exactly one character. That character is: ,(char "\\" 0) there is no second char: ,(char "\\" 1)
<ixelp> (char "\\" 0) => #\\, and then (char "\\" 1) ERROR: Array index 1 out of bounds for "\\" .
<gilberth> *scratcheshead* This channel has colour stripped?
<jmercouris> gilberth: explain to me what I am doing wrong here
b00p has quit [Quit: Leaving.]
<jmercouris> I am sending "\\n" to see "\n" which makes sense to me
<jmercouris> heres another example
<bike> you're sending one backslash and then one n, i believe
<ixelp> dpaste: 8V9PZY5YY
<bike> you're using PRINT to print the string. you can see it's escaping the double quotes in the string
<jmercouris> bike: yes, I am sending one backslash and then one n, this is correct for the first case
<bike> try using write-string to look at the contents without that
<jmercouris> now look at the second case
<jmercouris> I want to send two backslashes and then and n
<jmercouris> therefore I have to send "\\\\n" and parenscript only produces "\\n"
<gilberth> jmercouris: First of all get rid of that replace-newlines-p and the str:replace-all thing. It is wrong no matter what.
<jmercouris> gilberth: yes, sure
<gilberth> Second: Both WRITE-LINE and PS:PS do exactly what they should do.
<bike> if you want to send two backslashes you need to send two backslashes. four backslashes is how you tell the lisp reader to read two backslashes
<jmercouris> bike: how can I send two backslashes?
<jmercouris> let me post what I mean
<bike> you send a string with two backslashes, which may or may not have been CL:READ.
<ixelp> dpaste: B9SNA6T5F
<jmercouris> this is my problem
<jmercouris> the return value is fine, but what it writes is not fine
<jmercouris> I want it to LITERALLY SEND OVER THE SOCKET "\\n"
<bike> the return value is the second one?
<gilberth> jmercouris: Both are the very SAME.
<jmercouris> yes
<jmercouris> the return value is the second one
<bike> okay, well indeed, the return value is just what it writes but with escapes.
<jmercouris> then why does JavaScript not see that?
<bike> if you send this string over the socket, the other end will see one backslash and one n.
<bike> i don't know what javascript does with it from there.
<jmercouris> let me try once again
<gilberth> jmercouris: Because you are sending the characters of the string not the Lisp external representation of that string. The latter would be wrong anyway.
<ixelp> dpaste: DER8PMQRT
<jmercouris> so was parenscript not doing what it should have been doing?
<jmercouris> did I misunderstand?
<gilberth> jmercouris: A string is a sequence of characters. Not some program text. Neither JS nor Lisp. When in Lisp you write "a\\b" that is a sequence of 'a', '\', and 'b'. Three characters. Not four, not six.
<jmercouris> seems parenscript is not as intelligent as I thought then
<jmercouris> parenscript is absolutely *not* doing the correct thing
<bike> jmercouris: please please use write-string instead of print.
<gilberth> And write-line is writing those characters, not any external representation. Neither Lisp nor JS.
<jmercouris> bike: OK
<bike> jmercouris: you can see \\n in the PRINTed output there. that means that the actual string has \n. and it looks like that's what's in javascript.
<gilberth> jmercouris: ParenScript is doing exactly the right thing. Don't try to point to bugs that aren't there.
<jmercouris> bike: http://dpaste.com/56CNHWZFN
<ixelp> dpaste: 56CNHWZFN
<jmercouris> no, there most CERTAINLY Is a bu
<jmercouris> s/bu/bug
dino_tutter has quit [Ping timeout: 255 seconds]
<gilberth> There is not.
<jmercouris> gilberth: really, how is "document.getElementsByTagName('html')[0].innerHTML = '<head>\n <meta charset=UTF-8>\n <style>body{\n background-color: #eeeeee;\n color: black;\n font-size: 12px;\n padding: 0;\n padding-left: 4px;\n margin: 0;\n}</style>\n</head>\n<body>hello world\n</body>';" a valid string?
<bike> jmercouris: ...are you sure you're looking at the right output? write-string and print should be putting out different things.
<jmercouris> bike: I will double check
<bike> like try (write-line "foo\\n7") and (print "foo\\n7") in a repl. you'll see different things.
b00p has joined #commonlisp
<jmercouris> you're right, it was printing in multiple spots from debugging
<jmercouris> bike: now it matches
<jmercouris> what I am "write-string" ing is exactly what JavaScript is seeing
<jmercouris> Parenscript is just outputting invalid code then
<bike> great, sanity prevails.
<bike> i have no idea about parenscript.
<gilberth> Parenscript is fine.
<gilberth> I use it all the time and it has no issues with newlines.
<jmercouris> gilberth: yes... yes
<jmercouris> I just... let me see something
<jmercouris> eval("x = '<head>\n <meta charset=UTF-8>\n'")
<jmercouris> in JavaScript
<jmercouris> but if you do "x = '<head>\n <meta charset=UTF-8>\n' " directly in the repository
<jmercouris> s/repository/console, it will work
<jmercouris> I don't understand, I just don't get it
<gilberth> So you want to create that form eval(..) from PS?
<jmercouris> but THIS works: eval("x = '<head>\\n <meta charset=UTF-8>\\n'")
<jmercouris> gilberth: I want to create the part that will get eval'd from PS, yes
<gilberth> Sure. There is a string inside a string.
<jmercouris> I'm sorry if it was unclear
<jmercouris> all of the above is JavaScript
<jmercouris> I am putting that in the console
thuna` has quit [Ping timeout: 258 seconds]
<jmercouris> I just don't understand
<gilberth> Yes. And at a JS console you need to say the latter: eval("x = '<head>\\n <meta charset=UTF-8>\\n'")
<jmercouris> yes, that is true
<jmercouris> gilberth: so now that the problem is clear, how do we solve it?
<gilberth> Do you see why there is this double backslash?
<jmercouris> gilberth: I can't for the life of me imagine why
<jmercouris> is backslash an escape character in JS as well?
<gilberth> It is.
<jmercouris> then that is why
<gilberth> Yes, and unlike in CL \n in JS is the escape for a newline character.
<jmercouris> then explain this
<jmercouris> actually wait, nevermind
<jmercouris> I need to change how parenscript handles newlines in strings
<jmercouris> and I have no idea how the f I would do that
<gilberth> You don't.
<jmercouris> gilberth: how would I fix it otherwise then?
<jmercouris> I feel like there is something I am missing here
<gilberth> You want to create JS with a string literal that has JS program text. Then say so. I showed you: (ps:ps* `(eval ,(ps:ps (+ 1 2))))
<gilberth> I get the Lisp string "eval('1 + 2;');"
<jmercouris> I can't have the eval in there
<jmercouris> I just need the body of the eval
<jmercouris> but OK, I will think about it
<gilberth> You said "eval". I was supposing this would be something you need to generate.
cstub has quit [Quit: Leaving]
<jmercouris> gilberth: you see that on the JS said I already have the eval
<jmercouris> it just evals whatever is gven to it
jonatack has joined #commonlisp
<gilberth> Yes then give it what PS:PS is giving you and you'll be fine. Use WRITE-STRING to write it out. Without altering it. What PS:PS is giving you is perfectly valid JS program text. That's its purpose.
dinomug has quit [Remote host closed the connection]
rgherdt has quit [Quit: Leaving]
tboros has joined #commonlisp
<gilberth> Or put otherwise: When you say (write-line (ps:ps ...)) at the REPL and cut and paste the output (not the value printed back) into a JS console, that'll work as is.
<jmercouris> Yes
<jmercouris> the problem is that sometimes we eval and sometimes we don't depending on the renderer
<jmercouris> WebKitGTK+ does not require this... but cl-electron does
<jmercouris> so I have to figure out how to circumstantially do it that way
cstub has joined #commonlisp
waleee has joined #commonlisp
<tboros> According to ChatGPT, the following functions exist - "hunchentoot:write-multipart-mixed" and "hunchentoot:write-multipart-part". Additionally it also makes an instance of a 'response-mixin class. Have I somehow missed these from the documentations?
<tboros> More relevantly, any suggestions to how I may go about sending a multipart/mixed response containing a JSON and a CSV from a Hunchentoot server?
<tboros> The CSV is large so I would like to keep it in .csv format
terrorjack has quit [Quit: The Lounge - https://thelounge.chat]
terrorjack has joined #commonlisp
terrorjack has quit [Client Quit]
terrorjack has joined #commonlisp
random-nick has quit [Ping timeout: 240 seconds]
karlosz has quit [Quit: karlosz]
waleee has quit [Ping timeout: 255 seconds]
cstub has quit [Quit: Leaving]
b00p has quit [Quit: Leaving.]
<Shinmera> You'll have to do the multipart/mixed encoding manually, I'm afraid.
thuna` has joined #commonlisp
<tboros> I see, thanks
<tboros> I suppose I can just write the JSON part into the CSV and send as text/csv
jonatack has quit [Quit: WeeChat 4.0.4]