Why is D unpopular?
Walter Bright
newshound2 at digitalmars.com
Sun May 1 06:48:42 UTC 2022
On 4/30/2022 10:17 PM, Ola Fosheim Grøstad wrote:
> My point was that it did propose CTFE,
Nope. It proposed more syntax for something else. I wasn't sure what, as the
examples and text apparently needed the verbal part of the presentation to make
sense. I don't know what "metacode injection" is or what it has to do with CTFE.
> and the presentation states that they had
> a prototype compiler extension for it, back in 2003.
It says "partially implemented", not a prototype. It also seems to have nothing
in common with Bjarne's proposal 4 years later.
> D also makes some unsound assumptions by assuming that the hardware you compile
> on is giving the same answer as the hardware you execute on That can give
> surprising results, bugs that are nigh impossible to pinpoint, because you don't
> get them on your development machine. Are you really sure you want that?
Are you sure D's CTFE does that? (CTFE doesn't allow unsafe code, for example.)
Are you sure C++'s does not? D is much more portable between systems than C++
is, in particular things like the sizes of types.
> Thankfully consteval gives you full control over what happens when.
That's the C++ rationale for consteval. But D allows 100% control over whether
CTFE is run or not. consteval is completely unnecessary. It's simple - CTFE is
run if otherwise the compiler would give an error message that it cannot resolve
an expression at compile time. For example,
void test()
{
enum e = foo(); // runs foo() at compile time
auto f = foo(); // runs foo() at run time
}
------
CTFE is conceptually a no-brainer. Run a function at compile time. That's it.
Neither Daveed's nor Bjarne's proposals do that. Zero new syntax is necessary.
More information about the Digitalmars-d
mailing list