jackdaniel changed the topic of #lisp to: Common Lisp, the #1=(programmable . #1#) programming language | <https://irclog.tymoon.eu/freenode/%23lisp> <https://irclog.whitequark.org/lisp> <http://ccl.clozure.com/irc-logs/lisp/> | offtopic --> #lispcafe
kaftejiman has quit [Remote host closed the connection]
minion has quit [Remote host closed the connection]
specbot has quit [Remote host closed the connection]
specbot has joined #lisp
minion has joined #lisp
nullheroes has quit [Quit: WeeChat 2.9]
vutral has quit [Quit: Connection closed for inactivity]
mrcom has quit [Ping timeout: 265 seconds]
orivej has quit [Ping timeout: 264 seconds]
galex-713 has quit [Ping timeout: 272 seconds]
marusich has joined #lisp
hendursa1 has quit [Quit: hendursa1]
hendursaga has joined #lisp
terpri_ has joined #lisp
terpri has quit [Ping timeout: 244 seconds]
orivej has joined #lisp
_jrjsmrtn has joined #lisp
<remexre> hm, if I wanna rigorously measure the performance of my code (for preventing performance regressions in a certain function), is there standard tooling for doing so?
__jrjsmrtn__ has quit [Ping timeout: 240 seconds]
<mfiano> trivial-benchmark should be decent
<remexre> ooh, that looks nice
ghard has quit [Ping timeout: 260 seconds]
<remexre> oof, though when I quickload it, I get an error about it violating the sb-impl package lock
Bourne has quit [Read error: Connection reset by peer]
<aeth> If you're in SBCL, there are some good non-standard tools for measuring performance.
<mfiano> remexre: ensure SBCL and the Quicklisp dist are up to date. It works here using latest for both
<remexre> ah, yeah, I'm on sbcl 1.4.9
rumbler31 has quit [Remote host closed the connection]
<remexre> I should poke the gentoo maintainers to mark the newer ones as stable...
<mfiano> Ouch. more than 2 years is an eternity in the software world
<mfiano> sbcl-1.4.9: June 28, 2018
wildbartty has quit [Remote host closed the connection]
shifty has quit [Ping timeout: 246 seconds]
orivej has quit [Ping timeout: 256 seconds]
ralt has quit [Quit: Connection closed for inactivity]
<remexre> okay, 2.0.4 wor
<remexre> works, even
wsinatra has joined #lisp
X-Scale has quit [Ping timeout: 256 seconds]
X-Scale` has joined #lisp
X-Scale` is now known as X-Scale
gko_ has joined #lisp
mrcom has joined #lisp
caltelt has quit [Ping timeout: 246 seconds]
rumbler31 has joined #lisp
ldb has joined #lisp
ldb has quit [Read error: Connection reset by peer]
ldb has joined #lisp
<ldb> good morning
_whitelogger has joined #lisp
ldb has quit [Remote host closed the connection]
ldb has joined #lisp
nmg has joined #lisp
space_otter has joined #lisp
Alfr__ has joined #lisp
Alfr_ has quit [Ping timeout: 260 seconds]
_whitelogger has joined #lisp
ldb has quit [Ping timeout: 256 seconds]
Oladon has joined #lisp
ldb has joined #lisp
ldb has quit [Ping timeout: 240 seconds]
ldb has joined #lisp
lucasb has quit [Quit: Connection closed for inactivity]
ldb has quit [Ping timeout: 264 seconds]
ldb has joined #lisp
ldb has left #lisp [#lisp]
rumbler3_ has joined #lisp
rumbler31 has quit [Read error: Connection reset by peer]
wsinatra has quit [Quit: WeeChat 2.9]
Necktwi has quit [Ping timeout: 256 seconds]
zigpaw1 has quit [Ping timeout: 256 seconds]
mindCrime has quit [Ping timeout: 260 seconds]
zigpaw1 has joined #lisp
mindCrime has joined #lisp
_whitelogger has joined #lisp
<beach> Good morning everyone!
Oladon has quit [Quit: Leaving.]
<buoy49> beach: mornin'
<beach> buoy49: How is PCL reading coming along?
Lord_of_Life_ has joined #lisp
Lord_of_Life has quit [Ping timeout: 256 seconds]
Lord_of_Life_ is now known as Lord_of_Life
kmeow has joined #lisp
<buoy49> beach: it's going well. I'm up to first macros chapter. I've also been messing with a little Telegram bot project that I had started before. It's running hunchentoot. That's the tried & true for little web things, right?
<beach> I think so, yes.
<buoy49> beach: cool. what type of projects do you use lisp for?
Oladon has joined #lisp
<beach> minion: Please tell buoy49 about SICL.
<minion> buoy49: SICL: SICL is a (perhaps futile) attempt to re-implement Common Lisp from scratch, hopefully using improved programming and bootstrapping techniques. See https://github.com/robert-strandh/SICL
<beach> minion: Please tell buoy49 about Cleavir.
<minion> buoy49: Cleavir: A project to create an implementation-independent compilation framework for Common Lisp. Currently Cleavir is part of SICL, but that might change in the future
<beach> Also improving other aspects of our set of development tools.
<buoy49> beach: wow, that's some heavy lifting
<buoy49> I don't much CS or PL stuff. I've learned some on the job, but I'm "self-taught," so to speak
<beach> I see.
<contrapunctus> buoy49: https://teachyourselfcs.com/
<buoy49> contrapunctus: thank you
<buoy49> contrapunctus: I actually own a couple of these books (Computer Systems: A Programmers Perspective & Designing Data-Intensive Applications)
<buoy49> Guess I should start with SICP after PCL. I've been thinking about SICP for awhile. I did the first chapter about 4 years ago, but was neck deep in my first dev gig and didn't maintain that effort
<beach> I would go for PAIP or On Lisp instead.
<easye> Like _Art of Computer Programming_, one is never finished with SICP esp. if you work through the problems.
<easye> _On Lisp_ will definitely open your eyes about macros.
<beach> And PAIP is pretty good about abstraction.
<buoy49> beach: got it
<beach> And, later, if you are interested in how Lisp is implemented, there is LiSP.
<beach> minion: Please tell buoy49 about LiSP.
<minion> buoy49: look at LiSP: "Lisp in Small Pieces". This book covers Lisp, Scheme and other related dialects, their interpretation, semantics and compilation. To sum it up in a few figures: 500 pages, 11 chapters, 11 interpreters and 2 compilers. <http://pagesperso-systeme.lip6.fr/Christian.Queinnec/WWW/LiSP.html>
bhartrihari has joined #lisp
<beach> It is a translation from French, but thanks to the very talented translator, the translation is actually better than the original.
<buoy49> easye: ah, yes. Tbh, I'm not sure if I actually "finished" all the problems of Ch. 1
<easye> buoy49: exactly, 'cuz the problems lead to further questions, which lead to further problems, like all truly great pedagogical texts.
<easye> beach: interesting that the translation is better than the original. Never heard that before. (I don't know French well enough to judge)
<buoy49> beach: that's interesting re: translation, but that seems to be the case with quite a few texts now that I think of it
<beach> I said that partly tongue-in-cheek. The translator is my wife. But I do think it is better.
<buoy49> Ha!
Chiota has joined #lisp
<beach> She is from Houston, by the way.
shangul has joined #lisp
<easye> Houston is somewhat near Paris, Texas...
<buoy49> beach: so is my wife, haha!
<beach> True dat.
<buoy49> easye: you know about Paris, TX? I haven't been there, yet. But I was reading about it the other day, actually
<easye> Never been to Paris, TX. I just know it from the movie.
<buoy49> easye: ah, yes. Forgot about that
Jeanne-Kamikaze has quit [Quit: Leaving]
ldb has joined #lisp
ldb has quit [Read error: Connection reset by peer]
ldb has joined #lisp
* ldb beaking news, mozilla laid off 250 ppl.
gravicappa has joined #lisp
Chiota has quit [Remote host closed the connection]
Necktwi has joined #lisp
terpri_ is now known as terpri
u0_a156 has joined #lisp
FennecCode has quit [Ping timeout: 260 seconds]
ldb has quit [Ping timeout: 240 seconds]
ldb has joined #lisp
dmr0x80 has joined #lisp
ldb has quit [Ping timeout: 256 seconds]
ldb has joined #lisp
FennecCode has joined #lisp
ldb has quit [Ping timeout: 256 seconds]
ldb has joined #lisp
ralt has joined #lisp
ldb has quit [Ping timeout: 264 seconds]
rumbler3_ has quit [Ping timeout: 265 seconds]
galex-713 has joined #lisp
ldb has joined #lisp
dmr0x80 has quit [Ping timeout: 256 seconds]
vutral has joined #lisp
ldb has quit [Ping timeout: 246 seconds]
Nikotiini has quit [Ping timeout: 264 seconds]
mangul has joined #lisp
shangul has quit [Ping timeout: 240 seconds]
pve has joined #lisp
gko_ has quit [Ping timeout: 256 seconds]
ggole has joined #lisp
Nikotiini has joined #lisp
galex-713 has quit [Read error: Connection reset by peer]
galex-713 has joined #lisp
Oladon has quit [Quit: Leaving.]
heisig has joined #lisp
orivej has joined #lisp
wxie has joined #lisp
troydm has quit [Ping timeout: 260 seconds]
farooqkz__ has joined #lisp
scymtym has joined #lisp
dmrintr has joined #lisp
mangul has quit [Ping timeout: 264 seconds]
hendursa1 has joined #lisp
hendursaga has quit [Ping timeout: 240 seconds]
_whitelogger has joined #lisp
Inline has joined #lisp
orivej has quit [Ping timeout: 240 seconds]
gaqwas has joined #lisp
ralt has quit [Quit: Connection closed for inactivity]
drot has joined #lisp
gaqwas has quit [Remote host closed the connection]
gaqwas has joined #lisp
gaqwas has quit [Changing host]
gaqwas has joined #lisp
wxie has quit [Quit: wxie]
troydm has joined #lisp
wxie has joined #lisp
liberliver has joined #lisp
wxie has quit [Ping timeout: 244 seconds]
rpg has joined #lisp
orivej has joined #lisp
gko_ has joined #lisp
mindCrime has quit [Ping timeout: 260 seconds]
kaftejiman has joined #lisp
kaftejiman has quit [Remote host closed the connection]
kmeow has quit [Remote host closed the connection]
vutral has quit [Quit: Connection closed for inactivity]
whiteline has quit [Remote host closed the connection]
whiteline has joined #lisp
orivej has quit [Ping timeout: 240 seconds]
orivej has joined #lisp
orivej has quit [Ping timeout: 260 seconds]
farooqkz__ has quit [Ping timeout: 260 seconds]
v3ga has quit [Quit: WeeChat 2.7.1]
v3ga has joined #lisp
dra_ has joined #lisp
dra_ is now known as dra
rpg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
galex-713 has quit [Quit: No Ping reply in 180 seconds.]
galex-713 has joined #lisp
<jackdaniel> I'm sure that you've read it on internet explorer :)
<dra> Hello!
bhartrihari has left #lisp ["Disconnected: Replaced by new connection"]
bhartrihari has joined #lisp
bhartrihari has left #lisp ["Disconnected: Replaced by new connection"]
bhartrihari has joined #lisp
farooqkz__ has joined #lisp
farooqkz__ has quit [Remote host closed the connection]
madage has quit [Remote host closed the connection]
<contrapunctus> Hello!
pls153 has joined #lisp
random-nick has joined #lisp
madage has joined #lisp
<pls153> COUNTER ACTION other breaking news: someone is already developing a new browser in Rust: https://github.com/twilco/kosmonaut
pls153 has quit [Remote host closed the connection]
<contrapunctus> pls153: orange crab bad
Josh_2 has joined #lisp
_whitelogger has joined #lisp
space_otter has quit [Remote host closed the connection]
dra has quit [Remote host closed the connection]
shifty has quit [Ping timeout: 264 seconds]
cosimone has joined #lisp
scymtym_ has quit [Remote host closed the connection]
scymtym has quit [Remote host closed the connection]
scymtym has joined #lisp
Bourne has joined #lisp
thevishy has joined #lisp
thevishy has left #lisp [#lisp]
bitmapper has quit [Ping timeout: 256 seconds]
contrapunctus has left #lisp ["Disconnected: Replaced by new connection"]
contrapunctus has joined #lisp
ralt has joined #lisp
keutoi has joined #lisp
cosimone has quit [Remote host closed the connection]
cosimone has joined #lisp
yitzi has quit [Quit: yitzi]
yitzi has joined #lisp
FreeBirdLjj has joined #lisp
<Josh_2> mrcom: https://github.com/K1D77A/metalock all slot access happens using a read-writer lock now
<Josh_2> well each slot has It's own read-writer lock
hendursa1 has quit [Quit: hendursa1]
hendursaga has joined #lisp
FreeBirdLjj has quit [Ping timeout: 244 seconds]
mangoicedtea has joined #lisp
keutoi has quit [Ping timeout: 260 seconds]
kaftejiman has joined #lisp
keutoi has joined #lisp
flazh has quit [Ping timeout: 256 seconds]
vhost- has quit [Ping timeout: 265 seconds]
keutoi has quit [Ping timeout: 256 seconds]
vhost- has joined #lisp
flazh has joined #lisp
Bourne has quit [Read error: Connection reset by peer]
yitzi has quit [Quit: yitzi]
rpg has joined #lisp
lucasb has joined #lisp
keutoi has joined #lisp
Inline has quit [Ping timeout: 246 seconds]
jonatack has quit [Quit: jonatack]
jonatack has joined #lisp
EvW has joined #lisp
Inline has joined #lisp
Lycurgus has joined #lisp
bhartrihari has left #lisp ["Disconnected: Replaced by new connection"]
bhartrihari has joined #lisp
mangoicedtea has quit [Quit: Leaving]
kaftejiman has quit [Remote host closed the connection]
keutoi has quit [Ping timeout: 264 seconds]
puchacz has joined #lisp
<puchacz> hi, what version of write / print function is equivalent of (format nil "~a" object) please? object being any object
<puchacz> I just want to stringify it
<puchacz> and if I want to concatenate 2 strings? like (format nil "~a ~a" obj1 obj2) ?
<pve> puchacz: princ-to-string
<puchacz> pve: thanks
<puchacz> and concatenate strings? do I need to with-output-to-string etc.?
<pve> (concatenate 'string (princ-to-string obj1) " " (princ-to-string obj2))
<puchacz> ah, ok, thanks!
<pve> you'll want to define your own cat function
<pve> most likely
<puchacz> concantenate from lisp too slow?
<pve> no, I mean just for convenience
<puchacz> ok
<pve> or do with-output-to-string + (princ foo the-stream)
ralt has quit [Quit: Connection closed for inactivity]
<pve> so you could do like (stringify obj1 " " obj2) or something
<puchacz> I have it with format nil already, maybe the compiler does something sensible with it, but I prefer to make it less ugly
<pve> format nil is fine
<pve> if it's too ugly you can make stringify like above
orivej has joined #lisp
dmrintr has quit [Quit: WeeChat 2.9]
dmrintr has joined #lisp
<phoe> puchacz: #'uiop:strcat
<phoe> if you are not allergic to uiop
liberliver has quit [Ping timeout: 246 seconds]
<jackdaniel> (defun strdog (&rest args) (error "woof"))
<jackdaniel> I find it nice that silly Common Lisp functions fit in one line
<puchacz> phoe: I found strcat in arnesi
<puchacz> all good
dnm has quit [Ping timeout: 272 seconds]
physpi has quit [Ping timeout: 272 seconds]
dnm has joined #lisp
Inline has quit [Ping timeout: 260 seconds]
bitmapper has joined #lisp
physpi has joined #lisp
<puchacz> jackdaniel: your function gives a compilation warning about unused argument. something is wrong with it :)
<jackdaniel> the compiler is barking at the strdog
anewuser has joined #lisp
anewuser is now known as Guest3261
Guest3261 has quit [Remote host closed the connection]
Guest3261 has joined #lisp
Guest3261 has quit [Remote host closed the connection]
Guest3261 has joined #lisp
Guest3261 has quit [Remote host closed the connection]
rpg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Inline has joined #lisp
Lycurgus has quit [Remote host closed the connection]
telior has joined #lisp
<pve> is there some reason to be allergic to uiop?
<pve> I'm somewhat reluctant to use it, but can't really put my finger on why
orivej has quit [Ping timeout: 264 seconds]
terpri has quit [Quit: Leaving]
terpri has joined #lisp
terpri has quit [Remote host closed the connection]
terpri has joined #lisp
<flip214> If a macro wants to store a (static) value per-callsite (same for all threads), is the best way to use use the value slot of a gensym? Is there a more memory-efficient way if I just want to remember a fixnum? (cache for max. size of w-o-t-s)
rpg has joined #lisp
<pve> flip214: would load-time-value work?
jessa^22 has joined #lisp
Lord_of_Life_ has joined #lisp
Lord_of_Life has quit [Ping timeout: 246 seconds]
Lord_of_Life_ is now known as Lord_of_Life
cosimone has quit [Quit: Quit.]
yitzi has joined #lisp
jessa^22 has quit [Quit: Oh my God, why woman was easily to deceived and successfully tempted, then she became the tunnel of all sorts of sins. Adam was only her implicated. OMG nowadays many men impersonate the wicked deceiver to deceive woman online. Why? Brought to you buy 1]
gaqwas has quit [Remote host closed the connection]
gaqwas has joined #lisp
gko_ has quit [Remote host closed the connection]
rpg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
terpri has quit [Quit: Leaving]
terpri has joined #lisp
contrapunctus has left #lisp ["Disconnected: closed"]
contrapunctus has joined #lisp
liberliver has joined #lisp
stoneglass has joined #lisp
ralt has joined #lisp
<ralt> puchacz: you can use uiop:strcat
Bike has joined #lisp
dmrintr has quit [Ping timeout: 264 seconds]
gaqwas has quit [Remote host closed the connection]
<puchacz> ralt: np, I used strcat from arnesi
stoneglass has quit [Quit: stoneglass]
mindCrime has joined #lisp
Oladon has joined #lisp
rogersm has joined #lisp
Inline has quit [Ping timeout: 265 seconds]
Jesin has quit [Quit: Leaving]
liberliver has quit [Ping timeout: 265 seconds]
gaqwas has joined #lisp
gaqwas has quit [Changing host]
gaqwas has joined #lisp
liberliver has joined #lisp
Jesin has joined #lisp
orivej has joined #lisp
<mrcom> Josh_2: So I see! Forwarning--I've never been able to write DIY locking code that worked the first time, even after I was sure I debugged everything.
<mrcom> Josh_2: ...and I see a bug in BEGIN-WRITE. You're calling CONDITION-NOTIFY in the loop instead of CONDITION-WAIT.
<mrcom> Josh_2: Also, in END-READ you should consider calling (ASSERT (PLUSP RA)) instead of (UNLESS (ZEROP RA) ...)
<mrcom> It might seem more forgiving to not do anything if it's already zero, but that case should never happen.
v3ga has quit [Ping timeout: 272 seconds]
gaqwas has quit [Remote host closed the connection]
<mrcom> Bitter, bitter experience has taught me that it's better to detect threading errors as early as possible. If RA is ever zero at that point then something's gone wrong.
mindCrime has quit [Ping timeout: 260 seconds]
enrio has joined #lisp
<mrcom> Josh_2: Also, in WRITE-WITH-RW-LOCK the second call is to END-READ instead of END-WRITE.
TwoNotes has joined #lisp
puchacz has quit [Remote host closed the connection]
<mrcom> Josh_2: Oh, wait. I was thinking HANDLER-BIND. You don't to execute END-READ or END-WRITE twice, which UNWIND-PROTECT will do it everything is OK.
<mrcom> Also, in READ-/WRITE-WITH-RW-LOCK, if the BEGIN-READ or BEGIN-WRITE themselves fail you're going to have a mess.
<mrcom> (For example, if you hit Control-C right in the middle of the BEGIN-READ/-WRITE.)
Inline has joined #lisp
akoana has joined #lisp
<Josh_2> mrcom: I copied the implementation from the wiki pseudocode
<Josh_2> I added unwind protect because I initially had a bug where I was checking the wrong var (pretty typical) and it was stalling, if I C-c'd it the whole thing would break
<mrcom> Suggestion: Something like (let ((locked nil)) (unwind-protect (unwind-protect (begin-write ,lock) (setf locked t)) (if locked (progn ,@body)) (if locked (end-read/-write))
<mrcom> And when you added the unwind-protect it looked like everything was OK because you also had the (unless (zerop ra)).
<Josh_2> well I had to add that as well
<Josh_2> trial and error xD
<mrcom> Yeah, like I was I've never gotten this stuff to work first try. Or second. Or third :)
<Josh_2> Well It's all part of the fun!
<mrcom> The way it is now, every read will increment once and decrement twice.
<Josh_2> The suggestion you made is for the read/write macro?
<phoe> are there unit tests for it?
<mrcom> Yeah. You need some kind of indicator that the lock actually happened.
<mrcom> ... And I messed it up.
<Josh_2> mrcom: oh no
<mrcom> Should be (let ((locked nil)) (unwind-protect (progn (begin-write ,lock) (setf locked t)) (if locked (progn ,@body)) (if locked (end-read-/-write)))
<mrcom> ... And I messed it up again. There should be a PROG1 around the two (IF LOCKED ...) expressions, so that you return the value of the body.
<mrcom> ... but that will mean the END- doesn't execute if the body failes.
jw4 has quit [Read error: Connection reset by peer]
<Josh_2> mrcom: like this https://plaster.tymoon.eu/view/2008#2008 ?
<Josh_2> I already added the prog1
<Josh_2> I also made that mistake earlier :P
<mrcom> No, the LOCALLY doesn't do anything.
jw4 has joined #lisp
<Josh_2> What do you mean?
rogersm has quit [Quit: Leaving...]
<phoe> LOCALLY is likely there to allow declarations
<Josh_2> yeh
<mrcom> (LOCALLY () ...) is the same as (LET () ...), except that if the LOCALLY is a top-level form so are the sub-forms.
<phoe> yes
<mrcom> s/(LOCALLY () ...)/(LOCALLY ...)
<phoe> but it's more common to see (LOCALLY ...) than (LET () ...)
<phoe> PROGN is for when your body forms do not accept declarations; LOCALLY, for when they do
<phoe> at least that is what I was taught
liberliver has quit [Ping timeout: 240 seconds]
<mrcom> Anyway, what you want is that the PROG1 should instead be UNWIND-PROTECT (again).
<mrcom> That way the body (or its error) is returned, and you still call the unlock.
cantstanya has quit [Remote host closed the connection]
liberliver has joined #lisp
<mrcom> Sigh. Still not right. The first UNWIND-PROTECT will return the value of the SETF, or an error if BEGIN-READ/-WRITE failed.
cantstanya has joined #lisp
<flip214> pve: I need to modify that value during runtime... how would l-t-v help here?
<Josh_2> mrcom: yes I noticed that one as well :P
<Josh_2> (when it didn't work)
<Josh_2> although in that linked version the first unwind protect doesn't have a cleanup
<Josh_2> *sigh*
satousan has joined #lisp
Oladon has quit [Ping timeout: 246 seconds]
<mrcom> Nope, double-unlock again.
<Josh_2> hnng
Oladon has joined #lisp
<Josh_2> can't I only have 1 unwind protect? that will catch a C-c and then there will be only 1 unlock
MichaelRaskin has quit [Ping timeout: 240 seconds]
<Josh_2> probably gone full circle now
<Bike> begin-write and end-write lock and unlock respectively?
<Bike> why have the "locked" variable at all?
<Bike> (unwind-protect (progn (begin-write ,lock) (locally ,@body)) (end-write ,lock)) seems fine to me
<Bike> though you might wanna once-only lock
<Josh_2> because we don't want to call 'end-write' if it never locked?
<Bike> wait, so begin-write is like, a try lock? it doesn't wait until it can grab the lock?
gaqwas has joined #lisp
<mrcom> Async failure, such as C-C
<flip214> Bike: I guess it can fail (timeout, interrupt)
<Bike> but if you fail at grabbing the lock you probably shouldn't actually execute the critical section
<flip214> Josh_2: then make the inner (if ,locked (end-write ...)) a (when ,locked (end-write ) (setf locked nil))
<Bike> since something else could then execute it concurrently
<flip214> and merge the two (if ,locked)
<phoe> (let ((lock-grabbed-p nil)) (unwind-protect (progn (setf lock-grabbed-p (try-grab-lock)) (when lock-grabbed-p ...)) (when lock-grabbed-p (release-lock))))
<mrcom> Trying to post to plaster--what's "aeomwse" unscrambled?
<Josh_2> awesome
<phoe> or make an account there and get rid of prompts
<flip214> Josh_2: I annotated your paste
<mrcom> flip214: Yeah, that, only the first (when ,locked) isn't needed.
<mrcom> and it needs a prog1
<flip214> I updated it
<flip214> ah yeah, the return value might be interesting
<mrcom> Or error if it dies.
<Josh_2> okay very cool mrcom flip214 :D
<Josh_2> thanks!
<flip214> not sure if end-write would return a useful value... can that fail as well? If yes, then my code would try to unlock a second time
<mrcom> Riddle--how many programmers does it take to write lock primitives.
<mrcom> Answer--N+1
<Josh_2> mrcom seems so xD
<flip214> mrcom: the primitives are hard - by definition. as soon as there's a high-level interface, there's not so much that can go wrong
<mrcom> It's not quite up there with writing your own crypto, but it's definitely "just don't" if at all possible.
<mrcom> (In production, that is.)
<Josh_2> perhaps that is better :D
<Alfr__> It's still bogus: What happens when it's interrupted after (begin-write ,lock) but before (setf ,locked t)?... Look at the (when ...) at the bottom.
<Josh_2> oh geez
<Josh_2> xD
satousan has quit [Quit: WeeChat 2.3]
TwoNotes has quit [Quit: Leaving]
gaqwas has quit [Remote host closed the connection]
<Alfr__> Josh_2, if your begin write is blocking, then Bike's variant is fine. (I think.)
<mrcom> And we've got the same problem with the lock.
<mrcom> Alfr__: No, if the body flakes out then the unlock is never called.
FreeBirdLjj has joined #lisp
<mrcom> Sorry, other way around. If the lock flakes then the unlock will happen anyway.
<Bike> in mine? if the body is interrupted the unlock is in the unwind-protect
<Alfr__> mrcom, it is, there's a unwind protect ensuring the (end-write ..).
<Bike> (progn (begin-write lock) (unwind-protect (locally ,@body) (end-write lock)))
<Josh_2> Thats what I had at first Bike
<Bike> so what's the problem with it
<Alfr__> mrcom, but that begin-write better be uninterruptible otherwise (end-write ..) may be called without owning the lock.
<Bike> if begin-write is aborted there's no unlock. if the body is aborted there's an unlock. if the body returns normally there's an unllock.
<mrcom> Yeah, that's what he wants.
<mrcom> We were stuck trying to put unwind-protect around the lock.
FreeBirdLjj has quit [Ping timeout: 260 seconds]
<mrcom> Although...
<Alfr__> Bike, is there a guarantee that should begin-write return, the unwind-protect is in effect?
<mrcom> It's possible to get interruped between the (begin-write) and the (progn)
<mrcom> Er, between the begin-write and the unwind-protect
<mrcom> Alfr__: yeah, what you said
galex-713 has quit [Ping timeout: 272 seconds]
<markasoftware> I am writing a macro that takes a place as an argument. The place will be expanded multiple times. How can I avoid issues if the place passed in has side effects, for example, `(nth (incf i) foo)`?
<markasoftware> eg, alexandria:once-only but for places
<Alfr__> Bike, the that uninterruptible part war for that earlier version of yours, where you had (unwind-protect (progn ...; no the other way around.
galex-713 has joined #lisp
<Bike> the way unwind-protect is usually written there's no actual time for an interrupt, and anyway, if you're worried about that there's no possible way to fix the problem since there's always some space after grabbing the lock
<Bike> @markasoftware use the setf expansion
<Alfr__> Bike, good to know. :)
<phoe> that's how I implemented mod-{incf,decf} based on SICL code
<mrcom> Bike: "no actual time for an interrupt"--no such thing.
<Alfr__> I was pondering whether a way out would be for each thread to cas it's unique id (> 0) onto some place in lock. Then whether one holds a lock could be determined later on.
<mrcom> "Only once in a billion iterations", yeah.
<markasoftware> defsetf wouldn't have worked there?
<mrcom> If we only had to worry about a discrete return value, as C or C++ do, then you can just take the value and return it afterward.
<mrcom> However, Lisp is a lot richer environment. We've got to worry about conditions and closures.
<phoe> we don't need to worry about conditions since they are fully synchronous
rogersm has joined #lisp
<phoe> and if they perform non-local exits then all such exits are caught by UNWIND-PROTECT
<mrcom> What I mean is we can't (unwind-protect (lock) (setf save-val (progn @,body)) (unlock) (return save-val))
krid` has joined #lisp
<mrcom> (Roughly)
<Bike> sure you can, with multiple-value-list
<Bike> though it's not efficient
<Bike> and it's pointless anyway, since you can just use unwind-protect normally
<phoe> wait a second, why is (lock) the only protected form
terpri_ has joined #lisp
<Bike> also even in C++ you'd use RAII, which ends up looking kind of like unwind-protect
krid` has quit [Remote host closed the connection]
<Bike> { lock_raii_thing foo; ...critical section... return whatever; ... } bam
krid` has joined #lisp
<Bike> the real right thing to do here is probably to use the implementation's underlying with-lock-held, if your read write locks are implemented on top of the implementation locks
krid` is now known as krid
Inline has quit [Ping timeout: 265 seconds]
terpri has quit [Ping timeout: 260 seconds]
<Josh_2> It's built with bt
<Bike> you can have begin-write take care of its own abort behavior
<Bike> so that it only unlocks the write lock if it actually locked it
<Alfr__> Josh_2, bt has a with-lock-held macro!
<Josh_2> yes
<Josh_2> I'm using "with-lock-held"
<mrcom> The body has to be executed within the with-lock-held.
<phoe> my naïve approach for that would be (defmethod c2mop:slot-value-using-class (class object (slotd locked-slotd)) (bt:with-lock-held ((lock slotd)) (call-next-method)))
<Bike> with the rwlock implementation i know you're not holding an actual lock during the write-locked section
<phoe> but that's so simple that I'm sure I got it terribly wrong
<Josh_2> Bike: I am
<mrcom> You can't, at a high-level, split it up into BEGIN-READ/-WRITE and END-READ/-WRITE.
gaqwas has joined #lisp
gaqwas has quit [Changing host]
gaqwas has joined #lisp
<Bike> but you can though? to begin-write you grab the internal lock, increment a variable, do some condition waiting, decrement the variable, set another variable, then unlock the internal lock
galex-713 has quit [Ping timeout: 264 seconds]
galex-713_ has joined #lisp
<Josh_2> Yes sorry I misunderstood what you wrote
<Bike> and if you're using the reader-preferring implementation all you need to do to grab the write lock is grab an actual lock, which you can use the system with-lock-held for
<Josh_2> When actually executing ,@body no lock is held
<mrcom> The problem is that you need to atomically set-calc-unset
<Bike> running the end-write procedure partway through the begin-write procedure seems fine to me
<Bike> all it does is set a variable to what it would be anyway, and condition notify
<Josh_2> hmm so I can (unwind-protect the body of begin-write and have end-write as the cleanup?
<Bike> if you have begin-write clean up after itself appropriately, maybe
<pve> flip214: I didn't understand that you need to modify it, so no load-time-value then
luckless_ has joined #lisp
space_otter has joined #lisp
luckless has quit [Ping timeout: 240 seconds]
CrazyEddy has quit [Ping timeout: 265 seconds]
<mrcom> The fundemental problem is that Lisp doesn't really have a concept of critical sections.
<phoe> that's implementation-defined, SB-SYS:WITHOUT-INTERRUPTS and such
<mrcom> Yeah.
<Josh_2> hmm
<Josh_2> is there a compatibility library for that?
<mrcom> BT :)
<Josh_2> xD
duuqnd has quit [Remote host closed the connection]
rogersm has quit [Quit: Leaving...]
<Josh_2> hmm well ccl has the exact same 'without-interrupts' function
<Josh_2> perhaps I could make a portability library
<phoe> sounds like an idea, given that these macros/functions implement the same semantics
CrazyEddy has joined #lisp
bsd4me has joined #lisp
exodus has joined #lisp
<exodus> Howdy, folks. Trying out curry/compose reader macros from here https://github.com/eschulte/curry-compose-reader-macros
<Xach> fun!
<exodus> I eval the four lines as the instructions says, but the rcurry errors out with _ is unbound
<exodus> Xach: yeah!
<exodus> The other two examples work though. What am I doing wrong here?
heisig has quit [Ping timeout: 240 seconds]
<exodus> In fact, all of the examples work except the ones using the underscore.
shifty has joined #lisp
<Xach> exodus: you must also use-package curry-compose-reader-macros or import _ explicitly from that package
<Xach> _ refers specifically to curry-compose-reader-macros:_ and not any other symbol
z3t0 has quit [Ping timeout: 260 seconds]
<Xach> the example would benefit from more clarity in that regard
<exodus> Xach: oh, I see, yeah, it works after use-packaging that!
contrapunctus has left #lisp [#lisp]
<Xach> exodus: so, (import 'curry-compose-reader-macros:_) would be one option
<markasoftware> phoe: what was wrong with `define-modify-macro` for `mod-incf`?
<Xach> there you go
<exodus> Thank you!
<Xach> no problem!
<phoe> markasoftware: wrong?
<markasoftware> as in, why did you not use it instead of the more complicated macro involving get-setf-expander?
<markasoftware> *expansion
<phoe> hmmmmm
<phoe> can I express MOD-INCF this way though?
* phoe thinks
<markasoftware> you might need a closure to capture the modulus
<phoe> no no, the modulus is meant to be supplied on each call to MOD-INCF
shifty has quit [Ping timeout: 246 seconds]
shifty has joined #lisp
<markasoftware> define-modify-macro does let you pass extra arguments
ech has joined #lisp
<Bike> (defun mod-add (n divisor delta) (mod (+ n delta) divisor)) (define-modify-macro mod-incf (divisor &optional delta) mod-add) would be fine, i think?
<phoe> &optional (delta 1)
<phoe> but otherwise, hmmmm, I think so
<markasoftware> yeah, I'm inclined to believe that works
gaqwas has quit [Remote host closed the connection]
<markasoftware> as for why SICL wouldn't use define-modify-macro for incf, who knows? looks like sbcl doesn't either. Maybe performance?
ralt has quit [Quit: Connection closed for inactivity]
<Bike> it shouldn't have any impact on performance.
<markasoftware> actually, the SBCL source code says "DEFINE-MODIFY-MACRO could be used, but this expands more compactly."
<Bike> yeah, define-modify-macros do some junk to avoid multiple evaluation
<Bike> and it gets weird with the lambda list
<markasoftware> i see
<markasoftware> very interesting, all the setf stuff...never really understood it before today.
<phoe> beach: when you wake up, could you comment on that? I'm actually interested
<Bike> sicl's implementation only seems to bind one of the variables of the setf expansion, not sure what's goin on there
<phoe> there's no more variables in INCF or DECF though
<phoe> I mean, (incf x 1 2) is an error
<phoe> (incf x) is the case with zero variables, (incf x 42) - with one variable
<phoe> so it's either zero or one variables.
<Bike> oh, wait, yeah. i was thinking of the temps
exodus has quit [Remote host closed the connection]
yitzi has quit [Read error: Connection reset by peer]
<mrcom> Josh_2: OK, I think this is really it... https://plaster.tymoon.eu/view/2011#2014
<mrcom> (READ-WITH-RW-LOCK is left as an exercise for the reader :)
ggole has quit [Quit: Leaving]
<mrcom> Josh_2: The key things is that incrementing writer-wait, calling the body, and decrementing are all one atomic operation, with a window while it's spinning waiting for readers to clear.
minerjoe has quit [Ping timeout: 246 seconds]
<Josh_2> mrcom: Oh my
<Josh_2> phoe: did I miss anything with this? https://github.com/K1D77A/without-interrupts
enrio has quit [Ping timeout: 265 seconds]
<Josh_2> from what I saw abcl doesn't have an equivalent
<phoe> I don't know if I can review that since it's late and I haven't had much experience with that part of the Lisp ecosystem
<Josh_2> Okay no worries :)
satousan has joined #lisp
<Josh_2> mrcom: why are you using multiple-value-list?
<mrcom> What if BODY ends with (VALUES a b c)?
<Josh_2> yes
<Josh_2> if I use 'without-interrupts' this can be much simpler?
<mrcom> I don't think so. It's really no more complicated than what you had; the BEGIN- and END- functions are just inlined.
<Josh_2> yes I see that
<mrcom> And it doesn't need WITHOUT-INTERRUPTS, so will work with Lisps that lack the equivalent (ABCL? ECL?)
<Josh_2> only ABCL from what I saw
<mrcom> Even with WO-IRPTS you'll need to save the return value of the body.
<mrcom> (I think.)
<Josh_2> in the example you sent the cleanup form of the first unwind-protect is the other unwind-protect
<mrcom> And WO-IRPTS means no C-C.
Bike has quit [Remote host closed the connection]
<Josh_2> yes, that's what we are trying to stop with all the unwind-protects though right?
<Josh_2> well, we are trying to make them safe
<mrcom> It's not really a clean-up, and the values of the U-Ps aren't being used.
<mrcom> It's just a way of saying that all four things always have to execute, even if there's an abort somewhere.
<mrcom> (There could be another U-P around the DECF and the CONDITION-NOTIFY, but if the DECF doesn't work there's no point in notifying.)
<mrcom> Another issue with splitting into BEGIN- and END- is lock starvation.
<Josh_2> I don't know how to the write the read version
<Josh_2> also
<mrcom> The active writer can't release the RW lock until it grabs the G lock. If there are a lot of readers this could take a while.
<mrcom> Try following the same idea. Everything that's critical for the reader is under the one lock.
<Josh_2> I don't need to use (multiple-value-list ..) in this instance as write-with-rw-lock isn't exported from the package
<mrcom> OK.
terpri__ has joined #lisp
<mrcom> Anyway, for the reader, instead of (with-lock (increment)) (read) (with-lock (decrement)), you want (with-lock (increment) (read) (decrement))
<Josh_2> so basically just skipping the second lock grab and instead just performing the read in the middle
<mrcom> Yep. In both cases, the only reason even to do the incr/decr is for the benefit of the while-loop "window".
terpri_ has quit [Ping timeout: 260 seconds]
terpri__ has quit [Remote host closed the connection]
<mrcom> You won't have, technically, the "multiple simultaneous readers" aspect of RW locks.
terpri__ has joined #lisp
<Josh_2> mrcom: something like this? https://plaster.tymoon.eu/view/2015#2015
<Josh_2> but isn't multiple simultaneous readers a good thing?
<mrcom> Not in your case. All you're doing is a slot reference. That's so fast that it's utterly swamped by the lock/unlock.
<Josh_2> okay, so it basically doesn't matter
<mrcom> What you'll have is the "writers get priority" aspect.
<Josh_2> hmm
<mrcom> Yeah, in this case you'd probably actually get better performance without the condition variables.
<mrcom> Looks good, except you really don't want the "(unless (zerop ra) (decf ra))". You *always* want to decrement.
<mrcom> You no longer have the double-decrement problem, which is what you were fixing with the "unless ...".
<Josh_2> yep
<Josh_2> that was a holdover
<mrcom> You can tweak the code to get true simultaneous-readers, but remember that you're locking one slot on one instance. How frequently are you going to have two threads looking at the same thing at the same moment?
<Josh_2> who knows
<Josh_2> I don't
<Josh_2> pretty rare I imagine :P
<mrcom> The tweak would actually take more time than just waiting for the first reader to unlock.
bsd4me has left #lisp ["Leaving"]
<mrcom> Yeah, so it's up to what you want to learn out of it.
<Josh_2> yes I would like to learn
gravicappa has quit [Ping timeout: 264 seconds]
<Josh_2> Do you have any links to things I can read?
whiteline has quit [Ping timeout: 240 seconds]
rilez has joined #lisp
satousan has quit [Quit: WeeChat 2.3]
jesse1010 has joined #lisp
mangoicedtea has joined #lisp
dilated_dinosaur has joined #lisp
Josh_2` has joined #lisp
Josh_2` has quit [Client Quit]
Josh_2 has quit [Ping timeout: 240 seconds]
mindCrime has joined #lisp
space_otter has quit [Remote host closed the connection]
asarch has joined #lisp
<mrcom> Josh_2: Wow, I can't find anything Lisp-specific.
<mrcom> minion: memo for josh_2: Here's a nice discussion of RW locks, although for Go. https://eli.thegreenplace.net/2019/implementing-reader-writer-locks/
<minion> Remembered. I'll tell josh_2 when he/she/it next speaks.
asarch has quit [Quit: Leaving]
yitzi has joined #lisp
jesse1010 has quit [Remote host closed the connection]
pve has quit [Quit: leaving]
cjb has joined #lisp
random-nick has quit [Ping timeout: 240 seconds]
lucasb has quit [Quit: Connection closed for inactivity]
shifty has quit [Ping timeout: 246 seconds]
C-16 has quit [Ping timeout: 240 seconds]
orivej has quit [Ping timeout: 256 seconds]
Brentward has joined #lisp
C-16 has joined #lisp
space_otter has joined #lisp
mangoicedtea has quit [Ping timeout: 260 seconds]