IRC channel logs
2025-12-30.log
back to list of logs
<Codeko>I was writing an elisp->scheme procedure for my project that would work like this: <Codeko>(elisp->scheme '(defun double (x) (* x x))) <Codeko>but i've figured that i can just implement defun as a macro and it works, maybe a transpiler is not really needed for my project <ieure>Codeko, Guile can execute Emacs Lisp natively. <ieure>Might be some helpful stuff in that code. <Codeko>Looking into that code doesn't sound like a bad idea, but Guile executing elisp code natively doesn't really convince me, what does it do when if i try to run (split-window-right) or (put-text-property 1 10 'face 'bold) <ieure>Those aren't part of the language, those are Emacs features. <dsmith>Codeko, The question I ask is, where does elisp the language end, and emacs the application start? (and there is no clear answer yet) <Codeko>dsmith: You could try to trace some imaginary lines, but i don't think it makes much sense <ArneBab>johnwcowan: I’m glad sending the book worked! And I hope it’s well readable (it’s currently the only one of its kind) and you enjoy reading it. <ArneBab>johnwcowan: the book is meant as a present and a thank you. <ArneBab>johnwcowan: usually it’s just about as small as a hand :-) <mwette>I have module that provides getters and setters for C data structures stored in bytevectors. Would it be too odd for the getter to return, for a union type, an alist of all union members? <identity>…does that mean it would cons on access? <mwette>I need to be more clear. Give me a minute. <dthompson>I also have a library for parsing C structs in bytevectors that supports unions and I have used it for SDL3's massive SDL_Event union successfully, so maybe I can give some guidance <identity>i read that as ‹when using the getter on a union type, it would return an association list where the union members are keys and values are, well, values› which is definitely quite odd <mwette>dthompson: I'm aware of bstructs, if that is what you are talking about. <mwette>identity: Your read is correct. Why is that odd? You ask why do that when you have the getter for that, but someone may want to feed to procedures which assume alists. I have people asking for it. <dthompson>so is the request to convert structs to sexps? <mwette>I have set up setters and getters to accept alists, but getting unions makes me cringe a bit. <dthompson>seems weird to mix alists into your getters and setters rather than having a c->sexp conversion procedure <mwette>For object from struct { int a; int b; } you can (cdata-ref object 'a) to get a scalar or (cdata-ref object) to get ((a . 1) (b . 2)) <mwette>I am doing that for structs. But for unions I currently just return #f. <mwette>the architecture is use (cdata-sel obj tag ...) -> ctype; and (cdata-ref obj tag ...) -> guile value <dthompson>an alist representation of a union would be just like a struct but each value would be a view of the data as the union field type <identity>if you have a union of a boolean and a char, what is (cdata-ref union 'bool) when the union is #00000010? does that throw an exception? <dthompson>like in bstructs if I have the type description (union (foo int) (bar double)) then an sexp view of it would look like (union (foo 0) (bar 0.0)) <mwette>right. Does putting random bits in a float value ever generate an exception? <mwette>I have a pretty-printer that is like your bstruct->sexp I think. <dthompson>and it's often not very useful to look at a union this way except for debugging purposes <mwette>oops, my pretty-printer is for types, not data <mwette>So your ->sexp does generate all union options <dthompson>like if I allocate the union above like (bstruct-alloc <foo> (foo 42)) the sexp view is nonsense for the bar field <mwette>Exactly. I guess converting ransom bits to a float would ever generate a machine exception. <mwette>The normal way to work would be using the tags to get to the data you want. <mwette>This is cdata, the backend for my ffi-helper. I have updated to support other back ends. I have prototypes for bytestructures and bstruct (minus bitfields right now).