Thread overview
version as an expression?
Sep 08, 2022
ryuukk_
Sep 11, 2022
TheGag96
Sep 11, 2022
ryuukk_
Sep 11, 2022
ryuukk_
Sep 12, 2022
Nick Treleaven
Sep 12, 2022
ryuukk_
Sep 12, 2022
Tejas
Sep 12, 2022
ryuukk_
Sep 12, 2022
ryuukk_
September 08, 2022

Currently, i am doing this,( wich sucks

version(Windows)
    alias socket_t = size_t;
else
    alias socket_t = int;

I'd prefer to be able to do:

alias socket_t = version(Windows) size_t else int;

And better, if we had pattern matching and some builtin information available at compile time:

alias socket_t = switch (builtin.target.os) {
    .windows => size_t,
    else     => int
};

Why i hate the current way of doing it, but i feel it'll be available in a distant future unfortunately:

  • nothing will tell me if i forgot to implement an alias for a target until i compile for that target
  • i repeat the name of the alias N times
September 11, 2022

On Thursday, 8 September 2022 at 21:15:18 UTC, ryuukk_ wrote:

>

(snip)

Well, for now, there's at least this hack using a struct with a static opDispatch. I use it in some places in a project of mine.

September 11, 2022

On Sunday, 11 September 2022 at 05:38:44 UTC, TheGag96 wrote:

>

On Thursday, 8 September 2022 at 21:15:18 UTC, ryuukk_ wrote:

>

(snip)

Well, for now, there's at least this hack using a struct with a static opDispatch. I use it in some places in a project of mine.

It doesn't work with alias

September 11, 2022

Your trick is very clever btw, thanks for sharing!

September 12, 2022

On Sunday, 11 September 2022 at 21:38:51 UTC, ryuukk_ wrote:

>

On Sunday, 11 September 2022 at 05:38:44 UTC, TheGag96 wrote:

>

On Thursday, 8 September 2022 at 21:15:18 UTC, ryuukk_ wrote:

>

(snip)

Well, for now, there's at least this hack using a struct with a static opDispatch. I use it in some places in a project of mine.

It doesn't work with alias

import std.traits;
alias A = Select!(isVersion("Windows"), WinType, PosixType);
September 12, 2022

On Monday, 12 September 2022 at 10:02:48 UTC, Nick Treleaven wrote:

>

On Sunday, 11 September 2022 at 21:38:51 UTC, ryuukk_ wrote:

>

On Sunday, 11 September 2022 at 05:38:44 UTC, TheGag96 wrote:

>

On Thursday, 8 September 2022 at 21:15:18 UTC, ryuukk_ wrote:

>

(snip)

Well, for now, there's at least this hack using a struct with a static opDispatch. I use it in some places in a project of mine.

It doesn't work with alias

import std.traits;
alias A = Select!(isVersion("Windows"), WinType, PosixType);

Sorry but i refuse to touch phobos, specially std.traits, i want my compile to remain fast

September 12, 2022

On Monday, 12 September 2022 at 10:26:40 UTC, ryuukk_ wrote:

>

On Monday, 12 September 2022 at 10:02:48 UTC, Nick Treleaven wrote:

>

On Sunday, 11 September 2022 at 21:38:51 UTC, ryuukk_ wrote:

>

On Sunday, 11 September 2022 at 05:38:44 UTC, TheGag96 wrote:

>

[...]

It doesn't work with alias

import std.traits;
alias A = Select!(isVersion("Windows"), WinType, PosixType);

Sorry but i refuse to touch phobos, specially std.traits, i want my compile to remain fast

Weren't you copy pasting stuff that you needed? Why can't you do that with this as well?

September 12, 2022

On Monday, 12 September 2022 at 10:39:20 UTC, Tejas wrote:

>

On Monday, 12 September 2022 at 10:26:40 UTC, ryuukk_ wrote:

>

On Monday, 12 September 2022 at 10:02:48 UTC, Nick Treleaven wrote:

>

On Sunday, 11 September 2022 at 21:38:51 UTC, ryuukk_ wrote:

>

On Sunday, 11 September 2022 at 05:38:44 UTC, TheGag96 wrote:

>

[...]

It doesn't work with alias

import std.traits;
alias A = Select!(isVersion("Windows"), WinType, PosixType);

Sorry but i refuse to touch phobos, specially std.traits, i want my compile to remain fast

Weren't you copy pasting stuff that you needed? Why can't you do that with this as well?

My initial request was: "use version as an expression"

We are bike-shedding to a point where "just use a template from std bro" is what people are telling me to do instead

Where will i put all the files i copy, do i have to do that for every projects i will create

You can understand that that's not the path i wanted to take when i created this post, i expect language improvement

Same story with the .Enum thing i proposed few months ago, if i made it it's not to accept having to use mixing everywhere bellow my enums bloating the global scope

I loose hope every posts

September 12, 2022

I remember what one person told one not long ago: "stop using other languages as an example, just use that if that's what you want"

I'm forced again, let's look at other languages, zig for example:

const socket_t = switch (builtin.os.tag) {
    .windows => usize,
    else     => i32
};

caveat: it require importing "builtin", but it's very small, and doesn't have any other inter module dependency, it's just data, evaluated at compile time:

Will we stick to what C did 50 years ago, or we are ready to move on and improve the language beyond what C can offer? (no, 'std' doesn't count as improving the language)

I don't particularly like zig, but if D is stuck in the past and we can't expect improvements, and all the solutions will be on phobos instead, then i'll find it as dreadful to use as zig, and at this point using zig would feel better

"Why do you hate phobos this much?"

It's not that i hate it, it serve a purpose, offer a set of API ready to use

The problem is i target esoteric platforms that the language doesn't want to acknowledge (WASM), so i can't use it, that's as simple as that

And the performance profile is not aligned with what i expect, so i can't use it because of that too

I am also against Exception Handling, so i can't use it for that too

I want to control the memory usage, so i can't use it for that too

This is why i expect D to be usable, and to receive improvements without having to subscribe to Phobos, wich i don't want to do, hence my suggestions