IRC channel logs
2025-12-31.log
back to list of logs
<mwette>Is #:optional faster than #:key? I assumed yes, but maybe the compiler can resolve all the keyword arguments at compile time. <mwette>by resolve, I mean assign to the right slot somehow. <mwette>dthompson: bstructs does not support anonymous structs and unions. Correct? <dthompson>mwette: #:optional and #:key are equally fast if the argument list is known at compile time. if the procedure being called is from another module then iirc it will depend on if cross-module inlining occurs or not. <dthompson>mwette: and bstructs supports anonymous structs/unions. <dthompson>consider this contrived type: (define-bstruct <foo> (union (foo (struct (bar int))) (baz (union (bloop double) (zort (* void)))))) <dthompson>there is an inner struct and union that are not bound to any top-level names <mwette>In C, this is an anonymous struct: struct foo { int a; struct { int b; }}; <mwette>So , struct foo z; ...; c = z.a + z.b; <mwette>I meant "anonymous" in the scope of C language. <dthompson>ah, you show it. I guess I don't really understand the point of this. I've never used these in all my time using C. <dthompson>does it just change how alignment works or something? <mwette>dthompson: the point is to save level of selection with unions/struct mixes: struct foo { int a; union { bar_t b; baz_t c; }; } z; z.a = 1; get(z.a, &z.b); put(z.a, &z.c); <dthompson>ah okay, then yeah I don't currently support this but it could be added. <dthompson>anonymous union makes a lot of sense. anonymous struct I still don't really get. <dthompson>is struct { int a; struct { int b; }; } equivalent to struct { int a; int b; } ? <mwette>yes. I can save in union { struct { } } also <dthompson>this sounds kinda fun to implement. I'll see what I can do. <lechner>Hi, is there a way to tune readline in the REPL to consider past multi-line entries as one unit, i.e. scroll through them backwards in one piece instead of line-by-line? <old>anonymous structs are often useful when implementing an ABI and you want to extend it. You define such struct like so: <old>struct { unsigned long version; struct { int field1; char extension[MAX_EXTENSION_SIZE]; } __attribute__((aligned(sizeof(char *)))) } <old>ofc you could just use a named struct inside. Before the extension existed, `u' and `s' where used a member name for that <mwette>old: thanks, didn't know where it came from <old>I think it's plan 9 C that introduced anonymous struct first