April 12, 2023
On 4/12/2023 12:38 AM, Richard (Rikki) Andrew Cattermole wrote:
> On 12/04/2023 7:27 PM, Walter Bright wrote:
>> On 4/12/2023 12:11 AM, Richard (Rikki) Andrew Cattermole wrote:
>>> Unless proven otherwise, all memory is owned by the process not the thread and therefore is the default.
>>
>> Let's see if I understand:
>>
>>      int abc(int* p);
>>
>>      int sum(int[] a)
>>      {
>>          int sum = 0;
>>          abc(&sum);
>>          for (int i = 0; i < a.length; ++i)
>>              sum += a[i];
>>          return sum;
>>      }
>>
>> Your position is that `i` and `sum` should be shared variables? What if `abc(&sum)` passes `&sum` to a concurrent thread?
> 
> No, you have that backwards.
> 
> In both of those cases its owned by the thread. With @safe they would be scope, which is a partial implementation of 'owned by thread' checking.

Then I don't know what you mean by default being shared. And why would @safe influence this?


> A better example would be `a`. This is an argument, with an unknown memory lifetime or ownership, that should be shared implicitly even if it was marked scope.

Such implicit sharing means C semantics, where the compiler assumes that none of it is shared, and there are no protections and it's all up to the programmer to put in synchronization code where necessary.

You can actually do that now in D, just leave off the 'shared' annotations.
April 13, 2023
On 13/04/2023 5:06 AM, Walter Bright wrote:
>> In both of those cases its owned by the thread. With @safe they would be scope, which is a partial implementation of 'owned by thread' checking.
> 
> Then I don't know what you mean by default being shared. And why would @safe influence this?

Default being shared I mean in terms of equivalence of behavior and purpose of shared itself.

@safe influences it because of DIP1000 with scope, which gives memory a lifetime that is tracked across a thread.

>> A better example would be `a`. This is an argument, with an unknown memory lifetime or ownership, that should be shared implicitly even if it was marked scope.
> 
> Such implicit sharing means C semantics, where the compiler assumes that none of it is shared, and there are no protections and it's all up to the programmer to put in synchronization code where necessary.
> 
> You can actually do that now in D, just leave off the 'shared' annotations.

Exactly. You can leave it off and you have the same guarantees you have with shared being on (ignoring nosharedaccess as that is essentially turning it into atomic without any of the QoL stuff).

We can talk about this some other time perhaps at a BeerConf if you're on when I can talk. I do have a lot of things to talk about that are a bit exciting (and plenty of bugs like unresolved RTInfoImpl's with dmd)!
April 13, 2023

On Tuesday, 11 April 2023 at 12:21:01 UTC, Dmitry Olshansky wrote:

>

Thoughts?

One of the point of D type system is also to bring us native programmers to memory-safety (and purity), so I think the aspirational part of it shouldn't be discounted.

Like how D brought us to living with the GC.

While I'm not a fan of pure, shared, and constness, I can live with them and eventually change my mind. Over the years I'm using more @safe and pure. pure removal was discussed in last meeting and apparently it's still worth having it. Now if we had a @trustedPure or equivalent, that would be cool.

April 13, 2023
On 4/12/2023 10:50 PM, Richard (Rikki) Andrew Cattermole wrote:
> We can talk about this some other time perhaps at a BeerConf if you're on when I can talk. I do have a lot of things to talk about that are a bit exciting (and plenty of bugs like unresolved RTInfoImpl's with dmd)!

Ok. But I suggest writing down your thoughts, complete with examples and such. I have a hard time picturing just what your proposal is.
April 14, 2023
On 14/04/2023 7:38 AM, Walter Bright wrote:
> On 4/12/2023 10:50 PM, Richard (Rikki) Andrew Cattermole wrote:
>> We can talk about this some other time perhaps at a BeerConf if you're on when I can talk. I do have a lot of things to talk about that are a bit exciting (and plenty of bugs like unresolved RTInfoImpl's with dmd)!
> 
> Ok. But I suggest writing down your thoughts, complete with examples and such. I have a hard time picturing just what your proposal is.

- Remove ``shared(T)``
- Add ``atomic(T)`` so that ``a++;`` works, rather than a failure mode (like -preview=nosharedaccess introduces, or having to cast away shared).

