December 14, 2021

On Tuesday, 14 December 2021 at 11:14:03 UTC, zjh wrote:

>

On Tuesday, 14 December 2021 at 09:50:15 UTC, bauss wrote:

>

It's ultimately D's downfall that features are too complex.

Is d as complex as C++?

There are around 90 keywords in C++ 20, from which 11 are alternative names for operators. There are rare cases when a keyword in C++ can have a different meaning depending of the context.

We have 100 keywords in D and many of them have multiple meanings (scope, static, if, is, in, out, const, do, enum, return)

C++ is not necessary a complex language, STL usage and associated idioms makes it complex. If you look at some C++ code before Stepanov stepped in, it looks really nice and comprehensible :)

December 14, 2021

On Tuesday, 14 December 2021 at 11:15:02 UTC, WebFreak001 wrote:

>

ah right you mean for the built-in istring usage in the compiler it needs to be implemented.

I don't think it's such a big problem though, as the phobos implementation would also just be: (a little simplified)

auto text(istring...)(istring s) if (isIString!istring)
{
    return text(s[1 .. $]); // removes special __header, just concatenate rest
}

My point is, if the compiler has to implement istring processor anyway, why not make it a language feature:

//look ma no imports
int bottleCount = 99;
string str = i"$(bottleCount) bottles on the wall".stringof;
assert(str == "99 bottles on the wall");
December 14, 2021

On Tuesday, 14 December 2021 at 12:41:27 UTC, Ogi wrote:

>

On Tuesday, 14 December 2021 at 11:15:02 UTC, WebFreak001 wrote:

>

ah right you mean for the built-in istring usage in the compiler it needs to be implemented.

I don't think it's such a big problem though, as the phobos implementation would also just be: (a little simplified)

auto text(istring...)(istring s) if (isIString!istring)
{
    return text(s[1 .. $]); // removes special __header, just concatenate rest
}

[...]

//look ma no imports
int bottleCount = 99;
string str = i"$(bottleCount) bottles on the wall".stringof;
assert(str == "99 bottles on the wall");

ah yeah I could see that work. I think it would only work at compile time though if you use .stringof (otherwise you need a runtime function - like text - that allocates the memory somehow, which is none of the compiler's business)

>

My point is, if the compiler has to implement istring processor anyway, why not make it a language feature:

Having the text"..." syntax IS a language feature, you just need an implementation, which phobos provides and is bundled with every distribution of D. (have it in std.conv or add it to object if you aren't interested in the other proposal to have default imports specified as compiler flags)

December 14, 2021

On Tuesday, 14 December 2021 at 11:14:03 UTC, zjh wrote:

>

On Tuesday, 14 December 2021 at 09:50:15 UTC, bauss wrote:

>

It's ultimately D's downfall that features are too complex.

Is d as complex as C++?

If we are honest, it probably similar at this point.

December 14, 2021

On Tuesday, 14 December 2021 at 12:29:57 UTC, rumbu wrote:

>

On Tuesday, 14 December 2021 at 11:14:03 UTC, zjh wrote:

>

On Tuesday, 14 December 2021 at 09:50:15 UTC, bauss wrote:

>

It's ultimately D's downfall that features are too complex.

Is d as complex as C++?

There are around 90 keywords in C++ 20, from which 11 are alternative names for operators. There are rare cases when a keyword in C++ can have a different meaning depending of the context.

We have 100 keywords in D and many of them have multiple meanings (scope, static, if, is, in, out, const, do, enum, return)

C++ is not necessary a complex language, STL usage and associated idioms makes it complex. If you look at some C++ code before Stepanov stepped in, it looks really nice and comprehensible :)

The saying about C++ has always been that it's a nice language if you stick to a subset of its features. The problem is that everyone needs a different subset. I personally don't have a problem with D's complexity since it's easy to ignore most of the language. The other problem I had with C++ was the need to be a language lawyer. You really have to understand the complete specification of the features you're using to avoid having it blow up on you. You can't easily program in C++ without a shelf full of Scott Myers books. I don't feel that way with D.

December 15, 2021
On 10/12/2021 10:06 AM, WebFreak001 wrote:
> What do you think? Would this be essential for interpolated string adoption in user code or be useless?

I am against it.

Due to it marrying a memory management+formatting strategy to the language.

One way to do this is to support ``Identifier Token`` UFCS pattern which would allow this to "just work" except generically.

So if you want to get data from your database?

auto data = dbcon.sql`SELECT * FROM table where field = "%value$arg"`;

That could pass it in as an interpolated string.

However, that could be extremely confusing to the user as this is a function call, which takes a string... yet its actually something very different. Like why doesn't adding the brackets allow for that to work? ext. ext.

One reason I would like this pattern even though I don't think we should ever have it is so that I can have hex strings back. Super useful during code generation and table generation for large data sets (now days I've found that std.base64 does an excellent job at this, even with a little bit of fluff).

ubyte[] data = hex"AABBCC"; // ok
December 14, 2021

On Tuesday, 14 December 2021 at 09:50:15 UTC, bauss wrote:

>

While I completely understand the proposal then I think it's the wrong approach as it adds an infinite amount of complexity for something that barely solves any issues that exist today.

+1 I tuned out the whole discussion when I saw where it was going. It'd be nice to introduce features that improve the language without worrying about covering every possible edge case that could come up. Syntax, simplicity, and convenience are valuable.

December 14, 2021

On Tuesday, 14 December 2021 at 11:40:46 UTC, Ola Fosheim Grøstad wrote:

I'm always using /std:latest in C++.
and 2.098 in d.

December 14, 2021

On Tuesday, 14 December 2021 at 12:55:30 UTC, WebFreak001 wrote:

>

I think it would only work at compile time though if you use .stringof

Ouch, you’re right, we can’t reuse stringof for this. Some other name then, like str or something.

>

otherwise you need a runtime function - like text - that allocates the memory somehow, which is none of the compiler's business

YAIDIP requires istring processing both at compile-time (mixin and static assert) and runtime (regular assert and pragma(msg)).

December 14, 2021

On Tuesday, 14 December 2021 at 12:29:57 UTC, rumbu wrote:

>

C++ is not necessary a complex language, STL usage and associated idioms makes it complex. If you look at some C++ code before Stepanov stepped in, it looks really nice and comprehensible :)

C++ has the baggage of the past(Strengths/weaknesses), so is D.
If d strengthen the binding with C++ and port the C++ popular library, it must be very good.