freenode/#lisp - IRC Chatlog
Search
0:36:37
Josh_2
Is there an advantage to do say (defmacro pop-queue () `(sq:dequeue *commands-queue*)) over (defun pop-queue () (sq:dequeue *commands-queue*))? I've seen it done with accessors before
1:25:26
aeth
Josh_2: If you have a macro and an equivalent function, always go with the function. If you want sort of macro-like behavior then (declaim (inline function-name)) and you get that. Note that that inline includes the macro's *disadvantage* of not updating the callers when you recompile it. It will give you macro-like performance characteristics while permitting higher order functions and removing a bunch of potential bugs, though.
1:27:00
aeth
e.g. (defmacro 2+ (number) `(+ 2 ,number)) vs. (defun 2+ (number) (+ 2 number)) vs. (declaim (inline 2+)) (defun 2+ (number) (+ 2 number)) and for this particular case the 3rd option is probably what you want.
1:29:53
aeth
Forgetting , is such a common bug because the author will probably name their variables the same the whole way so it will take a third party using it to spot the missing , so that's one good reason to never use macros when a function will do.
1:30:25
aeth
e.g. the 2+ macro author might name their number 'number and then write `(+ 2 number) and you'll spot it when you call your number 'n and have to write a pull request
1:32:03
aeth
These seem to be incredibly common in exactly the sort of macro-as-inline-function trivial macros, too. Perhaps because the author isn't paying too much attention to something so trivial.
1:42:29
Josh_2
(bt:make-thread ..) is the way to make a thread that should run in the background, or am I missing something... *thonk*
2:05:38
aeth
Josh_2: (defun hello (n) (format t "Hello, ~D.~%" n)) (defun make-hello (n) (bt:make-thread (lambda () (sleep 10) (hello n)))) (dotimes (i 10) (make-hello i) (sleep 1))
2:06:42
aeth
Josh_2: Interestingly, the #'make-hello is actually *mandatory*, or else it reads the *current* value of i (9 for the first thread and 10 for the remaining 9) at the time of printing instead of printing 0 to 9.
2:07:43
aeth
Also don't forget to put it in its own function or be very aware of the variables it's capturing
2:08:51
aeth
It's a clsoure. It will have access to all of the outer variables, although if it's just (lambda () (receive-data)) I guess it won't matter. I think in that case (zero arguments) you might just be able to say #'receive-data
4:43:24
emaczen
I have a lisp function whose argument gets passed to a particular cffi:foreign-funcall which expects a struct
4:43:49
emaczen
The "struct" I pass to the lisp function gets automatically translated into a lisp list
4:45:30
emaczen
How do I stop this automatic translation, or how can I force the list to be converted back to a struct?
5:43:12
LdBeth
emaczen: then just use the ctype pointer, see https://common-lisp.net/project/cffi/manual/cffi-manual.html#Foreign-Structure-Types
8:13:28
Nilby
Grue: Probably because it wants you to use #'cddr, maybe to prevent against 'something as a typo.
8:17:22
beach
Grue`: I think it means that it is going to call FDEFINITION, perhaps in each iteration.
8:33:55
Grue`
I actually avoid using #' in my code for various reasons, so this warning was annoying
8:40:08
Grue`
' always uses top level function definition, so for example if I'm calling a function in a macro expansion I'm immune to it being redefined in flet
8:42:41
Grue`
yeah, standard functions get ' for consistency. basically I only use #' for lexical scope functions
8:50:43
Grue`
there's literally no difference in (disassemble (lambda (y) (funcall 'cddr y))) whether I uuse #' or '. So the compiler probably realizes that just means (cddr y)
8:59:26
jackdaniel
it might be that optimization of "locked" funcitons is in independent module and happens much later
10:31:36
akr
so if you pass example@example.com as the envelope, cl-smtp tries to use <example@example.com>
10:33:10
akr
the problem seems to be here: https://gitlab.common-lisp.net/cl-smtp/cl-smtp/blob/master/cl-smtp.lisp#L398
10:37:19
akr
#<SMTP-PROTOCOL-ERROR a command failed:\\ncommand: \\\"MAIL FROM:noreply@domain.eu\\\" expected: 250 response-code: 555 response-message: 5.5.2 Syntax error. w3sm148620wrp.51 - gsmtp>
10:37:21
akr
#<SMTP-PROTOCOL-ERROR a command failed:\\ncommand: \\\"MAIL FROM:noreply@domain.eu\\\" expected: 250 response-code: 555 response-message: 5.5.2 Syntax error. w3sm148620wrp.51 - gsmtp>
10:44:45
akr
there was a problem with my envelope which I fixed and then there was a problem with Google SMTP denying our requests doe to wrong IP or somesuch
10:47:55
beach
prite: There are two common ways, either "see loss" or "kloss". I use the former. I know nobody to pronounces each individual letter.
11:21:50
jackdaniel
some pronouce it c-loss, as an ultimate argument in favor of Common Lisp (and not for C). of course it sounds all the same, but it is the feeling you put into words what counts here ,)