4 ms·
There was an interesting aproach to this, in an experimental language some time ago fn f1 (x, y) #-> // Use C calling conventions fn f2 (x, y) -> // use
by vrotaru 2y ago
There was an interesting aproach to this, in an experimental language some time ago
fn f1 (x, y) #-> // Use C calling conventions
fn f2 (x, y) -> // use fast calling conventions
The first one was mostly for interacting with C code, and the compiler knew how to
call each function.
- dgellow 2y agoIs it similar to Zig’s callconv keyword?
- vrotaru 2y agoGuess so. Unfamiliar with Zig. The point is that not a "all or nothing" strategy for a compilation unit. Debugger writers may not be happy, but maybe lldb supports all conventions supported by llvm.
- int_19h 2y agoDebugger writers have dealt with different calling conventions for decades. The notion predates C even. They can handle it just fine.
- magicalhippo 2y agoDelphi, and I'm sure others, have had[1] this for ages: When you declare a procedure or function, you can specify a calling convention using one of the directives register, pascal, cdecl, stdcall, safecall, and winapi. As in your example, cdecl is for calling C code, while stdcall/winapi on Windows for calling Windows APIs. [1]: https://docwiki.embarcadero.com/RADStudio/Sydney/en/Procedures_and_Functions_(Delphi) https://docwiki.embarcadero.com/RADStudio/Sydney/en/Procedur...
- pjmlp 2y agoSince the Turbo Pascal days actually.
- magicalhippo 2y agoI was pretty sure it had it, I just couldn't find an online reference.
- pjmlp 2y agoTurbo Pascal for Windows v1.5, on Windows 3.1, the transition step before Delphi came to be.
- magicalhippo 2y agoAh, yeah that makes sense. Thanks!
- JonChesterfield 2y agoC for example does this, albeit in compiler extensions, and with a longer tag than #.
- IshKebab 2y agoTerrible taste. Why would you hide such an infrequently used feature behind a single character? In this case you should absolutely use a keyword.