freenode/lisp - IRC Chatlog
Search
7:08:52
splittist
Sitting in my London hotel room waiting for the conference call with folks in three cities that are not London. The glamorous life of the road warrior. I keep thinking I should make time to see Xof, but, of course, I can't 'make' time (even though I live near CERN...).
8:47:30
hjudt
is there a way to catch SIGTERM and SIGINT signals in sbcl? i've tried trivial-signal, but the examples provided do not work; e.g. sending INT only invokes the sbcl debugger but the signal handler does not run.
8:53:17
no-defun-allowed
after some idea generation in #lispcafe, i present the magrathea anti-vulnerability scanner hunchentoot mixin
8:54:22
no-defun-allowed
it works just like the hunchentoot easy-acceptor but if you load too many "sketchy" URLs in too short time, it zipbombs you
8:55:37
hjudt
what i want to do: i want to react to TERM so that i can invoke a proper shutdown routine on the server, doing some cleanup.
8:55:39
jackdaniel
hjudt: if I had to guess I'd first disable interrupt for that signal in sb!unix package
8:57:11
jackdaniel
(sb-unix::enable-interrupt sb-unix::sigterm :ignore) ; and see if trivial-signal starts working after that
8:58:31
jackdaniel
also regrading graceful exit I think there may be a nice interface for adding exit-hooks
9:10:55
hjudt
thanks. i have added a function to sb-ext:*exit-hooks*, which gets called. additionally setting sb-ext:*timeout* to a lower value than the default 60 also solves my problem that sbcl takes too long to shutdown.
10:38:53
no-defun-allowed
Pretty sure we call it cl, unless you want an editor that only works with gnu clisp.
10:39:20
jackdaniel
clisp is one of many common lisp implementations, abbrev for common lisp is CL not clisp
10:41:08
no-defun-allowed
I might write an editor after Netfarm and Magrathea, but it won't be very emacsy, as it'll work on abstract syntax trees or actual lisp structures.
10:42:26
jackdaniel
I believe that's what beach works on with Second Climacs (and that was discussed briefly a few days ago on this channel)
10:45:35
no-defun-allowed
I remember I made an image of it which also loaded a climacsrc for the hell of it and wrote a hello world extension.
10:46:50
no-defun-allowed
Also, it has a better out of the box experience than slime+emacs IMO, I still can't get company mode out of dumb "I see a symbol, I suggest that symbol" mode.
10:50:28
jackdaniel
clisp is written in c, ecl's core is written in c as well, sbcl is written in common lisp, ccl is written in common lisp, abcl is written in java
10:51:23
no-defun-allowed
SBCL and CMUCL are partly done in C for stuff like the garbage collector and the "everything went horribly wrong" debugger.
10:52:20
jackdaniel
Necktwi: here you have a brief listing of CL implementations: https://common-lisp.net/project/ecl/static/quarterly/img/vol4/all-hierarchy.png
10:54:22
no-defun-allowed
jackdaniel: CMUCL and SBCL do use C for the lowest level parts of their runtimes. I like scaring people with gencgc.c for example.
10:57:29
jackdaniel
no-defun-allowed: they have some modules written in C, that is not the same. but now I udnerstand what you mean.
10:58:53
jackdaniel
also saying SICL is a Common Lisp implementation may be considered a little bit of exaggeration given it is not complete, I think a more proper term would be: a set of modules written in CL
10:59:40
jdz
Necktwi: are you here to learn something or just reject every opinion that does not match your own?
11:00:08
shka_
Necktwi: common lisp is language standard, implementations are free to be written any way they like to. There IS NO reference implementation.
11:00:10
jackdaniel
no-defun-allowed: that doesn't make sense to me. GCL is working ClTl2 implementation with some ANSI parts (so in this sense it is a finished working project)
11:00:19
no-defun-allowed
jackdaniel: I probably wouldn't want to run CL without a garbage collector, so it's a fairly crucial component of a Lisp system.
11:01:21
no-defun-allowed
clisp is the shitslow one -- oh we're talking about standard by "I'm the leader implementation"
11:02:55
jackdaniel
Necktwi: this kind of discussion belongs to #lispcafe - I suggest all interested should move it there. we've already left CL land with it to some opinions about compilers.
11:03:33
no-defun-allowed
Necktwi: if you don't want a garbage collector, you can take it to #rust or #c++ probably.
11:40:02
dim
jackdaniel: idly trying ecl again, I see a lot of shifting a negative signed value is undefined [-Wshift-negative-value] in the output, hundreds of warnings when compiling lisp code
11:44:30
jackdaniel
shifting is for int integer <-> fixnum conversion (fixnum is an immediate), this is correct. we could possibly do something with a warning, but I'm not sure how to hid it
11:47:31
jackdaniel
sorry, I have two pans on fire (making dinner) can't help you more at this moment
16:33:14
matzy_
dunno who else has read it here (I'm assuming most people?), but I've been learning CL, and the second chapter on macros in Practical Common Lisp blew apart my brain last night
16:38:02
matzy_
beforehand i actually thought i kind of had a grasp on them, but it made it very confusing somehow
16:38:14
White_Flame
macros take source code, and return source code. This transformation happens before the involved functions are ever called.
16:38:49
White_Flame
so in (my-macro foo bar baz), even if foo/bar/baz are local variables, you get the source code symbols FOO BAR BAZ as parameters to the macro
16:39:11
White_Flame
yes, (defmacro my-macro (sym1 &rest others) ...) sym1 = FOO, others = (BAR BAZ)
16:40:04
White_Flame
&body is pretty much exactly like &rest, but tells the editor to indent it like a code body instead of as a data list
16:47:43
matzy_
but aren't all macro names throw away prefixes? like you dont use the name for anything besides calling it, right?
16:48:12
White_Flame
macros perform some transformation, usually because you want to generate more complex code given a simpler form
16:48:52
White_Flame
(defmacro sum (&rest nums) `(+ ,@nums)) would semantically perform a sum operation, though it's equivalent to #'+
16:50:37
pfdietz
matzy_: macros can perform arbitrary computations. They can be used for things that require preprocessors in other languages. Something like yacc, for example, can be done via a macro in Lisp.
16:51:06
pfdietz
A general rule though is that if it can be done naturally by a function, don't use a macro.
16:51:31
White_Flame
basically, as PCL mentions, write the short macro form and the expanded form that you desire. Then write code to generate one from the other
16:53:17
White_Flame
create this macro: (defvars *a* *b* *c*), which would expand to (progn (defvar *a*) (defvar *b*) (defvar *c*)) for any given list of variable names
16:55:45
pfdietz
You might also look at the things in lisp itself that are macros. Call macroexpand or macroexpand-1 on the (quoted) forms to see what they turn into.
17:01:22
White_Flame
pressing Alt-. in emacs when on the macro name will take you to the macro's source code
17:01:35
pfdietz
Right. They show what happens when macro expansion is performed at the (top level of the) form.
17:02:31
matzy_
that's what i wanted to see, their source. but then it'll be super helpful to see how they transform too
17:03:47
matzy_
White_Flame: ah crap my evil bindings overwrote that shortcut. do you know what the function is that i could call with M-x?
17:06:39
pfdietz
macroexpand-1 does one expansion. macroexpand keeps doing expansion (at the root of the form) until it's not a macro there.
17:10:44
another-user
hi, is there real world examples of advantage of clos over structs/plain functions?
17:11:09
White_Flame
yeah, (collide ball wall). Do you put the collision "method" on class ball or class wall?
17:12:04
White_Flame
regarding pklain functions, they can't dispatch on their parameter type (at least in the C view of things)
17:12:52
White_Flame
and CL multimethods can have before/after/around hooks, as well as the meta-object protocol which lets you define what an object, method, etc fundamentally is & does
17:14:58
another-user
White_Flame: yeah, but all those hooks can be implemented trivially with plain functions as well and to define my data i could use structs/maps
17:15:40
White_Flame
certainly you can turing tarpit any feature, by dumping in lots of programmer discipline burden and mandating specific framework call styles
17:16:06
jackdaniel
another-user: you could have heard the same argument about introducing functions from assembler programmers
17:16:47
matzy_
White_Flame: i feel like this should be easier than i'm making it out to be. i dont get how to repeat (defvar ) statements like that for each arg
17:19:02
another-user
White_Flame: regarding collide example, it's good point against oop actually, usually it comes up in game dev and there people use ECS instead of OOP
17:19:16
beach
another-user: I think you are going to have to trust us that there are tons of advantages of using generic functions and standard objects. You will understand the advantages once you start using these features.
17:19:56
shka_
another-user: CLOS is awesome, allows to write programs with unparalleled extensibility while still being understandable
17:19:59
beach
another-user: It is good argument against traditional object orientation where the class provides encapsulation and where there is only single dispatch.
17:20:12
matzy_
Bike: i actually tried that in slime, and it said y was unbound. but shouldn't ,@vars at least work right?
17:20:37
beach
another-user: It is not a good argument against CLOS-style object orientation, where the encapsulation is provided by the package system and we have multiple dispatch.
17:20:43
shka_
i tried to write example in a blogpost, but sadly i think that i failed to show advantage decently
17:20:50
Bike
matzy_: it's expanding into (defvar x y z), which is what you told it to expand into, but probably not what you want it to expand into.
17:21:25
matzy_
Bike: no, slime throws an error instead of expanding, and while i get it is not what i was trying to do, shouldn't it still work?
17:21:35
jackdaniel
clos brings a lot to the table. I have ambivalent feelings about this, because it abstracts many things away (so you don't have to think about these things), but also requires a lot of cognitive effort for programmer to understand the code - I'm not sure if using it for anything non-trivial simplifies or complicates programming