Opt-in for including argument names in ABI

Seb seb at wilzba.ch
Thu Sep 17 14:12:13 UTC 2020


tl;dr: `pragma(mangle, withArgumentNames:true)` would be a way to 
tell the compiler to include the argument names in the ABI, s.t. 
overloads with different names can be resolved.

Why?

1) Provide implementations for different input formats
------------------------------------------------------

```
sin(deg: 90);
sin(rad: 0.5);
```

2) Allow for a smooth deprecation
---------------------------------


```
deprecated pragma(mangle, withArgumentNames:true) void snoopy(int 
dummy); // A
void snoopy(int width); // B

snoopy(dummy: 10); // A (-> deprecation message)
snoopy(width: 10); // B
snoopy(10); // B
```

Mangling would be roughly sth. like:

```
_D9app3fooFiQdummyZv // includes argument names
_D9app3fooFiZv // regular
```


This could potentially result in really names with many 
parameters, but I doubt it would be as bad as a few templated 
ranges (see e.g. 
https://dlang.org/blog/2017/12/20/ds-newfangled-name-mangling/).
However, if long names are a concern, solutions could be:

1) Let the user specify mangling himself, e.g.

```
deprecated pragma(mangle, withArgumentNames:{"dummy": "d"}) void 
snoopy(int dummy); // A
```

2) Let the user define a custom mangling postfix:

```
deprecated pragma(mangle, postfix:"dummy") void snoopy(int 
dummy); // A
```

3) Or build a hash of all arguments names.


What are your though on optionally allowing to include argument 
names into the ABI?


More information about the Digitalmars-d mailing list