attila_lendvai has quit [Ping timeout: 256 seconds]
scymtym has joined #commonlisp
<jasom>
pdietz: could use count-if #'identity then
<pdietz>
Or (count nil (mapcar #'>= list (cdddr list)))
s-liao has quit [Ping timeout: 256 seconds]
<dre>
<Guest74> I still think my favourite for part 2 is (COUNT T (MAPCAR #'< list (CDDDR list)))
<dre>
that is very nice
<dre>
and if only I had thought of it
ad-absurdum has quit [Ping timeout: 252 seconds]
Oladon has joined #commonlisp
mariari has quit [Quit: WeeChat 3.3]
mariari has joined #commonlisp
mariari has quit [Remote host closed the connection]
asen has joined #commonlisp
asen has quit [Remote host closed the connection]
asen has joined #commonlisp
jealousmonk has joined #commonlisp
akoana has joined #commonlisp
ad-absurdum has joined #commonlisp
Oladon has quit [Quit: Leaving.]
Fare has joined #commonlisp
ad-absurdum has quit [Ping timeout: 256 seconds]
ad-absurdum has joined #commonlisp
ad-absurdum has quit [Client Quit]
s-liao has joined #commonlisp
unyu has quit [Quit: WeeChat 3.3]
taiju has quit [Remote host closed the connection]
taiju has joined #commonlisp
xantoz has quit [Ping timeout: 252 seconds]
prxq has quit [Ping timeout: 252 seconds]
prxq has joined #commonlisp
paule32_ has joined #commonlisp
xantoz has joined #commonlisp
paule32__ has joined #commonlisp
paule32 has quit [Ping timeout: 265 seconds]
paule32_ has quit [Ping timeout: 256 seconds]
paule32 has joined #commonlisp
paule32__ has quit [Ping timeout: 252 seconds]
pranavats has left #commonlisp [Error from remote client]
aartaka has joined #commonlisp
Bike has quit [Quit: Lost terminal]
kingofcsu has joined #commonlisp
kingofcsu has quit [Client Quit]
kingofcsu has joined #commonlisp
taiju has quit [Ping timeout: 252 seconds]
kingofcsu has quit [Quit: Leaving]
<beach>
Good morning everyone!
<beach>
mzan: There is no reason to have a newline after LET*. And in Common Lisp, we don't have closing parentheses preceded by whitespace (and that includes newlines). Plus, there is no particular reason to have blank lines in the middle of top-level forms.
<beach>
mzan: And (lambda (ss) (series:collect-sum ss)) can be more simply expressed as #'series:collect-sum.
<beach>
mzan: Similar with series:collect.
<beach>
mzan: And your indentation is off. Lines after (->>ss3 ought to be indented.
Guest74 has joined #commonlisp
<beach>
mzan: And (lambda (x) nil) can be expressed as (constantly nil).
azimut_ has quit [Remote host closed the connection]
azimut has joined #commonlisp
<beach>
jackdaniel: I am not sure from your demo what the improvement is compared to what things were before. Any hints?
<Guest74>
pdietz: what are some of the possible return values implementations might choose?
taiju has joined #commonlisp
<beach>
Guest74: Anything other than NIL to represent true.
<Guest74>
yeah, just read that, generalized boolean.
<beach>
(< 2 3) => "Why, of coure" is perfectly conforming.
<beach>
*course!
<aeth>
clearly you want NIL and (NOT NIL)
<Guest74>
not nil doesn't work with count
<Guest74>
what's that reversing function?
<beach>
:test-not?
<Guest74>
what item would you supply with test not? another page to read.
<Guest74>
but asking about the function that returns the complement of a fucntion? probably complement?
<beach>
I haven't had my coffee yet, but perhaps (count nil ... :test-not #'identity) or (count nil ... :test #'not)
<Guest74>
or i guess use count-if
<beach>
Many possible solutions.
s-liao has quit [Quit: Client closed]
pdietz has quit [Quit: Client closed]
<Guest74>
oh, test-not takes two args.
<beach>
Maybe I meant :key.
<beach>
Like I said, coffee not consumed yet.
semz has quit [Ping timeout: 252 seconds]
<Guest74>
count nil :key #'null works
<beach>
Right.
<Guest74>
it's an interesting use.
pdietz has joined #commonlisp
lisp123 has joined #commonlisp
<Guest74>
I guess it probably wouldn't be good style to use it since :key sort of implies an accessor?
karlosz has joined #commonlisp
lisp123 has quit [Ping timeout: 252 seconds]
<hayley>
The :key and :test arguments are pretty open to interpretation to me. I recall mentioning some form in #commonlisp a while ago, something like (find 'integer '(fixnum real string) :test #'subtypep).
<hayley>
Worse, the :test doesn't have to be an equivalence relation. For example, (complement #'=) or #'/= is not an equivalence relation, but using either for :test is preferred over using the deprecated :test-not.
semz has joined #commonlisp
<Guest74>
well, I will happily abuse this if the opportunity presents itself. I notice clhs doesn't mention anything besides it being a designator for a function.
Oladon has joined #commonlisp
pdietz has quit [Ping timeout: 256 seconds]
<beach>
hayley: Nobody cares about the deprecated features it seems.
<hayley>
Oh well, they'll be in trouble when we get a new standard, and I won't.
<Guest74>
I love me some remove-if-not
s-liao has joined #commonlisp
jealousmonk has quit [Quit: ERC (IRC client for Emacs 27.1)]
akoana has quit [Quit: leaving]
<Guest74>
i think it communicates more what you want.
<semz>
I definitely find it more natural to enforce a predicate than to describe what I want removed.
<semz>
Do remove-if and remove-if-not predate the "filter" terminology that's more common nowadays?
<hayley>
I'm not sure, but "filter" is vague as to what is kept.
<hayley>
The Standard ML function List.partition partitions into two lists instead, which seems nicer.
pranavats has joined #commonlisp
karlosz has quit [Quit: karlosz]
<beach>
I agree with hayley that FILTER is ambiguous. Plus, in Common Lisp there is the distinction between REMOVE and DELETE which is made explicit this way.
<beach>
When appropriate, I just think of REMOVE-IF-NOT as KEEP-IF.
s-liao has quit [Ping timeout: 256 seconds]
tyson2 has quit [Remote host closed the connection]
<Guest74>
damn, i don't even know how these people type this fast to submit so fast.
<hayley>
Competitive programming is a thing, unfortunately.
<hayley>
...notably, the competitions where people churn out code as quickly as possible. Not all competitions are based on programming speed.
<Guest74>
are there elegant competitions?
<hayley>
Quite likely, but I don't know how you judge that.
<dre>
ok
azimut has quit [Remote host closed the connection]
<dre>
so how do we use (split-sequence #\space "this is a string") in sbcl?
azimut has joined #commonlisp
<Guest74>
just like that. maybe split-sequence:split-sequence
<Guest74>
you have to have the system loaded (ql:quickload "split-sequence")
<dre>
^ that's what i was missing, thanks
<hayley>
Make sure you have loaded the split-sequence system, and then (split-sequence:split-sequence #\space "this is a string")
<dre>
I also have found (ql:quickload :cl-ppcre)
<dre>
which might be a nicer lib?
<Guest74>
if you understand regex
<hayley>
I'd usually say something right about now, but I don't have functions that replace and split strings.
<hayley>
But, yes, CL-PPCRE performs operations on regular expressions, and not just strings, so e.g. splitting on "|" might go sideways quickly.
<hayley>
I recall my first university assignment involved parsing "database" files which were | delimited, just to throw people off using .split() in Java, which takes a regular expression.
<dre>
ok I don't get it
<dre>
I've loaded up ppcre with ql, but when i try to run anything I get undefined function
lisp123 has joined #commonlisp
<hayley>
Amusingly, I was just about to ask something about regexen implementation: somehow an article I wrote on my regular expression compiler got big on Reddit and Hacker News. Someone asked me how I would handle character classes like \w or [:alpha:]. I suspect generating a whole lot of <= for each range is a terrible way to match a character class comprised of many ranges.
<dre>
the very first code line on the ppcre documentation is "(parse-string "(ab)*")
<hayley>
Another approach would be to use a bitmap, but we'd need a lot of bits for every Unicode character. And the generated code is quite fast, so having a large table also would result in more cache misses and more of a slowdown, which would be unfortunate. Is there a clever way to "compress" a bitmap in a way that allows for random access to the bitmap?
<dre>
(ql:quickload :cl-ppcre) (parse-string "(ab)*") => undefined function
Jing_ has joined #commonlisp
<dre>
can someone explain ?
<dre>
has it got to be in the form?
<hayley>
dre: I assume the documentation assumes you have used the package, but that is not a good idea, so you need to include the name of the CL-PPCRE package. Try (cl-ppcre:parse-string "(ab)*")
kakuhen has quit [Remote host closed the connection]
Guest74 has quit [Ping timeout: 252 seconds]
Jing has quit [Ping timeout: 252 seconds]
azimut has quit [Ping timeout: 276 seconds]
<dre>
oh
<dre>
nice thanks that worked
<dre>
so what's the workaround? how can I be "using cl-ppcre" in that sense?
kakuhen has joined #commonlisp
<dre>
although I don't mind prefixing everything with the package that it comes from...
<beach>
dre: Workaround?
Guest74 has joined #commonlisp
azimut has joined #commonlisp
<hayley>
Prefixing everything with the package is usually easier on the person reading your code, so I would just do that.
<beach>
dre: If CL-PPCRE is to long, use a package-local nickname.
<dre>
the workaround is to work harder, I get it :)
<hayley>
Not by much. And it's better if your editor can complete names, so (cl-p <tab> p-str <tab> "(ab)*") might suffice.
kakuhen has quit [Client Quit]
* hayley
forgot the : after completing cl-ppcre, but hopefully dre gets the idea.
s-liao has joined #commonlisp
<hayley>
Here is a hackish implementation of a "page table" which avoids requiring parts of the bitmap that are entirely 0 or 1 to exist in memory <https://plaster.tymoon.eu/view/2740#2740>, but I would guess testing for the sentinel values could confuse branch prediction.
<hayley>
Hm, I could hash cons instead, and there would only be one fully 0 page, and one fully 1 page.
<dre>
another newb question
<dre>
if I write a function, call it, and it fails, getting me into the debugger,
<dre>
if I then redefine the function ( correcting the mistake), and then "Ctrl-D" to get out of the debugger...
<dre>
do i have the new corrected function, or the old crappy function defined ?
<beach>
If you evaluate the DEFUN form again, you have the new version.
karlosz has joined #commonlisp
<beach>
dre: Are you using SLIME?
<dre>
but I'm evaluating the defun in the debugger, then leaving the debugger, so I have the old version right?
<dre>
no, SBCL / vim
<dre>
sorry ;_;
<dre>
I'm so naughty ;;_;
<beach>
SBCL has only one global environment, so if you evaluate the DEFUN form in that environment, the old function will be replaced.
<beach>
dre: Not "naughty", but you are depriving yourself of some reasonably good tools.
<hayley>
There is SLIMV for vim, though I have heard mixed things about it. Granted, I have also heard mixed things about SLIME too.
<dre>
I use "vim-slime" which, very basically, will send the paragraph I'm on to *another-terminal* with a <c-c><c-c>
<dre>
which actually works suprisingly well.
<dre>
but I don't get introspection like I do with emacs.
<Nilby>
or you could be like me and not use SLIME/SLIMV/SLY anything, and even more naughty, use :use/use-package
<dre>
I know it's begging for macros, I'll figure that out soon.
<Guest74>
SECOND might be more readable than CADR
<hayley>
It might be better to use DESTRUCTURING-BIND too. e.g. (destructuring-bind (action distance-string) (cl-ppcre:split " " item) ...)
<Guest74>
or that. I really need to go to bed.
Guest74 has quit [Ping timeout: 256 seconds]
lisp123 has quit [Remote host closed the connection]
abrahms has joined #commonlisp
<abrahms>
Hey commonlisp folks. I'm trying to figure out how to call a function if I have the string representing it's name. (funcall (intern "func-name-here") 1) doesn't seem to work.
<hayley>
Try with an uppercase name.
<hayley>
The reader upcases symbol names by default, so you probably need to upcase the name yourself.
<abrahms>
I'm so grumpy that works. :)
<abrahms>
Thanks so much!
<_death>
probably want FIND-SYMBOL instead
<abrahms>
_death: find-symbol can't find the function if it's lowercase, sadly.
<Alfr>
abrahms, no but it won't intern a new symbol into package if func-name-here is misspelled.
<_death>
another alternative is a hash-table mapping strings to functions
<Alfr>
_death, with an equalp hash table for case insensitiveness?
<_death>
perhaps
<Alfr>
_death, that's the first time I actually consider equalp to be of any use.
<beach>
jackdaniel: Ah, so you are saying you fixed that bug?
<_death>
often when I want to have such dispatch equal is more appropriate.. but I do use equalp sometimes, either for such case-insensitiveness or for non-string array equality
<beach>
jackdaniel: Great!
s-liao has quit [Quit: Client closed]
s-liao has joined #commonlisp
waleee has quit [Ping timeout: 252 seconds]
pdietz has joined #commonlisp
<jackdaniel>
beach: well, the spec is quiet about what does it mean to propagate changes, so not strictly a bug
<beach>
Ah, yes, I see.
<beach>
So was the behavior different before when incremental redisplay was in use, compared to when it was not?
<beach>
I guess I was puzzled by the mention of incremental redisplay.
<jackdaniel>
I've fixed a few bugs too, but table readjust is new
<jackdaniel>
I've been fixing issues for situation when some record was redisplayed that was not top level
<beach>
I see.
<beach>
Every day, there are fewer reasons to choose an FFI-based solution to Common Lisp GUI applications. :)
<hayley>
You might want to use (incf aim blah) rather than (setf aim (+ aim blah)) too.
<dre>
but I get an error during macroexpansion of setf
<dre>
is it the string?
<dre>
thanks for incf
<hayley>
You didn't provide a variable name to set in the SETF forms that comprise the body of the last WHEN form.
<dre>
OH
<dre>
right
<dre>
neat thanks
<dre>
changing to incf will solve that anyway :P
<dre>
thanks, this is superb
Cymew has joined #commonlisp
dre has quit [Remote host closed the connection]
<abrahms>
Is there a utility function that amounts to "Given <list>, replace the 4th element with <thing> and return it to me"? I've looked and I can't quite find one. rplacd is as close as I've come and it's a bit wonky of an API
<lisp123>
does (setf (nth 3 *list*) 50) work?
nature has joined #commonlisp
makomo has quit [Ping timeout: 256 seconds]
varjag has joined #commonlisp
<abrahms>
Close. It returns `50`. I tried playing around with setf in the repl, but it was very angry about replacing constant data.
<lisp123>
If you don't want to change the original list, but rather return a new one
Algernon666 has joined #commonlisp
frgo has quit [Ping timeout: 252 seconds]
Algernon91 has quit [Ping timeout: 252 seconds]
shka has joined #commonlisp
amb007 has quit [Ping timeout: 256 seconds]
amb007 has joined #commonlisp
elderK has quit [Quit: Connection closed for inactivity]
treflip has joined #commonlisp
cosimone has joined #commonlisp
pjb has quit [Ping timeout: 268 seconds]
amb007 has quit [Ping timeout: 256 seconds]
amb007 has joined #commonlisp
lisp123 has quit [Remote host closed the connection]
asen has quit [Quit: Leaving]
aeth has quit [Ping timeout: 252 seconds]
lisp123 has joined #commonlisp
aeth has joined #commonlisp
aartaka has quit [Ping timeout: 256 seconds]
scymtym has quit [Ping timeout: 252 seconds]
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
pjb has joined #commonlisp
gaqwas has quit [Ping timeout: 256 seconds]
Jing_ has quit [Remote host closed the connection]
Jing has joined #commonlisp
s-liao has joined #commonlisp
scymtym has joined #commonlisp
varjag has quit [Ping timeout: 256 seconds]
<mzan>
beach: apart these "cosmetic" details, sadly: 1) the library series was not able to execute correctly the same code, but written in a slightly different way; 2) my code is not 100% stream-oriented, because it can not process a file of 30Mb. It is ok for 16Kb
etiago has quit [Ping timeout: 256 seconds]
attila_lendvai has joined #commonlisp
Lord_of_Life_ has joined #commonlisp
etiago has joined #commonlisp
Lord_of_Life has quit [Ping timeout: 256 seconds]
Lord_of_Life_ is now known as Lord_of_Life
<beach>
mzan: I did not study your code enough to understand what it does, nor the problem to understand what the code is supposed to do.
semz_ has joined #commonlisp
semz has quit [Ping timeout: 268 seconds]
treflip has quit [Remote host closed the connection]
lisp123 has quit [Remote host closed the connection]
waleee has joined #commonlisp
s-liao has quit [Ping timeout: 256 seconds]
cage has joined #commonlisp
s-liao has joined #commonlisp
treflip has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
s-liao has quit [Ping timeout: 256 seconds]
s-liao has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
heisig has joined #commonlisp
frgo has joined #commonlisp
tyson2 has joined #commonlisp
waleee has quit [Ping timeout: 252 seconds]
sbodin has joined #commonlisp
aartaka has joined #commonlisp
heisig has quit [Ping timeout: 252 seconds]
heisig has joined #commonlisp
ldb has joined #commonlisp
<ldb>
sup
<jcowan>
hayley: a classic hacque for Unicode char classes is to keep a sorted sequence of ranges as a vector. Contains is binary search, where the index mod 2 tells you if the char is in or out. Union and intersection are O(number of ranges), and complement is O(1)
<hayley>
Interesting. I'm not sure if O(log n) for contains would be okay, but I've set myself unreasonably high standards for scanning performance so far, honestly.
<jcowan>
if the range excludes NUL and O(n) otherwise.
random-nick has joined #commonlisp
<Xach>
abrahms: you want the old 4th element? or the list?
<Xach>
if the former, i love SHIFTF for that!
<hayley>
I already have such a sorted sequence to represent sets, but I don't want to give the branch predictor a hard time. I guess I can do a binary search of fixed length branch-free though.
<jcowan>
If truly fixed it will be large; if fixed up to a bound it's more feasible.
<jcowan>
consider the set of every other codepoint.
<hayley>
Sure. Then I would bail out to a bitmap.
<hayley>
...or perhaps my two level table idea, which would allow reusing the same #*0101... subvector for each group of characters.
<hayley>
From memory, ALPHANUMERICP had some 550 ranges or so, thus 10 iterations of binary search. Not sure if that is too many.
unyu has joined #commonlisp
lisp123 has joined #commonlisp
sbodin has quit [Quit: -a- IRC for Android 2.1.59]
heisig has quit [Quit: Leaving]
waleee has joined #commonlisp
<pdietz>
The distribution of inputs is likely highly nonuniform in practice, which would speed things up.
waleee has quit [Ping timeout: 252 seconds]
dmgk has left #commonlisp [#commonlisp]
etiago has quit [Ping timeout: 252 seconds]
ldb has quit [Ping timeout: 256 seconds]
<pjb>
hayley: perhaps not, when dealing with random unicode characters. it can be optimized for the iso-8859-1 case. But instead of using a binary search, perhaps one could have an indexed search. Are those ranges very non-uniformly distributed?
s-liao has quit [Quit: Client closed]
pve has joined #commonlisp
etiago has joined #commonlisp
lisp123 has quit [Remote host closed the connection]
CrashTestDummy2 has quit [Quit: Leaving]
treflip has quit [Remote host closed the connection]
treflip has joined #commonlisp
CrashTestDummy has joined #commonlisp
Algernon91 has joined #commonlisp
Algernon666 has quit [Ping timeout: 250 seconds]
Bike has joined #commonlisp
<mzan>
beach: about my assertion "my code is not 100% stream-oriented, because it can not process a file of 30Mb. It is ok for 16Kb"
<mzan>
it is probably wrong, because I noticed that there are ways for instructing series to optimize the code.
treflip has quit [Quit: ERC (IRC client for Emacs 27.2)]
phadthai has quit [Ping timeout: 260 seconds]
Cymew has quit [Ping timeout: 256 seconds]
Inline has quit [Ping timeout: 252 seconds]
ec_ has quit [Ping timeout: 276 seconds]
anticomputer_ has quit [Remote host closed the connection]
anticomputer has joined #commonlisp
scymtym has quit [Ping timeout: 252 seconds]
_73 has joined #commonlisp
abrahms has left #commonlisp [ERC (IRC client for Emacs 27.2)]
<_73>
In SBCL when I try to compile my file with a `defpackage` clause that has an `import-from #:alexandria ...` clause I get an error "The name ALEXANDRIA does not designate any package". If I go to the repl and `(ql:quickload "alexandria")` then recompile the file everything works fine. Should I ensure that my libraries are loaded by editing my `~/.sbclrc` file, or is their a different way to load my dependencies? I have made a `.asd`
<_73>
for my project that mentions my dependencies but I don't know how to tell SBCL about it.
<_73>
I am using sly in emacs.
<bremner>
isn't it enough to put it in the same directory as the file containing defpackage?
<Bike>
_73: packages are orthogonal to dependency resolution. to tell asdf about dependencies you should load your system via ASDF.
<bremner>
oh, duh, nvm me.
makomo has joined #commonlisp
<pjb>
_73: you should ensure that your dependencies are loaded, indeed, but better do it by writing an asd file rather than in you rc file.
<beach>
_73: In your ASDF system definition, put :depends-on (#:alexandria), then load your system with (asdf:load-system '#:<your-system-name>)
<White_Flame>
if you put a symlink to your project directory from ~/quicklisp/local-projects/, then you can (ql:quickload "your-system") as well
<beach>
Am I the only one who finds it strange when people who are given advice don't even acknowledge having seen it?
<White_Flame>
eh, I get into working on things and forget to check IRC, too
<beach>
Like "I don't understand", "OK, let me try that", "What do you mean 'package'?".
<Bike>
well, if they don't say anything else they could just be off to lunch for a bit or something
Inline has joined #commonlisp
Guest74 has joined #commonlisp
<beach>
White_Flame: Sure, if it takes more than a few minutes to get any reaction, but if the advice is given almost immediately, one would think they would stick around.
<pjb>
Well, the first answer was given 16 seconds after the last message.
<_73>
I have been here the entire time struggling through docs: When I try `(asdf:load-system :my-system)` I get an error `Component :MY-SYSTEM not found`. I understand from the docs that the problem is I do not have my code in a standard location like `~/common-lisp`. I am trying to modify the `asdf:*central-registry*` but can't seem to get it right.
<pjb>
I think people can wait 30 seconds for an answer on irc. The time to type it!
<beach>
But my question was answered. I seem to be the only one.
<White_Flame>
_73: you should just use the quicklisp portion of it, as it makes it easier
<White_Flame>
QL wraps ASDF's functionality and adds download and a standard path (~/quicklisp/local-projects/)
<pjb>
_73: modifying asdf:*central-registry* is one way. Another is to put it in i~/quicklisp/local-projects/ (symlinks don't work with all implementations) another is to set ql:*local-project-directories* (similar to asdf:*central-registry*)
<pjb>
_73: (push #P"/path/to/the/directory/where/you/put/your/asd/file/" #| <--note the final / |# asdf:*central-registry*)
<pjb>
_73: the asd file should have the same name as the system (it's possible to be different, but it's easier if it's the same, without the ".asd" of course.
* _73
goes to try this and will report back
<pjb>
beach: you're not the only one, but we can't do much about, so…
tyson2 has joined #commonlisp
<pjb>
let's rejoice that we don't have martians on irc yet…
phadthai has joined #commonlisp
Inline has quit [Ping timeout: 256 seconds]
Oladon has joined #commonlisp
scymtym has joined #commonlisp
tyson2 has quit [Ping timeout: 256 seconds]
<Bike>
_73: if your asd is in /home/seventythree/code/my-system/my-system.asd, you want (push "/home/seventythree/code/my-system/" asdf:*central-registry*)
<Bike>
_73: if you're using quicklisp, another possibility is to put a symlink to my-system/ in quicklisp/local-projects, and then make sure it's synced with (ql:register-local-projects)
<_73>
ohh I see. I was symlinking the asd file instead of the projects top level dir.
ec_ has joined #commonlisp
phadthai has quit [Read error: Connection reset by peer]
<Xach>
that will work also.
phadthai has joined #commonlisp
<_73>
I have succeeded. Thanks for the help.
mfiano has joined #commonlisp
CrashTestDummy2 has joined #commonlisp
CrashTestDummy3 has joined #commonlisp
mfiano has quit [Quit: leaving]
CrashTestDummy has quit [Ping timeout: 256 seconds]
tyson2 has joined #commonlisp
mfiano has joined #commonlisp
CrashTestDummy2 has quit [Ping timeout: 256 seconds]
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
<Catie>
In C, it's possible to spawn a POSIX thread with a "detached" attribute, such that when the thread's function exits its resources are freed by the operating system; there's no need to join the thread. Is anyone aware of a way to spawn a "detached" thread in Common Lisp?
paule32 has quit [Ping timeout: 256 seconds]
<Bike>
i believe bordeaux does not have detachment
<Catie>
Not that I've been able to find, at the very least
<jackdaniel>
if you are interested only in the final effect, then you could join in the finalizer
<Catie>
Register a finalize on the thread, all right! I'll give that a go and see if it'll work
<Bike>
i don't think implementations have this functionality much. clasp doesn't have it, doesn't look like sbcl does
<Catie>
Register a finalizer, rather
<Bike>
you could also give the thread function an unwind-protect, maybe?
<Catie>
jackdaniel: Thank you, I'll give that a read
mfiano has quit [Quit: leaving]
amb007 has quit [Ping timeout: 256 seconds]
amb007 has joined #commonlisp
<Catie>
Bike: the issue I run into is that you can't join a thread from within itself, and threads execute in their own dynamic environment. Originally I was hoping to make this work by signalling a condition, but none of the handlers I establish in the thread-spawning context are in effect for the thread
<Bike>
i meant within the function itself. like, (make-thread (lambda () (unwind-protect (do-stuff) (clean-up))))
<jackdaniel>
isn't this about system-reserved resources? how can you clean that up?
<Catie>
The system-reserved resource in this case is the thread itself. There's a limit along the lines of _POSIX_THREAD_MAX after which you get no more threads, and while it's incredibly unlikely that I'll run into that limit, ignoring it entirely just feels wrong
CrashTestDummy2 has joined #commonlisp
<Bike>
ah, i see. so it can't clean itself up.
rogersm has quit [Quit: Leaving...]
<Catie>
Yeah, it's a real weird one. The other idea I've got in my head is to have a dedicated thread-joining thread that responds to an asynchronous Unix-type signal and joins the thread, which would let my main loop continue uninterrupted
yourname_ has joined #commonlisp
<Catie>
jackdaniel: Wouldn't establishing a finalizer on a thread object that calls join-thread on the object itself cause a cycle?
yourname_ has quit [Client Quit]
mfiano has joined #commonlisp
CrashTestDummy3 has quit [Ping timeout: 252 seconds]
<Catie>
I suppose I could put it in a real lightweight struct or something
CrashTestDummy has joined #commonlisp
<Bike>
as he describes in the post, on some implementations (but not all, so there's a complication) the finalizer function receives the object as an argument
igemnace has quit [Ping timeout: 256 seconds]
<jackdaniel>
some implementations (most notably _not_ sbcl and trivial-garbage) pass the object as an argument to the finalizer -this allows rehabilitation or joining the thread
<Catie>
Which is incredibly convenient! I just don't want to have to rely on a specific implementation
amb007 has quit [Ping timeout: 252 seconds]
amb007 has joined #commonlisp
<jackdaniel>
well, trivial garbage is the smallest common denominator, so it will work everywhere
<jackdaniel>
the trick is to register a finalizer that closes over the resource for the single object that wraps over it (i.e (list resource))
<Guest74>
so how do you find out what the max thread limit is and how close you are to it?
<Catie>
Probably by writing a C program. You could inspect your system headers too
CrashTestDummy2 has quit [Ping timeout: 252 seconds]
<jackdaniel>
that said, you will probably need to take care to keep wrapper alive until the thread is finished, I'm not sure how blocking finalizers behave in implementations
<Catie>
Guest74: Under FreeBSD it's aliased to __ULONG_MAX, which is probably 2^64 (but I don't feel like looking through sys/types.h)
<Guest74>
I just read it depends on how much memory and stack size you have on linux
<Catie>
jackdaniel: If the wrapper object is referencing an alive thread, could it still be garbage collected?
<jackdaniel>
if nothing is referencing the wrapper - sure, why not?
<Guest74>
(os:shell "cat /proc/sys/kernel/threads-max") works. 62424 on my machine. Probably not a problem for my purposes.
<Catie>
Guest74: I think PTHREAD_THREADS_MAX is compile-time, but there may be a separate runtime tunable that's less than or equal to it
<jackdaniel>
passing the wrapper to the thread's environment should suffice for that purpose I guess (because when the thread finishes then it will be referenced no more)
<random-nick>
wouldn't the implementation of detached threads just be calling the pthread function which detaches the thread on the pthread? the thread would have to unwind all the way (and run the handlers) in order to exit anyway, right?
mfiano has quit [Quit: leaving]
mfiano has joined #commonlisp
<jackdaniel>
fwiw ecl creates them in detached state
mfiano has quit [Client Quit]
mfiano has joined #commonlisp
<Bike>
huh. kind of seems like a good idea for lisp threads generally?
<Guest74>
interesting max threads is determined by real memory, max threads per process by virtual memory on linux.
<Bike>
we can just have a separate thread object that keeps whatever info we want that we garbage collect normally
<Catie>
Bike: I agree! I'm looking through the SBCL source to see if they do the same
<jackdaniel>
yes, I didn't check on other implementaitons, but I have never actually thought that implementation might leave some linger resources when not joined
<jackdaniel>
it is, well, possible (and not probable)
<Catie>
The SBCL thread struct has a result slot, which indicates to me that the thread is joined by the runtime somehow and the result is collected, and that calling the sb-thread join function just returns that value
<jackdaniel>
otoh I think that I remember that sbcl doesn't care for closing streams taht are garbage collected (and such leak may end with no more descriptors)
mfiano has quit [Client Quit]
mfiano has joined #commonlisp
<Guest74>
I think they fixed that? Or I fixed my code. I used to run into that a lot.
<jackdaniel>
technically it is not a bug
<jackdaniel>
you could have copied the file descriptor by using some internals, closing it on gc may give strange results (but well, you've copied it by using some internals :)
<jackdaniel>
figurative "you"
<Catie>
Okay, so working backwards a bit, SBCL has a global variable *joinable-threads* and a function join-pthread-joinables. When I run a thread and let it exit, it resides in *joinable-threads*. When I trigger a garbage collection, the thread is no longer in *joinable-threads*. So maybe SBCL does the convenient thing?
Devon has joined #commonlisp
<Devon>
Which implementations Garbage Collect Truly Worthless Atoms? (GCTWA)
<random-nick>
Catie: they also seem to get joined in allocate-thread-memory
<Catie>
Ah, sure enough! I missed it because pauseless-threadstart isn't in my *features* anymore, so I skipped right over it
<frgo>
Oh-kay - I just booked my flights to Porto to ELS2022. Hope to see many of you there ...
<jackdaniel>
let's hope they won't have borders closed at the time
karlosz has joined #commonlisp
<frgo>
True words. I hope that by March we're out of of wave 4 and not yet into wave 5 ...
<Guest74>
omicron will either be the end, or a new start.
<frgo>
In my day job I work for the German Red Cross. I hope, really hope, that Omicron is covered with the current vaccines. Having all red flags on ICU bed availability in a 100 km radius around Stuttgart is no fun.
<Catie>
Sakes alive
<rotateq>
frgo: yes they start now giving more pressure to the situation
* attila_lendvai
is annoyed by the covid discussion, especially when people echo what they say on TV, as opposed to first-hand experience/info
lisp123 has joined #commonlisp
Cymew has quit [Ping timeout: 252 seconds]
Oladon has quit [Quit: Leaving.]
<_73>
from the SBCL repl, what is the way I can unqualify a library function? For example I would like to be able to use the symbol `alexandria:compose` as just `compose`. I can do this fine in a package using defpackages `:import-from`.
<Catie>
You can just (import alexandria:compose)
<_73>
ok thanks
<Alfr>
_73, the repl starts up in the package common-lisp-user, you could use IMPORT.
<Catie>
Or rather, (import 'alexandria:compose)
<Alfr>
_73, you also may want to think about creating your own package for repl use.
nature has quit [Ping timeout: 252 seconds]
<_73>
Alfr: I would want this so I could have my own custom default toolset?
paule32 has joined #commonlisp
<Alfr>
_73, or to make your repl habits less implementation dependent, because implementations make symbols accessible in cl-user which are not in cl.
<varjag>
so between the two mmap cl libraries, which one would folks prefer
waleee has joined #commonlisp
<random-nick>
Guest74: mem-aref seems to have a compiler macro which eventually directly calls SBCL's function for accessing memory when the type is constant
<random-nick>
which presumably compiles to efficient machine code
gaqwas has joined #commonlisp
<random-nick>
frgo: weird that the manual for CFFI has no mention of :array
<frgo>
Well, the real manual is the source code.
epolanski has joined #commonlisp
<Bike>
the internal workings of marray seem... exciting
<random-nick>
waaf-cffi seems to be a different approach to what static-vectors does?
random-nick has quit [Quit: quit]
random-nick has joined #commonlisp
<_death>
the limitations are not inherent, the interface was just sufficient to what I wanted at the time so I didn't bother removing them.. but if the idea makes sense, then one could imagine more powerful mmapped array facility.. say for IPC
waleee has quit [Ping timeout: 252 seconds]
<random-nick>
hmm, why does WITH-ACCESSORS not have the simple variant of slot-entry like WITH-SLOTS does?
<pjb>
because accessor names are often longer than what you'd want for a variable name.
<yitzi>
Shinmera: hehe....Arc isn't object oriented cause I know better!
<hayley>
Everyone who first learns CLOS apparently thinks they really need a reader macro for SLOT-VALUE. Then, hopefully they learn CLOS.
Fare has quit [Ping timeout: 252 seconds]
<jackdaniel>
novices don't use clos because they don't understand it, experts don't use clos because they do - or something like that
<jackdaniel>
(in truth most cl programmers use generic functions and clos protocols some way or another)
tyson2 has quit [Remote host closed the connection]
<yitzi>
How about: Novices see objects and slots, experts see generic functions and accessors?
<jackdaniel>
gurus see slot-location's
nature has quit [Ping timeout: 256 seconds]
<yitzi>
Nice.
scymtym has quit [Ping timeout: 245 seconds]
<jackdaniel>
thanks :)
Oladon has joined #commonlisp
pdietz has quit [Quit: Client closed]
<edgar-rft>
all slots but mommy :-)
gaqwas has quit [Read error: No route to host]
gaqwas has joined #commonlisp
gaqwas has quit [Remote host closed the connection]
<rotateq>
jackdaniel: plz tell me more about slot-locations :)
gaqwas has joined #commonlisp
<pve>
careful, you might become a guru
<rotateq>
pve: I'll take that risk. :) first I shall master the state of being a sorcerers apprentice to the next step
<jackdaniel>
I'm not a guru, I can't see it ,)
<jackdaniel>
slot-definition-location is advertised by amop authors as a way to optimize important bits implemented with standard classes (to avoid unnecessary function calls)
<rotateq>
okay but anyway you also have high respect by me
<jackdaniel>
heh
<rotateq>
ah okay, so i should go on reading and working through it, but wanted it anyway
gaqwas has quit [Remote host closed the connection]
<rotateq>
jackdaniel: but you're one of the McCLIM _and_ ECL gurus :)
aeth has quit [Ping timeout: 252 seconds]
gaqwas has joined #commonlisp
<varjag>
Shinmera: alright then
<jackdaniel>
they say that to hack something interesting you either need experience, talent or patience. I'm in the last group. thanks though!
<jackdaniel>
and good night \o (it is late here already)
<rotateq>
pve: there's a nice quote starting "if programming languages were like religions, LISP would be like Buddhism". I think that is one of the timeless points which attract me so much.
<rotateq>
see you soon again
aeth has joined #commonlisp
lisp123 has quit [Remote host closed the connection]
<pve>
rotateq: heh, nice
pdietz has joined #commonlisp
aeth has quit [Ping timeout: 252 seconds]
<pdietz>
Generic functions for slot access can be nice because you can combine other methods with them. :around, :before, :after
aeth has joined #commonlisp
<pdietz>
Another nice idea is to define slot-unbound methods to lazily populate slots.
waleee has joined #commonlisp
<rotateq>
in the beginning of the week i realized a bit more how/when the other method-combinations could be effectively used or that it can be useful the when having SETFs also generic the dispatch can go to the new-value too if needed
pve has quit [Quit: leaving]
aeth has quit [Ping timeout: 256 seconds]
aeth has joined #commonlisp
scymtym has joined #commonlisp
TMA has joined #commonlisp
Fare has joined #commonlisp
NotThatRPG has joined #commonlisp
<NotThatRPG>
Allegro offers `EXCL:RECORD-SOURCE-FILE` so that one can record where new kinds of things are defined. E.g., I am making FIVEAM do (excl:record-source-file ',name :fiveam-test) inside fiveam:def-test. Question: do CCL and SBCL have any equivalent of this?
Algernon91 has quit [Read error: Connection reset by peer]
Algernon91 has joined #commonlisp
waleee has quit [Ping timeout: 268 seconds]
abrantesasf has joined #commonlisp
<NotThatRPG>
Shinmera: If this supported Allegro, too, I'd be more excited -- Allegro, SBCL, and CCL are my target implementations....
<fe[nl]ix>
if Franz gave free licences to developers, that would be nice too
waleee has joined #commonlisp
<Shinmera>
NotThatRPG: you, too, can contribute to open source
<Shinmera>
don't let your dreams be dreams
<fe[nl]ix>
hahaha
igemnace has joined #commonlisp
hhdave has quit [Ping timeout: 256 seconds]
<NotThatRPG>
Shinmera: I'm already contributing quite enough to CL open source! I'm tapped out...
<Shinmera>
*shrug* Oh well...
<NotThatRPG>
I would have thought there would be an interface to SBCL's source recording but... apparently not?
<NotThatRPG>
There is a CCL:record-source-file
<Shinmera>
That reminds me that I initially created https://portability.cl in the faint hopes it would drive people to try and improve the situation on either library or implementation sides, but as far as I can tell it actually changed nothing at all.
<Shinmera>
So far my impression writing several of these libraries is that unless you do the painful work of aggregating the info for 90% of the implementations out there that you don't even use, nobody'll bother contributing a backend for even one more.
<Shinmera>
Or maybe I'm just impatient
<Bike>
i did a few from the implementation end, but i guess that's not quite the same
<Bike>
i should submit PRs, since i added a cltl2 interface in clasp
<Shinmera>
Yeah Clasp has been an outlier. You folks have been doing a tremendous job increasing support coverage.
<NotThatRPG>
Shinmera: If you look into the crawling horror that is the ASDF source, you will see what it takes... I don't know that anyone besides Fare has the energy to fight through testing on all the various implementations out there.
<Krystof>
(sb-c:source-location) gets you a source location for that form in sbcl, I think
<Shinmera>
NotThatRPG: I have, and as I said I've also written many of these libraries myself.
<Shinmera>
I'm not aiming my laments at anyone in particular, to be clear
<Shinmera>
Just woes about the general state of affairs, nothing new :)
<Bike>
a lot of these aren't actually that bad assuming the implementation has support. trivial-extensible-sequences support on sbcl consists of #+sbcl #:sb-sequence for example
<Bike>
but in that case there's a well defined protocol people pretty much go with, which is not the case with e.g. all the compile-file extensions asdf tries to herd
amb007 has quit [Ping timeout: 256 seconds]
<NotThatRPG>
Krystof: Does that let me set the source location myself? I will look again -- I was apropos-ing with source-file, so wouldn't have found any source-location symbols.
amb007 has joined #commonlisp
<Krystof>
the pattern we use is something like (defmacro deffoo (...) `(%deffoo ... (source-location))) (defun %deffoo (... source-location) <store source-location wherever you like> ...)
<Krystof>
then whatever consumes your source locations needs to know where you've stored them; I don't think we have a protocol for that
<NotThatRPG>
Ah. So one *calls* source location, and it gives you back the source location to do with what you will.
<NotThatRPG>
Thanks!
varjag has quit [Ping timeout: 252 seconds]
aartaka has quit [Remote host closed the connection]
<Fare>
Crawling horror? It's not THAT bad, for what it does.
<NotThatRPG_>
I didn't mean to imply that it's more awful than it needed to be. But awful it did need to be.
<NotThatRPG_>
Anyway, must dash! Goodnight all!
NotThatRPG_ has quit [Client Quit]
<Fare>
Gnite!
NotThatRPG has quit [Ping timeout: 252 seconds]
<Fare>
The awfulest parts are those that deal with portability across 17 implementations, in UIOP. Especially the portable run-program facility.
<Fare>
or the pathname support.
luis has joined #commonlisp
<Shinmera>
Yeah, run-program/launch-program are yikes
varjag has joined #commonlisp
<Fare>
pathnames are a mindfuck, though. There is a wide gap between that the standard specifies and what is common practice in today's world.
<Fare>
with plenty of undefined behavior that every implementation does in subtly different ways.
<Shinmera>
I have often thought about starting a thing for a secondary path mechanism that's more tailored towards modern systems, and adding support for that to implementations, but doing so is too much effort even for me.
<Fare>
iolib tried to do that...
varjag has quit [Ping timeout: 252 seconds]
<Fare>
but then you have to hook it up into LOAD and all other primitives that deal with paths.
<Shinmera>
did it? My idea would have been to allow using cl:open/etc with this new path type.
<Shinmera>
Right.
<Fare>
yeah, that's the part that's definitely not portable.
<Fare>
Also, anything that binds wrapped low-level resources to high-level variables introduces "interesting" issues to make your program async-safe. No one tries to do that because it's too hard (except for the Erlang guys maybe), but I wonder what an async-safe lisp would look like.
<Shinmera>
doing async in lisp is depressing in many ways :(
<Shinmera>
I'd give a lot to have the kinds of convenience that exists in JS and C# with the async keyword.
<tyson2>
Does Clojure do async well?
<Fare>
Shinmera, or use Gambit Scheme like me :-)
shka has quit [Ping timeout: 256 seconds]
<Shinmera>
I wasn't aware that Gambit supported all my 100+ libraries, wow!
<Fare>
(well, I use Gerbil on top of Gambit, but it inherits Gambit's relatively good async behavior)
<rotateq>
tyson2: as i heard clojure shall be well for concurrency
<Fare>
Shinmera, it doesn't :-(
<Shinmera>
Oh well...
<etimmons>
One of these days I want to add environment variable support to run/launch-program. Gonna probably take a while to get it right, though
<Fare>
That said, sometimes I wonder about porting CL to Gambit, or things like that.
<Fare>
etimmons, even more "interesting" to get right portably. You may have to punt on many implementations and/or extend them properly.
<rotateq>
and how do C# and JS do the async stuff? a friend told me in Rust the async is with some kind of continuations, but idk
<Fare>
etimmons, a fallback of course, on Unix, is to exec env... but what about Windows?
<rotateq>
oh noez windows
<etimmons>
Yeah, that's why I haven't even tried yet
<Fare>
debugging UIOP on Windows was... interesting.
<tyson2>
thanks, rotateq
<etimmons>
Fare: I bet
tyson2 has quit [Remote host closed the connection]
<Shinmera>
rotateq: marking a function async causes its return value to be a kinda closure. The await keyword within an async function marks a continuation/closure chain point. So async foo(){ x = await bar(); } returns a closure that should be called when bar() completes. when invoked, the function then resumes, binding x to the result of bar().
<etimmons>
Fare: by the way, I don't know how much you've checked out of gitlab emails, but I opened a merge request on reader-interception yesterday
Devon has quit [Ping timeout: 256 seconds]
<Shinmera>
rotateq: This makes async programming 1000x less painful because you can essentially pretend it's still imperative in most cases.
<Shinmera>
You could potentially do something like this in CL but it would definitely require code walking, and yikes.
cosimone has quit [Remote host closed the connection]
Algernon91 has quit [Ping timeout: 252 seconds]
<rotateq>
yes but in itself one of the really powerful concepts
<random-nick>
Shinmera: I think you can do something like that with cl-async and green-threads
<rotateq>
and of course, if scheme can have it ...
gaqwas has quit [Ping timeout: 252 seconds]
<random-nick>
green-threads doing the code walking
<random-nick>
rotateq: scheme's spec requires call/cc, which means that most implementations support it and/or some saner alternative
<hayley>
Yeah nah, you would probably mess up dynamic bindings with async/await.
<random-nick>
so it's probably trivial to implement
<hayley>
And then you have a whole lot of synchronous CL code to deal with, so you won't get very far with async colouring.
<random-nick>
I think you can implement coroutines using sleeping OS threads, but that is not exactly resource efficient
<rotateq>
"probably trivial" soso :)
<random-nick>
hayley: well that's an issue with any language which adds async later on, no?
<hayley>
Yes.
<hayley>
IOW give me green threads or give me death.