freenode/#lisp - IRC Chatlog
Search
17:52:26
sukaeto
IIRC, if you put type declarations in your code, SBCL tells you when you make a type error
17:55:30
sukaeto
minion: memo to rpg: you could try out elpy. I've used it a bit with iPython in inferior Python mode. It's not as nice as SLIME, and I eventually stopped using it, but it might give you what you want.
18:02:14
anamorphic
Hi, I have some foreign code that deals with a pointer to two kinds of things: FOO and BAR, but in my CFFI code, I'd like to prevent a FOO pointer being passed to a function where BAR pointer is expected, so I came up with this scheme: https://pastebin.com/YU7fx2XK but it feels like I'm probably re-implementing something. Is there a better way to go?
18:57:04
phoe
anamorphic: I don't think so. CFFI pointers are not typed, so having a simple structure wrapper around them is the way to actually keep them typed in the Lisp world.
19:13:22
Bike
cffi does maintain types for pointers, it just ignores them, right? would it be difficult/possible/a good idea to have it type check those?
19:15:37
|3b|
at least on sbcl it just returns an (untyped) sbcl pointer value, with no extra cffi type info as far as i know
19:24:39
phoe
I mean, the returned pointers are not typed in any way and a pointer returned from a function that is supposed to return an int pointer can be dereferenced as a float pointer later on and no type errors will happen.
19:25:10
phoe
I suppose it could, sure - it won't be backwards compatible, obviously, but the type information could be stored somewhere and then checked.
19:25:43
LiamH
I think the reason for the pointer types is for conversion on dereferencing, especially for structs.
19:28:39
phoe
LiamH: you can't dereference a pointer in CFFI without providing the type that you want to dereference as.
19:41:10
sjl_
> Pointers do not carry around type information. Instead, type information is supplied when pointers are dereferenced.
19:41:12
sjl_
> A type safe pointer interface can be developed on top of an untyped one. It is difficult to do the opposite.
19:46:34
LiamH
cffi-libffi, which allows for struct by value call/return, required the type of the struct be specified in order to do the conversion. As a convenience, the ability to specify the type of pointer was added to facilitate similar conversion for call-by-reference, though I don't think that is implemented.
20:07:30
phoe
karlosz: get yourself a fresh int pointer, write a uint32 to it, read a sint32 from it
4:39:56
p_l
and some of the issues might have came from sleep apnea, something I'm going to have tested
4:40:32
beach
Oh, yes, so! My (admittedly small) family has those, and got a machine for breathing at night.
4:43:36
p_l
while not as much of a problem in that specific job, it was definitely a pattern over last year