Basically everything I have to say is rather academic in nature, not very practical, there are arguments both for and against everything practical I can suggest.

From my reading of research papers regarding coroutines, pretty much all the concurrency primitives that we know of today for PL design was already invented by 1976 with an implementation; this is very much an open problem still.

I really enjoyed this particular passage from one paper as it shows just how little things have changed in 50 years:

> However, this paper also ignores many serious problems. The most serious is that it fails to suggest any proof method to assist in the development and verification of correct programs.

April 14, 2023

On Tuesday, 11 April 2023 at 12:21:01 UTC, Dmitry Olshansky wrote:

>

https://olshansky.me/posts/d-biggest-mistake/

So you were bitten by abuse of qualifiers and now want a language that doesn't let you abuse qualifiers? I write D2 code without abusing qualifiers and I'm perfectly fine.

April 14, 2023
On Tuesday, 11 April 2023 at 12:21:01 UTC, Dmitry Olshansky wrote:
>
> Thoughts? I'm going to do D1.5 for myself but wanted to know if anyone feels the same.

Whether forwards or backwards, someone should first write a paper/article/whatever, exploring 'the darker side of D'.

We need a 'Markku Sakkinen' like paper (he wrote one back in the early 90s called "The darker side of C++ revisited".

I expect some people over at Micrsoft had a good read of that paper before setting off to create C#.

My guess is, his view has still not changed:

"..taking the weakly typed and weakly structured language C as a base has become an irremediable handicap."

April 14, 2023

On Tuesday, 11 April 2023 at 13:32:53 UTC, Dmitry Olshansky wrote:

>

On Tuesday, 11 April 2023 at 13:08:33 UTC, Adam D Ruppe wrote:

>

On Tuesday, 11 April 2023 at 12:21:01 UTC, Dmitry Olshansky wrote:

>

Interestingly enough if we simple disable semantic check for transitive qualifiers relegating them to pure annotations to be

I've actually thought about making a -betterD switch that disables most the annotations, turning them to no-ops.

But your first sentence:

>

Make no mistake - thread-local by default is great!

Gonna go ahead and disagree with that, the thread local by default I think is a mistake now. It causes as many problems as it solves.

If needed we may introduce __threadlocal, what should be the default is a question of compatibility with current D2.

With choose, for a new keyword, something very ugly?

I don't want to write ugly code, let that to C++ and Rust

tls by default is a huge mistake, i support adam's suggestion

Please, make good and simple syntax, anything that starts with __ is ugly

The only reason i personally use const is to be able to pass things either by reference or to avoid GC allocation

void pass(const scope int[] a)
pass([1,2,3])

I see code in phobos that abuse everything, then abuse workaround

return () @trusted { return getAddressInfoImpl(node, service, &hints); }();

https://github.com/dlang/phobos/blob/01a12f919e624b3f7b73171ae03d4d0a91a0b87b/std/socket.d#L916-L943

OOP, bloatware, syntax-uglifier people designing stuff should be put to jail

If D3 or D1.5 every happen, hopefully that kind of stuff disappears, 0 compatibility with that code

April 14, 2023

On Friday, 14 April 2023 at 18:33:50 UTC, ryuukk_ wrote:

>

The only reason i personally use const is to be able to pass things either by reference or to avoid GC allocation

I think that const as function parameter designation is a mistake in computer science history. Swift has done this more right. ALL parameters are immutable, if you write to a parameter then the compiler will create a copy of it on the callee stack frame (not caller stack frame as often today, but it is also a definition who it belongs to).

The copy parameter by default is one of these mysteries to me that is adopted by many languages.

I actually think that writes to parameters (that are not references) should be disallowed. If you want to write to it you should make a copy of it by assignment (ie. manually copy it).

April 15, 2023

On Friday, 14 April 2023 at 18:33:50 UTC, ryuukk_ wrote:

>

On Tuesday, 11 April 2023 at 13:32:53 UTC, Dmitry Olshansky wrote:

>

[...]

With choose, for a new keyword, something very ugly?

[...]

One word - backward compatibility. Keywords with __ are reserved by the compiler.

>

[...]

Maybe.

>

[...]

It will be an experiment, a backwards compatible one.

>

disappears, 0 compatibility with that code