Thread overview
New blog post featuring D
Jan 23
jmh530
January 22

It's not the star of the show, but my latest blog post features D as one of the heroes to quickly solve one of my problems. Was a nice reminder that if you make content, it doesn't have to be "about" D in order to show D off. Just a nod to "when I have a problem, I use D to solve it" can be helpful.

https://briancallahan.net/blog/20240122.html

~Brian

January 22

On Monday, 22 January 2024 at 14:00:05 UTC, Brian Callahan wrote:

>

It's not the star of the show, but my latest blog post features D as one of the heroes to quickly solve one of my problems. Was a nice reminder that if you make content, it doesn't have to be "about" D in order to show D off. Just a nod to "when I have a problem, I use D to solve it" can be helpful.

https://briancallahan.net/blog/20240122.html

~Brian

Nice. In fact, in this case, the LDC is not being the protagonist. Perhaps, a bash script could do the same.

Based on what you did it is similar to my zigcc wrapper for ldc2. Replacing the system toolchain.
https://github.com/kassane/sokol-d/blob/main/tools%2Fzigcc.zig

January 22
On 1/22/2024 6:00 AM, Brian Callahan wrote:
> It's not the star of the show, but my latest blog post features D as one of the heroes to quickly solve one of my problems. Was a nice reminder that if you make content, it doesn't have to be "about" D in order to show D off. Just a nod to "when I have a problem, I use D to solve it" can be helpful.
> 
> https://briancallahan.net/blog/20240122.html
> 
> ~Brian

Nice work! Minor suggestion: The D example is too short to benefit from -O -release flags. Also, `-fas` is redundant as `as` is produced by default.
January 23
On Monday, 22 January 2024 at 20:57:58 UTC, Walter Bright wrote:
> On 1/22/2024 6:00 AM, Brian Callahan wrote:
>> It's not the star of the show, but my latest blog post features D as one of the heroes to quickly solve one of my problems. Was a nice reminder that if you make content, it doesn't have to be "about" D in order to show D off. Just a nod to "when I have a problem, I use D to solve it" can be helpful.
>> 
>> https://briancallahan.net/blog/20240122.html
>> 
>> ~Brian
>
> Nice work! Minor suggestion: The D example is too short to benefit from -O -release flags. Also, `-fas` is redundant as `as` is produced by default.

You shouldn't advertise -release flag as long as it does "wrong thing"™ like removing array bound checking and assertions (it is contradictory to your normal memory safety stance).
January 23
On 1/23/2024 1:58 AM, Patrick Schluter wrote:
> You shouldn't advertise -release flag as long as it does "wrong thing"™ like removing array bound checking and assertions (it is contradictory to your normal memory safety stance).

-release has not removed array bounds checking for about 17 years now :-)
January 23
On Tuesday, 23 January 2024 at 21:30:28 UTC, Walter Bright wrote:
> On 1/23/2024 1:58 AM, Patrick Schluter wrote:
>> You shouldn't advertise -release flag as long as it does "wrong thing"™ like removing array bound checking and assertions (it is contradictory to your normal memory safety stance).
>
> -release has not removed array bounds checking for about 17 years now :-)

The documentation says "Array bounds checking is not done for system and trusted functions, and assertion failures are undefined behaviour."

https://dlang.org/dmd-windows.html#switch-release
January 23

On Tuesday, 23 January 2024 at 09:58:53 UTC, Patrick Schluter wrote:

>

You shouldn't advertise -release flag as long as it does "wrong thing"™ like removing array bound checking and assertions (it is contradictory to your normal memory safety stance).

The "-release" option removes bounds checking from the unsafe code, but keeps them in the code that is annotated as @safe. The only problem is that @safe is not the default function attribute in D. So all samples from the blog post need a @safe: line added in the beginning of the source file to opt-in the safety. The first sample would turn into:

@safe:
import std.string;
import std.process;

int main(string[] args) {
    string[] av = new string[args.length + 2];
    av[0] = "/usr/bin/cc", av[1] = "-xassembler", av[2] = "-c";

    size_t ac = 3;
    foreach (i; 1 .. args.length)
        av[ac++] = args[i];

    return spawnProcess(av).wait();
}

Also there's an error in one of the samples:

int main(strings[] args) {
January 24
On 1/23/2024 1:45 PM, jmh530 wrote:
> On Tuesday, 23 January 2024 at 21:30:28 UTC, Walter Bright wrote:
>> On 1/23/2024 1:58 AM, Patrick Schluter wrote:
>>> You shouldn't advertise -release flag as long as it does "wrong thing"™ like removing array bound checking and assertions (it is contradictory to your normal memory safety stance).
>>
>> -release has not removed array bounds checking for about 17 years now :-)
> 
> The documentation says "Array bounds checking is not done for system and trusted functions, and assertion failures are undefined behaviour."
> 
> https://dlang.org/dmd-windows.html#switch-release

You're right. It is not removed from @safe code.