Re: DIP1044---"Enum Type Inference"---Formal Assessment

2023-05-10 Thread Paul Backus via Digitalmars-d-announce

On Thursday, 11 May 2023 at 00:56:03 UTC, ryuukk_ wrote:

Don't you find this code easier to read and review?

```D
if (target.os == .Windows)
{
item("windows");
}
else
{
item("posix");
if (target.os == .linux)
item("linux");
else if (target.os == .OSX)
item("osx");
else if (target.os == .FreeBSD)
{
item("freebsd");
item("bsd");
}
else if (target.os == .OpenBSD)
{
item("openbsd");
item("bsd");
}
else if (target.os == .Solaris)
{
item("solaris");
item("bsd");
}
}
arrayEnd();
```


Honestly, not really. I've never looked at this part of DMD, and 
without context, I'd have no idea where the symbols `Windows`, 
`linux`, `FreeBSD`, and so on were coming from. Having it 
explicitly spelled out at the usage site--either via qualified 
names (`Target.OS.Windows`) or a local alias (`alias TOS = 
Target.OS`) makes it trivial to understand what's being referred 
to.


In fact, for this particular example, there are actually two 
enums in the DMD source code that these symbols could be coming 
from: `enum TargetOS` in `cli.d`, and `enum OS` in `target.d`. So 
you would have to scroll up and look at the imports to 
disambiguate.


Re: DIP1044---"Enum Type Inference"---Formal Assessment

2023-05-10 Thread ryuukk_ via Digitalmars-d-announce
I was reading DMD source code, case of repetition that adds 
nothing of value but useless reading strain



https://github.com/dlang/dmd/blob/999d835c1196eb993a99bb7f1c863da265a6b6c0/compiler/src/dmd/json.d#L843-L869


```D
if (target.os == Target.OS.Windows)
{
item("windows");
}
else
{
item("posix");
if (target.os == Target.OS.linux)
item("linux");
else if (target.os == Target.OS.OSX)
item("osx");
else if (target.os == Target.OS.FreeBSD)
{
item("freebsd");
item("bsd");
}
else if (target.os == Target.OS.OpenBSD)
{
item("openbsd");
item("bsd");
}
else if (target.os == Target.OS.Solaris)
{
item("solaris");
item("bsd");
}
}
arrayEnd();
```

what could be done to avoid the repetition?


Reduce the length of the repetition with a short alias?

```D
alias TOS = Target.OS;

if (target.os == TOS.Windows)
{
item("windows");
}
else
{
item("posix");
if (target.os == TOS.linux)
item("linux");
else if (target.os == TOS.OSX)
item("osx");
else if (target.os == TOS.FreeBSD)
{
item("freebsd");
item("bsd");
}
else if (target.os == TOS.OpenBSD)
{
item("openbsd");
item("bsd");
}
else if (target.os == TOS.Solaris)
{
item("solaris");
item("bsd");
}
}
arrayEnd();
```

Well, repetition is still there, now you got a short Type to type 
that doesn't mean anything without context, why is it needed? why 
do we need that noise? what problem does it solve?


We can use ``with()``? but why do i need a with here? target.os 
is self explanatory already, it's supposed to be type safe, it's 
a type safe enumeration, i should only care about the values, why 
now introduce an extra scope with extra indentation? it'd create 
more noise and now visual strain


Don't you find this code easier to read and review?

```D
if (target.os == .Windows)
{
item("windows");
}
else
{
item("posix");
if (target.os == .linux)
item("linux");
else if (target.os == .OSX)
item("osx");
else if (target.os == .FreeBSD)
{
item("freebsd");
item("bsd");
}
else if (target.os == .OpenBSD)
{
item("openbsd");
item("bsd");
}
else if (target.os == .Solaris)
{
item("solaris");
item("bsd");
}
}
arrayEnd();
```



Re: Beta 2.104.0

2023-05-10 Thread anonymouse via Digitalmars-d-announce
On Wednesday, 10 May 2023 at 12:34:00 UTC, Steven Schveighoffer 
wrote:


This reminds me of an LDC bug fixed recently. I bet DMD suffers 
from a similar problem: 
https://github.com/ldc-developers/ldc/issues/3864


-Steve


And it is. Just tried the workaround proposed (export 
MACOSX_DEPLOYMENT_TARGET=11) and it resolved the issue. Thank you.


-- anonymouse


Re: Beta 2.104.0

2023-05-10 Thread anonymouse via Digitalmars-d-announce

On Wednesday, 10 May 2023 at 10:22:23 UTC, jmh530 wrote:
mir-stat also doesn't include mac os as part of the test suite 
(mir-algorithm does). PRs are welcome.


Actually, it happens even when you don't import anything. As for 
PRs, I would if I could. Although I've been around the community 
for a while, I'm definitely the most unskilled member here. Just 
got ticked off at myself over the weekend and picked up my first 
stats book ever with the intent to build a solid foundation and 
gain the skills necessary to help out.


--anonymouse


Re: Beta 2.104.0

2023-05-10 Thread max haughton via Digitalmars-d-announce
On Wednesday, 10 May 2023 at 12:34:00 UTC, Steven Schveighoffer 
wrote:


This reminds me of an LDC bug fixed recently. I bet DMD suffers 
from a similar problem: 
https://github.com/ldc-developers/ldc/issues/3864


-Steve


`MACOSX_DEPLOYMENT_TARGET` fixed it for me recently when I was 
getting the "not aligned" problems with rosetta dmd on macos.


Re: Beta 2.104.0

2023-05-10 Thread Steven Schveighoffer via Digitalmars-d-announce



This reminds me of an LDC bug fixed recently. I bet DMD suffers from a 
similar problem: https://github.com/ldc-developers/ldc/issues/3864


-Steve


Re: Beta 2.104.0

2023-05-10 Thread FeepingCreature via Digitalmars-d-announce

On Tuesday, 2 May 2023 at 00:34:45 UTC, Iain Buclaw wrote:

This release comes with 11 major changes, including:

- In the standard library, `std.typecons.Rebindable` now 
supports all types


Tiny note of warning: `Rebindable` supports all types that it did 
not previously support, including structs. However, the previous 
`Rebindable` had a special logic where if you passed it an 
_array_, it would simply alias itself to `Unqual!ElementType[]`. 
So you cannot rely that if you write `Rebindable!T foo;`, that 
you can then do `foo.get`.


I'm trying to fix that, but it's a bit controversial. My main 
argument is that ~nobody used to use it anyway, so we may as well 
fix it now as it's actually becoming useful.


Re: Beta 2.104.0

2023-05-10 Thread jmh530 via Digitalmars-d-announce

On Wednesday, 10 May 2023 at 02:48:02 UTC, anonymouse wrote:

On Tuesday, 2 May 2023 at 00:34:45 UTC, Iain Buclaw wrote:
Glad to announce the first beta for the 2.104.0 release, ♥ to 
the 36 contributors.


A couple days ago I ran into an issue that was solved by 
https://issues.dlang.org/show_bug.cgi?id=23846 so I upgraded to 
this beta. I just initialized a dub project to try to use 
```mir.stat```


[snip]


Does it matter if instead of importing mir-stat you use 
mir-algorithm or std.math?


mir-stat also doesn't include mac os as part of the test suite 
(mir-algorithm does). PRs are welcome.