On Tue, 27 Aug 2024 at 04:06, Timon Gehr via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
On 8/26/24 03:16, Manu wrote:
> On Mon, 26 Aug 2024, 07:56 Timon Gehr via Digitalmars-d, <digitalmars-
> d@puremagic.com <mailto:digitalmars-d@puremagic.com>> wrote:
>
>     On 8/25/24 13:06, Dom DiSc wrote:
>      >
>      > But I fully agree, this should be replaced by true trusted
>     blocks, the
>      > sooner the better.
>
>     You cannot have a "trusted block". It just does not work. The interface
>     to any trusted thing has to be clearly delineated.
>
>
> Well it obviously does work in some sense, because it's the de facto
> standard that people generally expect in numerous languages.
> ...

No, it's laid out differently.

> People are going to have it one way or another; whether it's a
> ridiculous hack like `()@trusted { ... }();` or otherwise. It's what
> other languages with this sort of thing do.
> ...

No, e.g. Rust just does not distinguish trusted and untrusted safe
functions.

Rust does:

unsafe {
  my_unsafe_code;
}

Perfect.

In C#:

unsafe {
  my_unsafe_code;
}

Perfect.

> We don't have a better offering to motivate people to deviate from their
> patterns.
>
> Resisting that degrades D.
>

It should not be called "trusted" then.

Absolutely, 100%.

Fundamentally, I agree on the substance (though probably, even better
designs are possible). However, let's not invent another idiosyncratic
keyword now.

What 'another keyword' are you talking about?
I think the problem that you're pointing at here is that we're using `@trusted` as a hack as if it meant what we all want; `unsafe` as in other languages.
I understand that D's 'concept' is not quite like that, but nobody ever wanted the definition that D presents that I'm aware of, and all we want is an unsafe block.

I don't see any reason for @trusted... we only need @safe to invoke the escape analysis, and then the ability to write an unsafe block inside a function; which people are abusing the @trusted keyword to achieve. Why is the design we have better than the established designs?