@ctfeonly

Johannes Pfau nospam at example.com
Thu Dec 7 21:50:31 UTC 2017


Am Thu, 07 Dec 2017 01:32:35 -0700
schrieb Jonathan M Davis <newsgroup.d at jmdavisprog.com>:

> 
> In the vast majority of cases, when a function is used for CTFE, it's
> also used during runtime. So, in most cases, you want to ensure that
> a function works both with CTFE and without, and in those cases
> something like @ctfeonly wouldn't make any sense. In my experience,
> pretty much the only time that something like @ctfeonly would make
> any sense would be with a function for generating a string mixin.

Not only string mixins. When programming for microcontrollers you want
to do as much in CTFE as possible, as space for executable code is
severely limited. So you may for example want to use CTFE to generate
some lookup tables and similar stuff. Basically the whole
'initialize a variable / constant using CTFE' idiom benefits a lot from
such an attribute.

-- Johannes



More information about the Digitalmars-d mailing list