On Thursday, 7 December 2017 at 01:21:11 UTC, Nicholas Wilson
wrote:
I can add this to LDC pretty easily, but does anyone else have
a use for this (e.g. shrinking binary sizes for mixin heavy
codebases) and would benefit having this as a standard thing?
I've thought about this in the past, but never really pursued it
much to see if there are already existing facilities in the
language to accomplish what I want.
I want to enforce that a method is only used at compile time.
That is I want either the compiler or the linker to throw an
error if I've accidentally used a function at runtime when I only
intended it to be used at compile-time. Also, I want the
compiler to let me know if my intended-for-compile-time-only
function cannot be used at compile-time because I mistakenly made
it dependent on something that is only available at runtime.
That being said, I want D's features to carry their weight. I
would first like to prove that facilities don't already exist or
that existing facilities are too cumbersome to accomplish said
goal before adding such a feature.
Also, my primary motivation for using D is so I can program
resource-constrained microcontrollers in a more fun and
convenient language than C/C++. I've definitely encountered
code-size problems in D, but they were mostly due to the
compiler's unnecessary coupling to the runtime, and the way the
compiler generated code as the linker couldn't prove that the
code was dead (Exhibit A:
https://issues.dlang.org/show_bug.cgi?id=14758). I don't yet see
how @ctfeonly would help with that.
Mike
- Re: @ctfeonly Mike Franklin via Digitalmars-d
-