Xach 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>
dec0d3r has joined #commonlisp
dec0d3r has quit [Remote host closed the connection]
scymtym has quit [Ping timeout: 252 seconds]
scymtym has joined #commonlisp
taiju has quit [Ping timeout: 252 seconds]
Inline has joined #commonlisp
random-nick has quit [Ping timeout: 252 seconds]
abrantesasf has joined #commonlisp
jacek_ has quit [Remote host closed the connection]
pranavats has left #commonlisp [Error from remote client]
taiju has joined #commonlisp
taiju has quit [Ping timeout: 256 seconds]
abrantesasf has quit [Remote host closed the connection]
Guest74 has joined #commonlisp
Oladon has quit [Quit: Leaving.]
perrierjouet has quit [Quit: WeeChat 3.3]
abraham has left #commonlisp [The Lounge - https://thelounge.chat]
djuber has joined #commonlisp
s-liao has joined #commonlisp
dstein64- has joined #commonlisp
dstein64 has quit [Ping timeout: 260 seconds]
dstein64- is now known as dstein64
Oladon has joined #commonlisp
ldb has joined #commonlisp
jpl01 has quit [Remote host closed the connection]
s-liao has quit [Ping timeout: 256 seconds]
ldb has quit [Remote host closed the connection]
ldb has joined #commonlisp
perrierjouet has joined #commonlisp
ldb has quit [Ping timeout: 252 seconds]
ldb has joined #commonlisp
<beach> Good morning everyone!
<ldb> hi
<ldb> do you guys know any implementation of decimal floating point in lisp?
<phantomics> Morning beach
<ldb> I found on in GNU Emacs's calc package, but I cannot find the orgin of the algorithms been used.
lisp123 has joined #commonlisp
Inline has quit [Ping timeout: 268 seconds]
<loke[m]> There is a decimal package on QL. It represents decimal numbers as the fraction of a power of 10
<loke[m]> So the numbers are also real CL numbers
pranavats has joined #commonlisp
ldb has quit [Ping timeout: 252 seconds]
ldb has joined #commonlisp
ldb has quit [Ping timeout: 256 seconds]
lisp123 has quit [Remote host closed the connection]
taiju has joined #commonlisp
semz has quit [Ping timeout: 252 seconds]
ldb has joined #commonlisp
Lycurgus has joined #commonlisp
<ldb> loke: yes, that's called we-decimal. the homepage and github repo has been removed, fortunately there's a copy from quicklisp
<ldb> it does not have elementary function calculation that I'm looking for, but still provides some useful insights. thanks for the info.
lisp123 has joined #commonlisp
waleee has quit [Ping timeout: 252 seconds]
s-liao has joined #commonlisp
semz has joined #commonlisp
lisp123 has quit [Ping timeout: 252 seconds]
tyson2 has quit [Remote host closed the connection]
s-liao has quit [Quit: Client closed]
s-liao has joined #commonlisp
poselyqualityles has joined #commonlisp
peterhil has joined #commonlisp
taiju has quit [Ping timeout: 252 seconds]
makomo has joined #commonlisp
taiju has joined #commonlisp
lisp123win has left #commonlisp [ERC (IRC client for Emacs 26.3)]
lisp123 has joined #commonlisp
ldb has left #commonlisp [ERC (IRC client for Emacs 27.2)]
lisp123 has quit [Ping timeout: 252 seconds]
s-liao has quit [Quit: Ping timeout (120 seconds)]
s-liao has joined #commonlisp
dale has quit [Remote host closed the connection]
akoana has quit [Quit: leaving]
Lycurgus has quit [Quit: Exeunt]
gaqwas has joined #commonlisp
Algernon69 has joined #commonlisp
<Guest74> mfiano: So I 'added'(cause it was basically there) loading from vectors to pngload and not sure about the naming and where to put it. right now I named it load-vector and placed it by itself in octet-vector.lisp, but maybe it should be in png.lisp?
Algernon69 has quit [Ping timeout: 252 seconds]
makomo has quit [Ping timeout: 252 seconds]
mrcom_ has joined #commonlisp
mrcom has quit [Ping timeout: 268 seconds]
Guest74 has quit [Ping timeout: 256 seconds]
Algernon69 has joined #commonlisp
Algernon91 has joined #commonlisp
<susam> Good morning, beach! Good morning, everyone!
Algernon69 has quit [Ping timeout: 240 seconds]
<beach> Hello susam.
treflip has joined #commonlisp
dale has joined #commonlisp
dale has quit [Remote host closed the connection]
dale has joined #commonlisp
s-liao has quit [Quit: Client closed]
s-liao has joined #commonlisp
poselyqualityles has quit [Ping timeout: 252 seconds]
lisp123 has joined #commonlisp
<dre> Good morning everybody.
<dre> it's 7pm on a sunday and I finally get to catch up on 2 days of AoC
lisp123 has quit [Ping timeout: 256 seconds]
aartaka has joined #commonlisp
MichaelRaskin has joined #commonlisp
<dre> if I have a list like '(1 2 3 4 5) and I want to change the 4 into a 't' - do i just use setf for that?
<dre> answer is yes, pls excuse me
<dre> still new to the complete repl experience
Qwnavery has joined #commonlisp
<jackdaniel> (setf (nth 3 my-list) t)
<jackdaniel> that said, you should not modify a quoted list
<beach> dre: You need to be careful how you phrase your questions. Do you really mean that you have a list (quote (1 2 3 4 5)) or a list (1 2 3 4 5)?
<jackdaniel> it is a literal, so you charter the undefined behavior territory
<beach> dre: If you have a list (1 2 3 4 5), then what jackdaniel said.
<dre> yeah I'm still bad at the quote and list thing
<jackdaniel> dre: note in http://www.lispworks.com/documentation/HyperSpec/Body/s_quote.htm " The consequences are undefined if literal objects (including quoted objects) are destructively modified. "
<dre> (let ((x (list 1 2 3 4))) (setf (car x) t) (princ x))
<phadthai> agreed with the other replies, then also see rplaca/rplad
robin has quit [Ping timeout: 252 seconds]
<dre> "not evaluated" I'm still trying to understand
<phadthai> err rplacd
<dre> so like, '(1 2 3 x) is just "as is" where if I did (list 1 2 3 x) the x would be evaluated?
<beach> phadthai: That's not so great advice. RPLACA and RPLACD should be considered the underlying mechanism for (SETF CAR) and (SETF CDR), and the latter should be used by applications.
<akater[m]> dre: There's no need to manually print the results.
<phadthai> yes, for cons cells
<jackdaniel> dre: yes
<dre> akater[m], the setf only returns the value that it sets, not the whole x
<dre> here
<dre> here's a question: can I (setf value t) inside a mapcar ?
<akater[m]> dre: Just return the value you're interested in, x here.
<dre> akater[m], so (let ((x (list 1 2 3 4))) (setf (car x) t) x) ;-- you're right. thanks.
<dre> I was just demoing in the repl
<dre> is anyone up to date with AoC day 4? you'll love the code I have so far...
<akater[m]> dre: You can setf anywhere but “setf value” will often just modify the local reference, not the data itself.
<dre> ah ok that's good to know
<dre> so this is my general idea: https://dpaste.org/y6RX
<akater[m]> dre: (setf (car ..) ..) or (setf (some-accessor ..) ..) will (most often) modify the data. setf var normally reassigns the variable.
<dre> "setf var normally reassigns the variable." that is a good way to think of it, thanks. easy for me to "grok"
<dre> the story with AoC-4 is that, we're given a comma seperated list of pickings, ( like "12,343,65,523," ) then a collection of newline-deliminated boards. and we effectively just play bingo from that.
<dre> here ^ I'm parsing the input and getting the data structures right. ignore *boardidx*
<jackdaniel> what is the prize if you hit bingo?
<dre> a nice bottle of jackdaniel
<akater[m]> dre: Also, I say “most often“, etc. everywhere because a setf call can actually run arbitrarily complicated code, or even have no effect at all. At this level you probably shouldn't bother with that but I don't want to misinform.
<jackdaniel> your code style is almost acceptable ,)
<jackdaniel> comments between lines in the body should start with two semicolons like ";; foo"
<dre> thanks. it seems like a lot of things in lisp have some footnotes that require some "more than noob" understanding to be able to get it. I'm getting there
<jackdaniel> and you shouldn't put closing parens in a separate line
<dre> ah yes yes sorry i keep forgetting that, and now I'm noticing all the stray closing parens...
<dre> yes I will resolve that :P
<dre> dang procedural upbringing
<jackdaniel> in cond you usually break the line after the test (eventually, when they are short like yours, align "bodies" to start at the same column)
<jackdaniel> but generally at first glance it looked just fine, so I can tell that you're trying to follow the "usual style"
<dre> neat, thanks
<dre> i didn't know that body thing
<jackdaniel> also, top-level comments (i.e not in a function body) start with three semicolons
<jackdaniel> ;;; bam
<jackdaniel> one semicolon is for comment in the same line as the code (at the end)
<jackdaniel> and four semicolons are for some top-level comment at the beginning
* Qwnavery proceeds to write `list` by running a for loop over a quote block with eval
<dre> Qwnavery, you can just macro that out
<Qwnavery> :P
<dre> ok jackdaniel thanks, it's good to get things right
<Qwnavery> "unusual style"
<dre> but being 8pm on a sunday, i need to get this down pat
<dre> before work
<dre> so I think I have the data structures right, and I'm aiming to turn the value on each board into a t when that number has been used. ( then I just try to find a whole row of t's and I should be fine)
<jackdaniel> (if (equal v picking) (setf v t)) is a no-op (because you modify a lexical variable that is discarded soon after
<dre> do I have to use a (loop .... and a (setf (nthcar x (nthcar y *boards*)) t) .... )
<dre> ?
<dre> yeah I get the no-op
<jackdaniel> also this is a one-leg IF, you should write it like (when (equal v picking) …) ; not to mention that IF legs are aligned with the test
<dre> I just not sure how to get out of it
<dre> oh right, when, yeah I knew that.
<jackdaniel> one way to get it right it to map over the list (or even better loop to not cons)
<dre> oh, wait
<jackdaniel> i.e (loop for reminder on row do (when (equal (car reminder) picking) (setf (car reminder) t)))
<dre> I could setf *boards* ( ... mapcar statements ...) and just "if = return t else return number"
<jackdaniel> sure, if you are collecting things then why not
<dre> right? effectively re-setf'ing it to itself,
<dre> not using loops yet
<jackdaniel> I suppose that this doesn't matter if you care only to get things working - you may cons a new list "functional style" :)
<jackdaniel> so keep in mind to return the original or modified version of the element in each lambda
<dre> I'm not quite confident in cons or loops yett
<jackdaniel> sure
<dre> yeah I'm thinking return the value each time, and just setf it to the *boards*
<jackdaniel> but then you need to assign the mapcar result somewhere
<jackdaniel> makes sense
<jackdaniel> I've just remembered a witty quote from paip (I think): "Common Lisp is a perfect tool to write programs fast. It is also a perfect tool to write fast programs." ,)
<dre> yeah, so like: (setf *boards* (mapcar (L(row) (mapcar (L(V) (if.. (t) (V)) ) row) *boards*)
<dre> sorry, that was hard to type, I'll just try and do it..
<jackdaniel> go ahead, good luck!
shka has joined #commonlisp
poselyqualityles has joined #commonlisp
pve has joined #commonlisp
<dre> oof
<dre> this cl-ppcre is behaving different in the repl?
<dre> (cl-ppcre:split "\\s+" "12 1 2 43 65")
<dre> gives me sensible results (such as ("12" "1" "2" "43" "65")) -- but when I do it in code, I get things like ("" "9" "18" "13" "17" "" "5")
<dre> as in, the leading spaces get parsed as empty strings ??
<dre> I can't remove them..
Oladon has quit [Quit: Leaving.]
lisp123 has joined #commonlisp
<dre> nvm I can just do ALL-MATCHES-AS-STRING
lisp123 has quit [Ping timeout: 256 seconds]
<beach> dre: I recommend you figure out why the different behavior. It is not normal.
<jackdaniel> this regexp will return the first element as empty if there are spaces in front
<jackdaniel> but the empty sequence near the end doesn't seem right
* semz suspects a simple mistyped regex ("\\s" instead of "\\s+")
<semz> might be worth mentioning though that due to a bit of Perl braindamage, cl-ppcre:split behaves strangely near the end unless :limit -1 is provided
<semz> it is Perl-compatible after all
<semz> (cl-ppcre:split "," "foo,bar,") ;=> ("foo" "bar") but (cl-ppcre:split "," "foo,bar," :limit -1) ;=> ("foo" "bar" "")
<jackdaniel> n.b if you just want to split a squence, then there is a library split-sequence
karlosz has quit [Quit: karlosz]
anticomputer has quit [Quit: quit]
anticomputer has joined #commonlisp
<dre> beach, i could, but then there's also the topic of "yak shaving" ie: rabbit hole of figuring it out.
<dre> switching from "split on \\s+" to "match \\d+" is a sensible change and probably what I should've wrote to begin with as it's more precise.
<hayley> As far as I can tell, the string you were testing at the REPL did not include leading spaces.
s-liao has quit [Ping timeout: 256 seconds]
<dre> brb dinner. this is my current code.https://dpaste.org/f583#L
<dre> hayley, I... don't understand
<dre> the file I'm reading from has a line like: " 1 2 32 54 76 3 23" so I tried to do similar,
<dre> brb fire in kitching
<hayley> So far I'm very tempted to try to do the Advent of Code problems in APL.
<beach> dre: WHILE LINE is still a violation of the rules stated by Norvig and Pitman on page 13 of the LUV slides.
<beach> dre: And (= 0 ...) can be better expressed as (zerop ...).
<beach> dre: And you still have mysterious multiple consecutive blank lines.
<beach> dre: And the line INPUT-STRINGS) is badly indented.
<jackdaniel> how should it be indented then?
<beach> Oops. My bad. Misread the preceding line.
<beach> Because of the unusual alignment of the clause forms.
<jackdaniel> for length, a better predicate would be (alexandria:length= 0 line) because it has a compiler macro that optimizes check for constant integers
<jackdaniel> but for a string accessing length is O(1) so nvm
<beach> Do we have Emacs commands for aligning the forms in COND clauses?
<beach> If not, that's a lot of work. Plus, it potentially wastes a lot of whitespace.
s-liao has joined #commonlisp
<beach> dre: It's a much better idea to 1. Not have a newline after COND, and 2. Have the first line of each clause be the test, and then each remaining form on a new line.
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
<dre> <beach> dre: WHILE LINE is still a violation of the rules stated by Norvig and Pitman on page 13 of the LUV slides.
<dre> well then how the bloody hell do i fix it in
<beach> (UNTIL (NULL LINE))
<dre> zerop -- thanks.
<beach> Er, UNTIL (NULL LINE)
<dre> neat, thanks.
<dre> yep got it
<dre> beach> dre: And the line INPUT-STRINGS) is badly indented.
<dre> why?
<beach> No, I was wrong.
<dre> input strings is the second argument to the mapcar, (lambda being the first)
<dre> oh ok
<beach> Confused by your alignment of the COND clauses.
attila_lendvai has quit [Ping timeout: 256 seconds]
lisp123 has joined #commonlisp
lisp123 has quit [Remote host closed the connection]
poselyqualityles has quit [Ping timeout: 252 seconds]
Inline has joined #commonlisp
cage has joined #commonlisp
empwilli has joined #commonlisp
peterhil_ has joined #commonlisp
peterhil has quit [Read error: Connection reset by peer]
<frgo> Good day everybody. I am currently working on getting c2ffi and cl-autowrap working on arm64 (macOS M1). Should I use "aarch64" as the architecture identification or "arm64"?
pdietz has quit [Ping timeout: 256 seconds]
attila_lendvai has joined #commonlisp
<utis> doesn't cl-ppcre support subroutines like (?1) ?
lisp123windows has joined #commonlisp
<lisp123windows> What's the best library for creatng portable sockets in CL? Sorry I'm very new to this topic
<hayley> usocket
<lisp123windows> hayley: thanks!
<utis> anyway, what is the reference to use for the regex syntax?
Inline has quit [Ping timeout: 268 seconds]
s-liao has quit [Quit: Client closed]
<jackdaniel> frgo: do what trivial-features does
<jackdaniel> (namely arm64)
lisp123 has joined #commonlisp
<frgo> Ah - very good point. Wasn't aware of that. Thanks jackdaniel!
<jackdaniel> sure
<jackdaniel> n.b that should be specified in spec.md, I just happen to remember that it is arm64
<Nilby> utis: I just use "man perlre" and the cl-ppcre docs, in docs/index.html mention what hasn't been implemented. But keep in mind it's probably circa perl5.
lisp123 has quit [Ping timeout: 256 seconds]
<utis> Nilby: there's no mention of subroutines or recursion, which seem to be features of pcre
waleee has joined #commonlisp
mingus has joined #commonlisp
Inline has joined #commonlisp
cosimone has joined #commonlisp
makomo has joined #commonlisp
<Nilby> utis: I've never tried to use that. But I think you can call filter functions if you use the parse tree syntax.
treflip has quit [Quit: time to work]
mingus has quit [Ping timeout: 252 seconds]
random-nick has joined #commonlisp
igemnace has joined #commonlisp
Algernon69 has joined #commonlisp
Algernon91 has quit [Ping timeout: 240 seconds]
jpl01 has joined #commonlisp
Algernon69 has quit [Ping timeout: 240 seconds]
tyson2 has joined #commonlisp
poselyqualityles has joined #commonlisp
s-liao has joined #commonlisp
lisp123windows has left #commonlisp [ERC (IRC client for Emacs 26.3)]
lisp123 has joined #commonlisp
kennyd has joined #commonlisp
<utis> is there a nice way to avoid the repetition in (do ((c (read-char in nil) (read-char in nil))?
lisp123 has quit [Ping timeout: 252 seconds]
<utis> i thought it might be possible to write a macro that would be used like (do ((c (ditto (read-char in nil)) . . but couldn't quite figure out how
<_death> you can (do ((c #1=(read-char in nil) #1#) ...) ...), use some other operator like loop, or just not worry about it
<pjb> While (do ((c #1=(read-char in nil) #1#) ...) ...) should work, it is not advised to use structure sharing in code, since it can lead to circular code, whic would most certainly not work. Even simple structure beside literals, can lead to strange compiler behavior.
<_death> if the form being repeated is complex, consider extracting some of it to a function
<pjb> (eg. wrong error message reporting, bad optimization, possibly wrong code generation).
<edgar-rft> utis: the known limitations of DO were one of the reasons why LOOP was included in the CL standard
<utis> thanks!
yewscion44 has joined #commonlisp
<Nilby> I like (loop for c = (read-char in nil) while c do …)
yewscion44 is now known as yewscion
<beach> Nilby: So either you didn't read my remark to dre before, or your opinion is more valuable than that of Norvig and Pitman.
azimut_ has joined #commonlisp
<jackdaniel> beach: putting (not (null foo)) where generalized boolean suffices is not a very common convention
<jackdaniel> it is not ambiguous either
Guest74 has joined #commonlisp
<jackdaniel> so perhaps more people disagree with these smart people
azimut has quit [Ping timeout: 276 seconds]
<beach> I don't think I mentioned (not (null foo)) today.
<beach> So that would be putting words into my mouth.
<jackdaniel> sorry, you are right. I have until (null foo) categorized the same in my mind (I agree that they are different, but the remark above still is applicable)
<jackdaniel> that was not my intention
<beach> Good.
<beach> I know that some people here disagree with these two smart, knowledgeable, and highly experienced developers. But unless those people can somehow convince me that they are smarter, more knowledgeable, or more experienced, I will continue pushing the opinion of Norvig and Pitman.
aartaka has quit [Ping timeout: 252 seconds]
<beach> It is also find if those people do whatever they want in their own code, but it would be good if they were to be more careful when giving advice to others.
<beach> s/find/fine/
<jackdaniel> it is not that smart, knowledgeable, and highly experienced people are always correct (and it is not that it requires being smarter, more knowledgeable and more expierienced to disagree - especially when it comes to stylistic preferences)
<beach> But it is not a "stylistic preference". It has to do with the speed with which the person reading the code can understand it. So maybe you are faster than I am, but when I see WHILE C, I mentally have to stop and do the transformation into UNTIL (NULL C) which takes time. And a know for a fact that when I experience something like that, I am not unique.
<jackdaniel> perhaps this is a personal quirk of mine, but 'WHILE c' is for me faster to parse (as an idiom) than UNTIL (NULL C) (perhaps because of a double negation?)
<beach> So perhaps I should start putting it like this: Perhaps you don't care about people like me, of which we think there are a lot, but the very smart, very knowledgeable, and highly experienced developers Norvig and Pitman have apparently worked in development teams with such people, because they recommend you make their life easier by wasting less of their time.
<beach> jackdaniel: There is no double negation. UNTIL (NULL C) means "until C is a default value rather than a character", not "until C is not true"
<attila_lendvai> interesting. i think processing (while c ...) is faster/easier for me than (until (null c) ...)
<beach> Write WHILE (CHARACTERP C) instead if you worry about NULL.
<Guest74> Styles change with the times, like language in general does. Do Norvig and Pitman even Lisp anymore?
<beach> Guest74: This is not about style, as I said.
<jackdaniel> I have no information how thorugh they were with gathering data about other developers (perhaps they indeed gathered some insightful statistics, but that doesn't seem very probable for a style guide). UNTIL reads for me as (COMPLEMENT WHILE) - but as I've said, this may be very much a personal inflexibility
poselyqualityles has quit [Ping timeout: 252 seconds]
<jackdaniel> I think that I have nothing interesting to add so I'll keep quiet now (unless asked about something)
<beach> Same here.
<Guest74> beach: style, language, and communication are intertwined. those who 'invented' texting may have caused headaches in their parents, but for them it was easier to parse.
aartaka has joined #commonlisp
<beach> Guest74: I get the hint.
jpl01 has quit [Remote host closed the connection]
<Guest74> You may have inferred more than what I meant/wrote, I don't know what this 'hint' is.
igemnace has quit [Ping timeout: 256 seconds]
notzmv has quit [Ping timeout: 268 seconds]
<Guest74> for reading files I just use :until (eql char :eof) which methinks communicates more info.
<beach> Yes it does because it makes the default value more specific, so it can't be confused with a Boolean.
<beach> It perfectly mimics what I said above namely it means "until C is a default value rather than a character".
Nilby has quit [Quit: [deleted]]
Alfr is now known as Guest4714
Guest4714 has quit [Killed (strontium.libera.chat (Nickname regained by services))]
Alfr has joined #commonlisp
<Guest74> I remember reading a lot of that in old code, but not so much in recent code.
yewscion has quit [Quit: Connection closed]
yewscion has joined #commonlisp
<yitzi> I like Pittman's (I believe) trick of using the stream itself as the eof value. Works with read.
<beach> Clever.
<beach> Also avoids the Boolean confusion.
<yitzi> But, yeah :eof is the value used in the Gray stream protocol
<beach> True.
makomo has quit [Ping timeout: 256 seconds]
<jackdaniel> yitzi: what does it give you? (I'm not aware of the trick)
<beach> jackdaniel: No need to invent yet another default value.
<beach> Not that one more :EOF matters, of course.
<_death> jackdaniel: it gives you a "unique" value for READ to return
<jackdaniel> I see, I thought that there are some other consequences. Thanks.
<jackdaniel> I was fixated on read-char when thinking about this (so nil seemed fine)
<yitzi> jackdaniel: Allows one to read :eof also. No danger of reading the eof indicator.
<jackdaniel> makes sense, yes
kennyd has quit [Quit: CGI:IRC]
<jackdaniel> I think that I did once use an uninterned symbol for that, but using the stream makes more sense
kennyd has joined #commonlisp
<beach> I have been using (LIST NIL), but using the stream avoids consing and it avoids another lexical variable.
<yitzi> Yes, I have seen that too. Using the stream is maybe a little less obvious to the casual reader as to what is going on...but it's clever.
<Guest74> hm, I find that more confusing than :eof.
<beach> Guest74: But :EOF doesn't work for READ.
<Guest74> (read stream nil :eof)?
<beach> Guest74: The stream can very well contain the :EOF symbol.
<beach> But it can't contain the stream.
<_death> #.*the-stream* ;)
<Guest74> ah, well, not in any streams I've been 'read'ing.
<beach> Relying on that might create some very subtle bugs.
<Guest74> I try to avoid READing lisp or texts.
<Guest74> I'm waiting for someone to write a nice safe reader or sandbox environment.
<jackdaniel> then wait no more, use eclector
<beach> Guest74: Eclector is not "safe"?
<Guest74> tbh, I still have nothing to read.
<jackdaniel> then why are you waiting?
<Guest74> Though I have been thinking about it. About how to store defaults.
<beach> yitzi: I will try to remember that one.
<Guest74> e.g., writing an interface to the openweather api, and wondering where to store things like units, api key, etc...
<Guest74> But since it's an interface that a frontend writer would use, I'm not even sure that's my responsibility.
<Guest74> Though when I write a frontend, I'd still face the same issue.
<yitzi> beach: Cool. One can definitely see the necessity of it in something like SBCL's do-forms which reads forms to be evaluated while preserving source code info.
<_death> load it
<Guest74> where does *source-info* come from?
<_death> see yitzi's link
unyu has quit [Quit: WeeChat 3.3]
<Guest74> but in general, should we be LOAD/READing human writable configurations?
<_death> it depends
unyu has joined #commonlisp
<Guest74> I actually wrote something that archives and restores symbols to/from disk. Not even sure why. with the ability to load a certain save by timestamp.
<_death> from your description, I would say leave the storage details to the user.. maybe make it easy to query for a plist containing the current settings or something
<Guest74> everything is currently in specials. my thinking being a frontend can just bind those.
<Guest74> Now if you've got a graphical frontend, do people automatically expect you can configure it through the gui?
<_death> that's one way.. another is to create an instance containing the stuff..
<_death> maybe have a single special for that
<Guest74> I swear this is the hardest part of programming. At least for me.
<Guest74> I kinda still want people to just be able to call the functions from the repl if they want, without having to bind a settings object.
<_death> &key (client *client*)
taiju has quit [Ping timeout: 256 seconds]
taiju has joined #commonlisp
<Guest74> What I've thought of for some vector stuff is having &key (style *style) stroke fill etc... and then doing (or(stroke)(style-stroke style)) but not sure how nice that is stylistically or having a bunch of things cluttering &key
<Guest74> but it would allow the exact same semantics as svg.
<Guest74> oops, no () on stroke.
lisp123 has joined #commonlisp
<_death> in limited cases the FORMAT (i.e. t -> *standard-output*) approach may also make sense.. in macros you can just omit the default (out "foo") and provide the user with special syntax to specify the target if needed, like (out (:to a-stream) "foo")
<Guest74> something to think about. I still need to refactor things as lots of redup in api calls, and want each function to work with either city, id, or lat/long.
Alfr has quit [Killed (tantalum.libera.chat (Nickname regained by services))]
Alfr has joined #commonlisp
makomo has joined #commonlisp
s-liao has quit [Quit: Client closed]
<Xach> I have the clutter of ((:credentials *credentials*) *credentials*) in my lambda lists, so they can be overridden dynamically or statically in various ways.
cage has quit [Remote host closed the connection]
asarch has joined #commonlisp
cage has joined #commonlisp
<_death> Xach: careful with that.. if the user is able to pass a function, the rebinding should be part of the documented behavior
Inline has quit [Quit: Leaving]
<Guest74> xach: I guess I can make a big mess and write &key (style*style*) (fill (style-fill style))(stroke (style-stroke style), that might get ugly with all the vars.
<Guest74> the idea is to support theming in the UI and the ability to override it in each function.
<Guest74> ugh, maybe i need a layer inbetween.
asarch has quit [Quit: Leaving]
<lisp123> Guest74: Have a read of the CLIM source code, IMO its quite useful in seeing good ways to deal with such things
<Guest74> no thanks for the third time.
<lisp123> I didn't say to use it
<lisp123> I said to check out its code for inspiration around optionals / keywords
<lisp123> w.r.t to &key (style *style*) etc
<lisp123> What I appreciated more after working with CLIM was the use of dynamic variables for defaults as it can make things a bit faster (only requiring you to shadow the variable when you want to override it vs. creating a new binding in each call)
<lisp123> (I hope I understood the intent correctly, I assume it was due to the above ^)
Oladon has joined #commonlisp
<jackdaniel> since we are at it, i.e drawing context is not about shadowing variables but rather their state. i.e (with-drawing-options (stream :ink +red+) …) changes the stream's ink for the reminder of the operator dynamic scope
<lisp123> jackdaniel: Yes, that's a more correct way to put it
<jackdaniel> currently not thread-safe™, but in principle it is possible - I believe that contextL allows danamically bound slots
<jackdaniel> dynamically*
voltron has joined #commonlisp
<lisp123> jackdaniel: Sorry I am a bit slow today (everyday?). What do you mean by the last part
<jackdaniel> lisp123: https://github.com/pcostanza/contextl is a library created by Pascal Costanza
<jackdaniel> it operates on a concept called "layers" that may be dynamically bound and influence the class behavior
<lisp123> jackdaniel: Thanks for the link. Interesting stuff
<jackdaniel> sorry for not being able to describe it better - I'm not well familiarized with the library; I'm only aware of it :)
<lisp123> No worries, I kinda of get it. But its like AOP, sometimes too much abstraction makes things too advanced for the average programmer
<lisp123> IMO one has to be careful with too much shenanigans at runtime. But in large projects it does make a lot of sense
sjl has quit [Quit: WeeChat 2.2-dev]
aeth has quit [Ping timeout: 256 seconds]
aeth has joined #commonlisp
Algernon69 has joined #commonlisp
euandreh has joined #commonlisp
notzmv has joined #commonlisp
engblom has joined #commonlisp
<engblom> It looks like macrolet is not working inside of a macro. Is that true or do I have some typos?
taiju has quit [Ping timeout: 252 seconds]
<beach> There is no such restriction, so you must be doing something strange.
<engblom> Thanks
<engblom> So (defmacro foo (bar) (macrolet ((baz (qux) ..... ) ....)) is OK?
<beach> Sure.
lisp123 has quit [Remote host closed the connection]
<engblom> I must be doing something stupid. As there seems to not be much activity on the channel at this moment I will paste a macro;
<engblom> (defmacro getf-hash-plist (hash-or-plist key)
<engblom> `(getf ,hash-or-plist ,key)))
<engblom> (if (hash-table-p (eval hash-or-plist))
<engblom> `(gethash ,key ,hash-or-plist)
<engblom> When I have this macro outside of another macro, everythign works. As soon as I move it inside that macro and use (marolet) it no longer works. Is there something I need to do when moving it inside of another macro?
<beach> I think your parentheses are unbalanced. But please use a paste site for more than one line of code.
<beach> Maybe your lines came across out of order.
<beach> engblom: EVAL is a bad sign.
<beach> If you seem to need to evaluate the argument to a macro, it's a sign that you should use a function instead.
<engblom> I will put the whole problem to a paste site.
<beach> In fact, I am pretty sure this should not be a macro.
<engblom> Here is the whole thing: https://pastebin.com/DX2XNWSH
<engblom> As it is there in the pastebin, it is working. However if I move the macro inside the other with macrolet, it does not work anymore.
<beach> You must have TABs in your code because it is incorrectly indented.
<beach> I'll let someone else have a look at that. I am too tired to figure it out, and I need to go fix dinner for my (admittedly small) family.
aeth has quit [Ping timeout: 252 seconds]
<engblom> beach: It seems like emacs running evil will place tabs when doing gg=G (which is to go to top and then indent everything all the way down to bottom)
perrierjouet has quit [Quit: WeeChat 3.3]
aeth has joined #commonlisp
<engblom> beach: Thank you anyway for trying to look at it.
Oladon has quit [Quit: Leaving.]
perrierjouet has joined #commonlisp
Algernon91 has joined #commonlisp
<engblom> Apparently Emacs does indent with tabs as default. I have now set (setq indent-tabs-mode nil) in .emacs. The new correctly indented paste is here: https://pastebin.com/1DDL2Z2g
Algernon69 has quit [Ping timeout: 245 seconds]
aeth has quit [Ping timeout: 252 seconds]
aeth has joined #commonlisp
yewscion has quit [Quit: Connection closed]
yewscion has joined #commonlisp
Inline has joined #commonlisp
lisp123 has joined #commonlisp
<cage> hi! A friend of mine is trying to make a bsd port for a lisp program but it fails with this error on osicat/cffi grovel, here is the backtrace: https://clbin.com/e4bSH
<cage> any idea?
op2 has joined #commonlisp
<jcowan> TIL that keyword names in a lambda list don't in fact have to be keywords: any symbol will work.
lisp123 has quit [Ping timeout: 268 seconds]
treflip has joined #commonlisp
<jcowan> What's the collective wisdom on having both optional and keyword parameters? Just fine, speciel cases only, or stylistically bad?
lisp123 has joined #commonlisp
voltron has quit [Remote host closed the connection]
<lisp123> jcowan: depends on your use case IMO
<lisp123> When certain variables are likely to be supplied and its annoying to type :keyword first, then optionals shine
<lisp123> Where there are multiple different parameters, then keywords are helpful
<lisp123> And when mixing the two, think about how the user will call the function. In general IMO good to stick to just keywords in that case, but if there's a keyword that one will use very often, then might as well throw it in there as an optional
voltron has joined #commonlisp
<lisp123> For internal code, mixing is also not too bad, but for external code, I guess it can be slightly off putting
<lisp123> According to PCL: Combining &optional and &key parameters yields surprising enough results that you should probably avoid it altogether.
<jcowan> an optional perhaps should be replaced by mandatory-with-null-value, where null value is either nil or a magic object: (define-constant magic-object #:magic-object)
<jcowan> if it is almost always present
<lisp123> That tends to be the way I write
<lisp123> I mean, I use default values for optionals and will write them as keywords
tyson2 has quit [Remote host closed the connection]
<lisp123> As a final point from me, I may combine &optional &key when writing functions in a quasi-modular way - e.g. (defun remove-duplicates-from-hash-table (&optional (table *my-hash*) &key (test #'equal)) ....), and in the future if the code needs to be abstracted to a utilities function, I would replace the optional part with a keyword
notzmv has quit [Ping timeout: 245 seconds]
<lisp123> But at least at the earlier quasi-modular step, I can refer to TABLE vs. *my-hash* in my code, without unnecessarily burdening calling functions by require table name to be always supplied
Lycurgus has joined #commonlisp
notzmv has joined #commonlisp
rotateq has joined #commonlisp
Lycurgus has quit [Quit: Exeunt]
Alfr has quit [Ping timeout: 256 seconds]
yewscion_ has joined #commonlisp
yewscion is now known as Guest2713
yewscion_ is now known as yewscion
treflip has quit [Remote host closed the connection]
Guest2713 has quit [Ping timeout: 252 seconds]
akoana has joined #commonlisp
dra has joined #commonlisp
<jackdaniel> jcowan: don't mix them. in fact, never use optional for exported interfaces
Algernon91 has quit [Ping timeout: 240 seconds]
skeemer__ has joined #commonlisp
amb007 has quit [Ping timeout: 256 seconds]
amb007 has joined #commonlisp
akoana has quit [Ping timeout: 256 seconds]
skeemer has quit [Ping timeout: 256 seconds]
akoana has joined #commonlisp
Inline has quit [Quit: Leaving]
<engblom> I am asking once more in case someone has joined who would be able to answer. Why is https://pastebin.com/1DDL2Z2g working as it is in the paste, but not if I move the upper macro inside the lower with help of macrolet?
<engblom> Also, could this be done in a better way?
<jackdaniel> engblom: please show both versions
<jackdaniel> also if that's not too much paste them on plaster.tymoon.eu
<jackdaniel> pastebins are unusable with all ads and cookie popups on mobile
<engblom> jackdaniel: Here is the first version (which works): https://plaster.tymoon.eu/view/2753#2753
<engblom> jackdaniel: I do no longer have the macrolet version, but I definied the inner macro right before the labels
<jackdaniel> well, how things are nested makes a difference, that's why I ask
<jackdaniel> you could have ysed in the expansion a macro that is available in the macro environment
<jackdaniel> or vice versa
<engblom> I will try to remake the version I had that did not work
<Guest74> is there a reason why getf-hash is a macro?
<jackdaniel> there clearly is, because build-rsetf puts the expansion in the location position
<engblom> Here is the version where I combined version that is not working: https://plaster.tymoon.eu/view/2754#2754
<engblom> combined everyting*
<jcowan> jackdaniel: I don't know: would you rather write (print x out) or (print x :ostream out)? Surely the first is just as clear?
karlosz has joined #commonlisp
<jcowan> (print x :to out) has some merit, I guess
<jackdaniel> engblom: as I have suspected - you define the macro in macro environment
<jackdaniel> and use it in the function env
<jackdaniel> that can't possibly work
<jackdaniel> btw, your snippet has awful indentation
<engblom> jackdaniel: How would you do it? I mean, the function is recursive so I would not want to define the macro for each iteration.
<jackdaniel> hang on, I'll switch to computer from my phone
<engblom> jackdaniel: Yes, I was in hurry to copy and paste the macro and forgot to tell the editor to reindent the stuff
<engblom> Here is the editor indented code: https://plaster.tymoon.eu/view/2755#2755
taiju has joined #commonlisp
<jackdaniel> without checking: https://plaster.tymoon.eu/view/2754#2756
<jackdaniel> the little one is calling, a night story time ciaos
pdietz has joined #commonlisp
<engblom> jackdaniel: It is complaining about value being unbound
<engblom> "The variable VALUE is unbound."
<jackdaniel> unquote it in recursive call to build-setf
cage has quit [Quit: rcirc on GNU Emacs 27.1]
<engblom> Now it is saying "The variable KEYS is unbound."
aartaka has quit [Ping timeout: 256 seconds]
aartaka has joined #commonlisp
karlosz has quit [Quit: karlosz]
<engblom> Actually, if there exists something like plist-hash-table from alexandria, but recursive, I could simplify it a lot.
zos has joined #commonlisp
Oladon has joined #commonlisp
<pjb> engblom: getf-hash-plist cannot work: (let ((map (if (zerop (ramdom 2)) (make-hash-table) '(:k1 v1 :k2 v2)))) (getf-hash-plist map :k1))
<pjb> engblom: do you understand why it cannot work?
<engblom> pjb: That part really works for this specific case
<pjb> engblom: try: (let ((map (if (zerop (ramdom 2)) (make-hash-table) '(:k1 v1 :k2 v2)))) (getf-hash-plist map :k1))
<jackdaniel> engblom: generally if you need to call eval on the object then you probably shouldn't use a macro
* jackdaniel is back
Alfr has joined #commonlisp
<pjb> engblom: or try: (let ((p '(k1 (k11 1 k12 2) k2 3))) (rsetf p 44 k1 k12))
theothornhill has joined #commonlisp
<theothornhill> Is it hard to make a program async in retrospect, in common lisp? As I'm doing my first implementation I don't want to deal with that to make sure things are correct first. Is that stupid?
<pjb> theothornhill: no, it's not hard. Instead of (program), write (bt:make-thread (lambda () (program)))
<theothornhill> Is that so? Nice. That's what I was hoping for
tyson2 has joined #commonlisp
<pjb> engblom: macros are functions that tranform programs (or program elements) into programs. The macro getf-hash-plist cannot test the data, since the data will only be known at run-time. It can only test the program, ie. the symbols and the expressions.
<jackdaniel> engblom: you may use i.e this function https://plaster.tymoon.eu/view/2754#2757
lisp123 has quit [Quit: Leaving...]
<jackdaniel> that could be made an iteration as well
<engblom> jackdaniel: It seems to not work when I test it with my data. I get "debugger invoked on a TYPE-ERROR in thread" where it confuses the key of a hashtable with the hash table itself
<mfiano> For a C struct defined with cffi:defcstruct, if a slot specifies an offset, is it optional for all subsequent slots to not be realigned? Quick testing says yes, but I just want to confirm I do not have to specify :offset for all following slots if they are to be contiguous with the single offsetted slot's memory.
<engblom> jackdaniel: The structure I tested it with a is a hash table where each value is a plist
<jackdaniel> engblom: as the error tells you, the order of arguments is wrong
<jackdaniel> you may try to fix it yourself
<engblom> jackdaniel: Got it, it was in gethash that the arguments were in wrong order. Now it does not give any error message, but it also does not set the value
<mfiano> Are both of these equivalent? https://plaster.tymoon.eu/view/2758#
<jackdaniel> engblom: it does here. you need to be more specific
<pjb> mfiano: try macroexpand.
<mfiano> pjb: That is only going to leave me with the same question.
<mfiano> I have already done that
<pjb> so the answer is in cffi::notice-foreign-struct-definition
<mfiano> I'm not asking if the expansion is the same.
<mfiano> I'm asking if the semantics are
<mfiano> Obvious the semantics are not
<mfiano> err the expansion is not
<pjb> the answer is probably in the documentations, but if not, in cffi::notice-foreign-struct-definition.
<engblom> jackdaniel: So, I have a globally definied variable. It is a nested structure consisting of hash-tables and plists. I try to alter a value by giving the whole path given by the keys. When I run your function with value 5, it does not change the value to 5. It is still the old value when I check up the data structure.
<mfiano> Quick glance at the code suggests it keeps an accumulated offset
<mfiano> I'll say 'yes', and move on
aartaka has quit [Ping timeout: 256 seconds]
<jackdaniel> engblom: https://plaster.tymoon.eu/view/2758#2759 perhaps this
aartaka has joined #commonlisp
* jackdaniel goes to bed, see you \o
<engblom> jackdaniel: That one replaced the whole inner plist with the value
<jackdaniel> perhaps you were short by one key?
<jackdaniel> I think that you have enough material to experiment, let me know if you have succeeded (I'll read the logs tomorrow)
azimut_ has quit [Remote host closed the connection]
aartaka has quit [Ping timeout: 252 seconds]
azimut has joined #commonlisp
voltron has quit [Remote host closed the connection]
<engblom> pjb, jackdaniel: thank you both. I have saved the code snippets you have created and I will test more tomorrow. It is very late here too, and my children wants to go to sleep so I need to quit here
attila_lendvai has quit [Ping timeout: 252 seconds]
dra has quit [Remote host closed the connection]
cjb has joined #commonlisp
cosimone has quit [Quit: ERC (IRC client for Emacs 27.1)]
azimut has quit [Remote host closed the connection]
azimut has joined #commonlisp
<mfiano> How can I allocate a foreign buffer of N bytes with CFFI, if I don't want to calculate it based on "count" of "type"?
<mfiano> just an opaque region of memory
<pjb> Use :char as type.
<yitzi> use a type of '(unsidgned-byte 8)
<pjb> this is not foreign.
<yitzi> gotcha.
<pjb> (cffi:FOREIGN-ALLOC :char :initial-element 0 :count 10)
<pjb> or :uchar
attila_lendvai has joined #commonlisp
aartaka has joined #commonlisp
Qwnavery has quit [Quit: WeeChat 3.3]
<mfiano> pjb: Thanks. I just wrote my first bit of cffi ever
<mfiano> I am probably doing this very poorly, but it at least works
<pjb> Seems ok.
<mfiano> I was originally passing in the type to the macro and getting the foreign type size of that, but this can change dynamically, and that is a bad idea the syscall manual says, so the first syscall in the macro figures out the actual size of a buffer it will write to
<pjb> Indeed. C API need to be like that.
aeth has quit [Ping timeout: 252 seconds]
attila_lendvai has quit [Ping timeout: 252 seconds]
aeth has joined #commonlisp
Algernon91 has joined #commonlisp
<Guest74> are there any good macro tutorials out there?
kennyd has quit [Quit: CGI:IRC]
akoana has quit [Quit: leaving]
shka has quit [Ping timeout: 252 seconds]
Algernon666 has joined #commonlisp
hobo has joined #commonlisp
Algernon91 has quit [Ping timeout: 240 seconds]
op2 has quit [Ping timeout: 252 seconds]
aartaka has quit [Ping timeout: 252 seconds]
<pdietz> My suggestion for macros is to not try to use quasi-quote to generate quasi-quote forms.  Put the guts off in a function somewhere.
<Guest74> my problem was wanting to pass in a list as a symbol, process that list in a function, and splice it into the expansion. Was, because dexador doesn't seem to work inside the macro with https, or without a port.
Lycurgus has joined #commonlisp
<Guest74> and now it works.
<Guest74> now back to wanting to pass in a special holding a list.
notzmv has quit [Ping timeout: 245 seconds]
mrcom__ has joined #commonlisp
mrcom_ has quit [Ping timeout: 252 seconds]
theothornhill has quit [Ping timeout: 252 seconds]
tyson2 has quit [Remote host closed the connection]
dre has quit [Ping timeout: 252 seconds]
notzmv has joined #commonlisp
kennyd has joined #commonlisp
karlosz has joined #commonlisp
Algernon91 has joined #commonlisp
Algernon666 has quit [Ping timeout: 240 seconds]
igemnace has joined #commonlisp
karlosz has quit [Quit: karlosz]
random-nick has quit [Ping timeout: 256 seconds]
pve has quit [Quit: leaving]
gaqwas has quit [Ping timeout: 252 seconds]
tyson2 has joined #commonlisp
akoana has joined #commonlisp
abrahms665920 has quit [Ping timeout: 256 seconds]
Algernon91 has quit [Ping timeout: 245 seconds]
dre has joined #commonlisp
Guest74 has quit [Quit: Connection closed]