libera/#commonlisp - IRC Chatlog
Search
16:00:31
pjb
nij-: but more often, you want to mix lisp and your own syntax. see for example, objective-cl: https://groups.google.com/g/comp.lang.lisp/c/AkU0JCnGGAA https://gitlab.com/com-informatimago/com-informatimago/-/blob/master/objcl/documentation.pdf
16:00:38
ecraven
phoe: but hard to generalise, if it's meant to work like clojure, for accessing "slots" of objects.. you'd need to define *all* possible keywords
16:01:21
phoe
ecraven: no no, I mean, if you had (:foo ...) expand into (my-ref :foo ...) then you would exclude the possibility of (defun :foo ...)
16:01:52
nij-
It's ok, I think the easist way is to hack the reader macro, but I may have to type one or two more characters.
16:24:00
beach
As I recall, Fare tried to define functions with names like that for ASDF or UIOP, citing that it was practical that they would always be available. But he had to back down when there were loud protests.
16:25:09
phoe
keywords are a rare global resource and defining stuff on them should be reserved for end users
16:30:38
thuna`
phoe: Right, the answer is keyword. But I had figured they worked similarly to nil and t
16:31:03
phoe
the thing is that T and NIL are from the CL package and by 11.1.2.1.2 you cannot define stuff on them
16:50:30
beach
Slow, but making steady progress. The latest progress by scymtym prompted me to work on Second Climacs a bit, so that his work could be layered on top of Second Climacs.
16:53:09
beach
So what you are seeing is very detailed and very accurate analysis of Common Lisp code at typing speed.
17:07:17
pl
Have a project where I might want to implement a RPC message bus and CORBA would be reasonable option
17:12:31
jeosol
beach: is it evaluating the code as type, or I am not understanding things correctly
17:12:33
beach
The editor is just DREI, so it is not the final deal. The demo is more about the upper layers.
17:13:03
beach
jeosol: It is not evaluating it. But it does some analyses based on the s-expression syntax.
17:14:15
beach
It won't ever generate executable code, but there could be some compilation-like passes added for even better analyses.
17:15:45
beach
In addition to the syntax analysis, scymtym also has a model of the global environment and the package system, so that some top-level forms can be "evaluated" for incremental effects on this global environment model.
17:16:06
jeosol
I seem to recall seeing some editor discussion last week about the state of editors. I only used SLIME+EMACS but did look at Sly, but then went back to my old slime+emacs setup
17:17:10
NotThatRPG_
I wonder if someone can clarify SBCL's interpretation of FUNCTION types. According to a compilation note, it's interpreting my (declaim (ftype (function (t t) fixnum) choice-node-player)) as (FUNCTION (T T) (VALUES FIXNUM &REST T)) Where does the &rest t come from?
17:18:32
Bike
if you mean that it returns exactly one value, instead of fixnum you can use (values fixnum &optional) or, my preference, (values fixnum &rest nil) which i think sbcl will interpret the same way
17:18:34
rainthree
https://stackoverflow.com/questions/9743056/common-lisp-exporting-symbols-from-packages "Of course, one could reach the conclusion, that macros like defstruct lack a feature. Namely, a switch which enables automatic exporting of the accessors etc. they create." (or better: a switch for each accessor :export t or nil) . Is it so ? I know serapeum.export has this, but the drawback is that the code becomes "foreign" to everyone used to the standard
17:18:34
rainthree
way of exporting in the defpackage. The drawback of exporting in the defpackage is that things get go out of sync , it brings extra maintenance burden . I think the best is to use defpackage and to reduce the burden, let the editor help you: "C-c x to export the symbol at point, or even the class and all its accessors with slime-export-class" . Now the only issue is that I'm dealing with cffi:defcstruct and slime doesn't have a function to
17:18:35
rainthree
automatically export the accessors for it. Should I code one myself or you guys have a better solution?
17:19:19
phoe
rainthree: do your own one, I have no idea if cl-annot or cl-annot-revisit has anything for automatic export of defstruct
17:20:35
rainthree
https://github.com/LispCookbook/cl-cookbook/issues/269 it has , but I think it can only export all of them, you cannot individually select which accessor you want to export, and that's not good
17:27:13
NotThatRPG_
Thanks, Bike ! A quick type declaration follow up: am I right in reading the spec as prohibiting declaration of the return type of a generic function? The doc page for `defgeneric` says that there can't be function declarations *inside* the form, but I could read it either way about external declarations.
17:30:30
resttime
If there are any CFFI maintainers lurking, created a PR for a small change meant to be first step in tackling an old bug with libffi and passing a foreign-structure-by-value (FSBV) to a foreign function with variadic args : https://github.com/cffi/cffi/pull/347
17:37:16
Bike
NotThatRPG_: you can declare the return type of a generic function, the same way as you do with other functions - declaim
17:37:35
Bike
NotThatRPG_: the declarations within the defgeneric only pertain to the discriminating function, which is why only optimize is allowed
17:39:22
NotThatRPG_
Bike: I was trying to do that, but according to SBCL "Generic function SHOP3::CHOICE-NODE-PLAYER clobbers an earlier FTYPE proclamation (FUNCTION (T T) (VALUES FIXNUM &REST T)) for the same name with (FUNCTION (T T) *)"
17:40:43
beach
random-nick: No, but there are plans for such a thing: http://metamodular.com/POSIX-API/
17:42:10
NotThatRPG_
Bike: But it seems to imply that the return value declaration is being ignored. For now I'm just putting #-sbcl in front of it.
17:43:55
Bike
you can see what the declaration on the name is with describe. and it does look clobbered if you put the declaim before the defgeneric. how vexing
17:46:58
random-nick
beach: hmm, I guess what I'm looking for would be something like the low-level interface, but I guess I'm interested in some linux-specific system calls
17:47:51
random-nick
regarding the no FFI requirement, wouldn't that cause problems for some newer system calls which use C structs?
17:49:39
rainthree
phoe: I think this is the most convenient solution: https://stackoverflow.com/a/70235441/19589272 show-all-fboundp-symbols-of-package then copy paste or use some editor shortcut such as ctrl+right click on the symbol to add it to the :export list in the defpackage form
17:50:08
beach
random-nick: A C struct is just a sequence of bytes in memory. It is just a matter of figuring out the layout.
17:50:28
beach
Anyway, my (admittedly small) family just announced that dinner is ready, so I'll be off for today.
17:50:39
pjb
But syscalls are just a few hundred functions. The equivalent of the API from libc would be implemented in pure lisp.
17:50:58
pl
random-nick: you need only to port the binary layout into some form of serialisation/deserialisation component that can be pure Lisp
17:52:05
pl
ACTION recalls the joke from Genera sources about implementing considerable chunk of PL/I compiler to do something like that, for mapping data structures into binary records on disk
17:52:31
random-nick
pl: it still has to reside in what is usually called "foreign memory" since CL object don't have any guarantees about how they're laid out in memory afaik
17:53:59
pl
You can have that as implementation specific interface between standard and implementation detail
17:56:02
pl
Similarly, the closest thing to knowing exact layout in standard C is that things in array are laid out in certain way
17:57:08
pl
(and even then it's not guaranteed it will reflect the layout and ops necessary to access them in actual memory, just that it will match other standard C code behaviour)
20:56:42
Nilby
random-nick: A number of things exist, but they are all partial or incomplete, as far as I know. If you want to share what system calls you're interested in, perhaps there's a smaller library that does what you're looking for?
21:38:27
random-nick
I was asking about it in general, but I guess the most interesting one is probably epoll
21:43:45
random-nick
also, getting access to futex and related APIs might be useful, but I don't know how the different implementations handle getting blocked in foreign code
23:09:46
pl
random-nick: on linux (and windows), the really nice stuff would be to implement io_uring
2:02:12
shunter
Quick question on WITH-XYZ macros that bind VAR -- is it recommended to declare that VAR has dynamic extent? VAR shouldn't be used outside the body anyways, so I think it fits with what dynamic extent is supposed to be, right?
2:03:07
shunter
It shouldn't, because the meaningful resource is closed by the time execution leaves the body
2:04:47
shunter
Very much like a with-open-stream: `(let ((,var (wl-display-connect ,@args)) (unwind-protect (progn ,@body) (wl-display-close ,var)))
2:05:55
Bike
if the value is actually inaccessible than using dx is fine. unless wl-display-connect inlines to something special, i doubt the declaration will really do anything, though.
2:52:00
Bike
it'll make your code very confusing, as it will mean calling a function alters the global definition of some other function.
3:03:47
dbotton
First in clog lingo - When you instantiate an instance of a clog panel there is an on-setup handler, so in that handler I want to sometimes define a function. - so in CL lingo - this is a function say create-panel generated by the builder that includes code by the user to run each time create-panel is used. So wanted to understand potential pitfalls if they add a defun
3:05:15
dbotton
As I can say have a canvas, draw a circle when created, then reuses the same code in say the on-click
3:05:48
Bike
well having code that messes with the global environment is messy for the same reason messing with the global environment usually is.
3:10:38
Bike
rationale what, in the standard? defun is just a normal form, so there's no reason to disallow it anywhere, and no specific rationale for allowing it anywhere
3:33:42
emacs-dwim
nij-: Of course, CL has: *evalhook* *applyhook* *macroexpandhook* #'evalhook #'applyhook.
3:40:37
dbotton
Bike, this seems interesting as a result - (defmethod draw ((obj (eql panel)) circle-color) nil) if I want a more JavaScript style of OO to place the defmethods in the create function.