[Info-vax] Viable versus ideal programming languages
Dan Cross
cross at spitfire.i.gajendra.net
Fri Mar 25 08:50:29 EDT 2022
In article <t1hqgd$c77$1 at dont-email.me>,
Simon Clubley <clubley at remove_me.eisner.decus.org-Earth.UFP> wrote:
>On 2022-03-23, Dan Cross <cross at spitfire.i.gajendra.net> wrote:
>> In article <t1fpab$v69$1 at dont-email.me>,
>> Simon Clubley <clubley at remove_me.eisner.decus.org-Earth.UFP> wrote:
>>>It seems that everyone falls back to C interface mode when trying
>>>to export functions for use by another language. A quick look around
>>>seems to show that Rust does the same.
>>
>> I suppose that if one's definition of a well-defined ABI is what
>> you are calling a "C interface mode" that's true, but most ABIs
>> are language-independent.
>>
>
>It's at this point that I mention many languages directly call this a
>C interface mode, including in the syntax that they provide to achieve
>this... :-)
Again, using the calling convention and structure layouts is
still qualitatively different than using C. The ABI gives you a
set of guarantees that you can program to, not the language; the
language at that point is irrelevant.
Further, for instance the System V ABI for x86_64 gives some
flexibility for languages with richer semantics than C. For
example, I see no reason why a language could not represent a
pair type as a small structure of two elements. Provided those
elements each fit within 64 bits, I imagine that such a tuple
could be returned in two registers (%rax, %rdx); nothing in the
ABI seems to preclude that, though it's clearly not something
one can do in C, as C doesn't support tuples.
- Dan C.
More information about the Info-vax
mailing list