freenode/#lisp - IRC Chatlog
Search
7:35:26
pve
Good morning. Am I correct in assuming that the following must return a string if the package ASD doesn't exist:
7:35:30
pve
(handler-case (read-from-string "ASD::QWE") (package-error (x) (package-error-package x)))
7:38:24
jackdaniel
pve: I think that standard does not specify whether reader signals a package-error in this situation
7:42:19
jackdaniel
http://www.lispworks.com/documentation/HyperSpec/Body/02_ce.htm "For example ..., the reader signals a correctable error" (examples are not normative, but it is a paragraph just using the phrase "for example")
7:43:01
jackdaniel
and "If editor::buffer is seen, the effect is exactly the same as reading buffer with the EDITOR package being the current package. "
11:04:28
iissaacc
and when i just blindly used pmap from lparallel in the REPL without doing any setup
11:04:53
iissaacc
instead of an error message i get a friendly "welcome to lparallel!" condition prompting me to set up a kernel
11:05:23
p_l
phoe: yes, but that requires a bit more work if you are going to represet XML in S-expressions :)
11:07:19
p_l
pjb: unfortunately I fear that one would need a special object for XML entities unless one wants to accidentally pollute the image in bad ways, for example to have nickname-independent namespace handling, as well as XML attribute lists
11:32:44
p_l
_death: I disagree. IIRC there's a single line to add to setup a kernel, and the main reason to have even the ability to use multiple kernels is to have control over them. If it created a kernel automatically, it would break a lot of stuff in fact
11:33:10
p_l
(related: why ITA ran, iirc, a customized CCL version that was modified precisely to not start threads automatically)
11:34:49
_death
p_l: a default does not preclude multiple kernels.. and a lazy default of a kernel containing nprocs workers makes sense to me.. I don't see why it should break stuff
11:36:24
_death
right now I have a line in my .sbclrc setting the kernel, and indeed it's an issue when dumping an image.. I could wrap the toplevel with a handler-bind to set it lazily, but..
11:36:26
p_l
_death: because there are non-trivial interactions in the running environment related to whether you have single or multiple threads
11:38:21
_death
p_l: a default kernel would be useful in a development setting.. an actual application would explicitly init its own kernel
11:39:07
p_l
_death: the issue I see is that anything that triggers threading is a danger in *development* setting. Much less in a deployed application setting
11:39:14
no-defun-allowed
I guess nproc is usually correct, but some people like to count cores and not hardware threads, and if I was doing something like pmapping URLs to retrieve over a network, I would want more worker threads.
11:39:25
p_l
it's already an issue when you link to some foreign lib and it triggers a thread when you don't expect it
11:41:19
no-defun-allowed
(Oh, and you would also have to implement thread count detection, as lparallel doesn't have that to my knowledge.)
11:42:47
p_l
you'd also need to check things like current resource limits, which is non-trivial and OS specific and nonportable
11:47:36
_death
it's not hard to find defeaters for any default.. anyway, even if the default default is not to have one, it could still make sense to allow a different default, say by setting lp:*kernel* to a function that can be called to create the actual kernel which will then be assigned to lp:*kernel*
13:52:52
younder
Josh_2, Well one of Lisp's traditional uses has been to experiment with languages. So you'd expect a bit of weirdness.
13:53:38
Josh_2
most of what I have read in Let Over Λ I just can't see how they would be used practically
13:56:22
younder
Josh_2, Let over lambda is a bit weird. Most get their bearings with 'Practical Common Lisp' with Peter Seibel
14:54:17
Bike
let over lambda is pretty strange, yes. many of the things in there are in fact impractical
14:55:16
loli
defmacro! or w/e it is called, can be nice to use. Though I haven't used much outside of that
15:02:21
rumbler31_
is there something similar to #x and #b for decimal numbers? I have an interesting bug where I have set print base to 16 and I want to explicitly read a base 10 integer, this is proving hard to google
15:20:55
rumbler31_
so i have a usocket connect call where I defined the function that uses this in the repl after I changed print base
15:21:53
rumbler31_
the resulting connect port gets read into its base 16 version (that miraculously is a legal base 10 number) and that number is passed to the lower level socket open call
15:23:21
rumbler31_
I thought at first that it would be fixed by being explicit about the base of the number that I typed into the repl, #10rnumber seems to be what I originally asked
15:24:42
rumbler31_
I set print base to look at network byte data with plokami and then wrote a funciton in the repl to rebroadcast packets to a udp port
15:25:04
rumbler31_
print-base was already 16 when I wrote (defun once ((open socket host portnumber))
15:25:29
rumbler31_
so port number was read from decimal into hex, which happened to be a valid decimal number, then that number was passed to the lower level open call
15:27:05
rumbler31_
oops now i've run out of file handles for opening too many sockets and forgetting to close them lol
15:49:02
francogrex
I am disgusted by swig, language cffi and uffi are no longer support. makes me want to vomit
16:20:54
kinope
Hi! Quick question. Are Common Lisp's bitwise operations like 'logand' considered as performant as their C/C++ counterparts? I've seen this used as an optimisation where a bitmask that is a power of two is used to do modular arithmetic.
16:22:36
phoe
which means that you need to do a proper LDB or MOD for the compiler to notice "oh, I can optimize it into a single CPU instruction on a machine word"
16:26:17
pjb
kinope: if you want to learn something, try to write in C: (defun f (x) (if (< x 0) 1 (* x (f (- x 1))))) (defun main () (print (f 1000)))
16:26:41
pjb
kinope: then you can try to compare the performance of your C program and of this CL program.
16:32:17
_death
rumbler31_: I use a repl-specific pprint dispatch table for pervasive hex printing.. see https://github.com/death/slime/commit/fedcefab7e8378ea90979ff3697056dea092ae0a
16:35:05
kinope
ralt: unfortunately for me ECL doesn't do dissasemble, but I did just have a look at the source and it looks like logand is directly translated to C's bitwise and '&'. I can't find where mod is implemented just now though.
16:38:12
jackdaniel
the function mod is implemented in src/c/num_co.d, but the compiler may opencode it into something more efficient if it i.e knows that arguments are fixnums
16:38:17
kinope
pjb: I couldn't tell you about that operation on 10000 bits, Bit twiddling is not my forte
16:39:13
jackdaniel
regarding bitwise operations, their optimizations are in src/cmp/cmpopt-bits.lsp
16:44:11
pjb
kinope: (defun make-lots-of-bits (n) (map-into (make-array n :element-type 'bit) (lambda () (random 2)))) (let* ((n 10000) (a (make-lots-of-bits n)) (b (make-lots-of-bits n)) (c (bit-and a b))) (print a) (print b) (print c))
16:44:25
kinope
jackdaniel: I'm looking at an implementation of a lock-free data structure that I think is bit twiddling for the added performance. I'm just trying to figure out if i can get away with using just the standard 'mod' to the same effect.
16:44:55
_death
kinope: a tail recursive one would have something like (f (- x 1) (* x acc)) in the "induction step", i.e. calling itself would be the last operation
16:44:58
pjb
kinope: or: (defun make-int-with-lots-of-bits (n) (random (expt 2 n))) (let* ((n 10000) (a (make-int-with-lots-of-bits n)) (b (make-int-with-lots-of-bits n)) (c (logand a b))) (print a) (print b) (print c))
16:46:53
jackdaniel
it was a question of uneducated folk, but I don't think that confusing him more would make him ask better questions
16:47:42
phoe
pjb: answering a question with an equally idiotic answer doesn't help anyone, even if the original question is, in your opinion, idiot.s
16:48:57
pjb
phoe: the original questionw as a comparison of C and CL on logand. There is no more relevant than to write two programs, in C and in CL using logand.
16:48:58
kinope
I may give that a shot later pjb, but right now its 3am in the morning and I'm not set up for C development on my phone, haha.
16:50:13
phoe
pjb: the original question was about using modular arithmetic and its performance, since that's all what C and C++ are capable of unless one uses a bignum library, and your answer was about bignums, which do *not* use modular arithmetic, and therefore your bignum answer did not apply to it.
16:51:15
pjb
phoe: most modular arithemetic is used in cryptography, on numbers bigger than a long long.
18:06:39
_death
it's useful if you want to program FORTRAN in Lisp.. though there are better options like prog and &aux
18:12:12
enedil
I mean, I would try to understand id better, but now I'm writing for code to pass my class, due to covid we had "remote classes" - consultations by email, so now, I'm trying to make some code that works. My go-to functional language is OCaml and it wouldn't like this kind of solution too