October 05, 2021
On Tuesday, 5 October 2021 at 01:11:22 UTC, H. S. Teoh wrote:
> ...
> This, my friend, is the power of DbI.  This example, of course, only scratches the surface of what you can do with DbI, but I'll leave it up to you to explore the rest. :-D

I'm not the OP but I'd like to say thank you very much for taking time and writing this, it gave me a wish to write some code and play with this idea.

Matheus.
October 05, 2021

On Tuesday, 5 October 2021 at 01:11:22 UTC, H. S. Teoh wrote:

>

The basic idea is very simple (but the results are powerful indeed).
......

Good Article,I have translated into Chinese,link here

October 04, 2021
On 10/4/21 5:11 PM, Paul Backus wrote:

> One place DbI is used a lot is in `std.range`.

Even before hearing the term Design by Introspection, I was showing Phobos algorithms to explain 'static if's usefulness when I was presenting D to mostly C++ programmers.

We imagine iota, map, etc. algorithms returning result types implementing the InputRange interface. And it makes sense: iota generates elements in order, map produces results in order, etc.

However, because 'iota' is capable of implementing opIndex, map can do so as well. So, the whole range object is usable as a RandomAccessRange:

import std.range;
import std.algorithm;

void main() {
  auto r = 10.iota.map!(i => i * 2);

  if (r[$/2] > r[0]) {  // This works!
    // ...
  }
}

Ali

P.S. Yes, iota provides opDollar as well, and so can map, etc.

October 04, 2021
On 10/4/2021 5:15 PM, Ali Çehreli wrote:
> That is exactly the case! (I wrote my response to H. S. Teoh before reading your post.)

Hmm, I should have read your post first!
October 05, 2021

On Monday, 4 October 2021 at 17:13:58 UTC, russhy wrote:

>

With D is get insanely quick iteration time, my project rebuilds in 0.7 seconds (full clean rebuild)

None of the existing natively compiled language can offer this, NONE!!

This is something people forget to mention, but this is very valuable

Delphi, Eiffel and Common Lisp.

October 05, 2021

On Monday, 4 October 2021 at 22:15:33 UTC, Walter Bright wrote:

>

This is plasticity, the opposite of brittleness.

To me, that's just another case of abstraction. D's '.' abstracts the details of '.' and '->'. That naturally leads to plasticity - ability to swap concrete things without affecting the abstract interface.

October 05, 2021
On Monday, 4 October 2021 at 20:42:06 UTC, David Gileadi wrote:
>
> This message was a reference type containing protected values.

Huh, what did you try to do? I tested the snippet before posting and for me, it worked.
October 05, 2021
On Monday, 4 October 2021 at 22:15:33 UTC, Walter Bright wrote:
>
> What are your experiences with this?

Pretty much.

At a superficial level D is a language that says "yes" to most things.
Can I have that feature? Yes.
Can I move this piece of code there? Yes.
Can I reuse that C/C++ code? Yes, you can.

So that's the "liberal" part, the low mental-friction that makes you do things.
Bounds check and variable initializaton participate in that, since you win precious time.

Because the first task of any software is to exist and be useful, at a reasonable cost.
And that's great because that's where most program need to stop, as garbage internal tools or experiments. So D has attracted a lot of lonewolves types - for better and worse - and it shapes the culture.

The other parts are the restrictions, you can add qualifiers to increase quality, and the language will gently remind you that safety is important. D strives to strike a balance for large-scale wasteland programming. It is the mature C++ that depart from the "MAX POWER" ethos to give instead actionnable power that you don't come to regret later. Some features you really appreciated in a hellish maintenance context.

So D strikes me as a thing of balance, its values are somewhat "bring your own values" and of course the marketing message isn't hitting as hard and fast as imbalanced languages.

October 05, 2021
On 10/5/21 6:17 AM, Dukc wrote:
> On Monday, 4 October 2021 at 20:42:06 UTC, David Gileadi wrote:
>>
>> This message was a reference type containing protected values.
> 
> Huh, what did you try to do? I tested the snippet before posting and for me, it worked.

Sorry, it was my poor attempt at wordplay. Please ignore.
October 05, 2021

On Tuesday, 5 October 2021 at 01:33:45 UTC, Paul Backus wrote:

>

Of course, this is not really true in practice. In languages that don't support DbI, what actually happens is that you do not write all 2^N customized versions of the code. Instead, you give up on having individual customized versions for each use-case and write a single version based on some lowest-common-denominator abstraction. What you really lose here are the benefits to performance and expressiveness that come from having individually-customized versions of your code.

What really happens in other languages is either proliferation of code (copy/paste) or branching at runtime (if cascades, booleans or switch/case).
The D way may end up adding more code, but code with less branching.