4 ms·
Given that we already have the concepts of exported entry points and extern in C, this should already be possible to a certain extent. The only other thing whic
by supriyo-biswas 3y ago
Given that we already have the concepts of exported entry points and extern in C, this should already be possible to a certain extent. The only other thing which needs to happen is that ELFs should have the concept of exported data structures, so while "URL" might not be a defined structure in the OS, something like curl can provide it.
Too bad we're stuck with UNIX/POSIX model - you could even take this idea of exported data structures and have the terminal represent data in the preferred users format instead of having tools like jq.
- sph 3y agoWe have dlopen and we can list exported symbols, but we have no information about a function's arguments, ABI and calling convention, so it's pretty much impossible to turn UNIX into a fully late-bound and interactive REPL. Same issue with syscalls. The only way is starting from scratch, with a novel approach and programming model.
- overboard2 3y agoOr you could add some more sections to object files. Just make clang and/or gcc export function signatures, structs, enums, and typedefs
- actionfromafar 3y agoI wonder if one of the existing interpreted languages (python/javascript/ruby/whatever) could maintain a patch for llmv/gcc which did exactly that and in the process make the most incredible seamless integration ever between itself and C (and also C++ now with its ABI stabilizing!)
- supriyo-biswas 3y agoWhy can’t you add additional data about the data types of parameters in a separate ELF section? It would be only used by programs that look for it like a specially designed shell. The calling convention can be assumed to be the same as used by the OS/arch combination.
- sph 3y agoYou could, but you then have to recompile the world with this new information stored as a ELF header or something, and good luck if the library is not written in C (so it has its own conventions, ABI, memory model and binary format) I'm talking about the status quo today, not how you can improve in a perfect world where everybody adopts a better way of doing things. Implementing an half-baked Smalltalk layer on top of UNIX will not turn UNIX into a Smalltalk environment.
- Tyr42 3y agoPowerShell?
- int_19h 3y agoWith CLR assemblies, you get rich embedded metadata including UDTs like structs and unions, and architecture-portable JIT-compiled bytecode to boot - both sufficient to map the entirety of C data and execution model.