Annotation of functions
jmh530
john.michael.hall at gmail.com
Tue Feb 20 14:22:35 UTC 2018
On Tuesday, 20 February 2018 at 12:15:57 UTC, psychoticRabbit
wrote:
> I've noticed that Go and Rust annotate functions.
>
> func (in go)
> fn (in rust)
>
> I was kind of wondering why they made that choice, given
> compilers in many languages do not.
>
> Would this be a useful feature in D?
>
> Everything else seems to have an annotation (e.g structs,
> classes.) So why not functions?
>
> What are people's thoughts about it?
>
> My first thought is to make it an optional annotation, for the
> benefit of developing source code analysis tools that can 'more
> easily' find functions in source code (i.e. The D compiler can
> just strip it off and do nothing with it.). That way
> programmers that see no benefit in it, don't have to deal with
> it.
If you want to annotate your functions (rather than someone
elses), you could do something like below. Ideally this would
also include a compile-time check that foo is a function. Maybe
use Atila's concepts library?
enum Function;
@Function void foo() { }
void main()
{
}
More information about the Digitalmars-d
mailing list