Can signatures be made simpler and error messages be made better?

Adolphus Greenholt melodygeorge178 at gmail.com
Mon Jul 12 05:03:16 UTC 2021


On Saturday, 12 June 2021 at 08:13:42 UTC, Ola Fosheim Grøstad 
wrote:
> One of the things I don't like about C++ is that signatures 
> often end up being complex. Sadly, D2's signatures are even 
> more complex (D1 had an edge on C++ there).
>
> Why not simply move "linting" information to a separate line 
> and keep the "first line" of function definitions clean.
>
> E.g. to require the return value, and c.x to have the same 
> lifetime:
> ```
> int myfunc(A a, ref T c)
> lifetime(return,c.x)
> {
>   body
> }
> ```
>
> Or introduce a new operator £ that takes the lifetime of an 
> object, which I think is even better:
>
> ```
> int myfunc(A a, B b, ref T c)
> require(£return==£a.x)
> {
>   body
> }
> ```
>
> This would also allow specifying destruction order
> ```
> require(£b < £a.x)
> ```
>
> Or are there things that needs to be expressed about life times 
> that cannot work with such a scheme?
>
> I also think a scheme like this should allow library authors to 
> give names to individual requirements and invariants.
>
> That would allow better error messages, maybe even custom error 
> handlers, e.g.:
>
> ```
>> invariant outofbounds { tests }
>> require lifetimes (…)
>> __interpret_compilation_error outofbounds (context) {
>    if (context.xyz such and such)
>    return "This failed because..."<a 
> href="https://www.mygiftcardsite.one/">My Gift Card Site</a>
> }
>
> ```

Electronic Signatures and Digital Signatures sound synonymous but 
More loosely, e-signatures are used to refer to any signature 
that is The existence of notaries was invented to help address 
these very valid concerns and can be


More information about the Digitalmars-d mailing list