|
|
Log in / Subscribe / Register

Perl-preprocessed C in the 21st Century

Perl-preprocessed C in the 21st Century

Posted Jan 15, 2026 13:20 UTC (Thu) by kleptog (subscriber, #1183)
In reply to: Perl-preprocessed C in the 21st Century by paulj
Parent article: The State of OpenSSL for pyca/cryptography

Looks to me they got Second System Syndrome badly.

Not that the original OpenSSL API was any good, but it sure looks like they went way overboard. If you want keyword arguments, don't use C. Wrong tool for the job.


to post comments

Perl-preprocessed C in the 21st Century

Posted Jan 15, 2026 14:37 UTC (Thu) by paulj (subscriber, #341) [Link]

Well... you actually can do keyword arguments in C reasonably easily and well (for a reasonable number of arguments), with no need to resort to expensive key-val that require runtime lookups of key objects. Just use a struct for keyword arguments, and create an anonymous struct at the caller to pass in the keyword args via the struct - unspecified kw args will be the type's default (e.g. 0 or NULL).

#include <stdio.h>

struct bar_args {
int x;
int y;
};

int bar(int z, struct bar_args args) {
return z * args.x + args.y;
}

int main (const int argc, const char *argv[]) {
printf("1 2 (0) %u\n", bar (2, (struct bar_args) { .x = 2}));
printf("1 2 3 %u\n", bar (2, (struct bar_args) { .x = 2, .y = 3}));
return 0;
}

Perl-preprocessed C in the 21st Century

Posted Jan 15, 2026 15:05 UTC (Thu) by willy (subscriber, #9762) [Link]

I was reminded of https://thedailywtf.com/articles/the_inner-platform_effect -- when you're layering your own programming language on top of the real programming language, you're definitely doing it wrongly.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds