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
<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.
<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>
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
<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.
<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
<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.
<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.
<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
<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>
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
<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>
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
<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.
<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>
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?
<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]