www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - New blog post featuring D

reply Brian Callahan <bcallah openbsd.org> writes:
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
Jan 22
next sibling parent Matheus Catarino <matheus-catarino hotmail.com> writes:
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
Jan 22
prev sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
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.
Jan 22
parent reply Patrick Schluter <Patrick.Schluter bbox.fr> writes:
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).
Jan 23
next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
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 :-)
Jan 23
parent reply jmh530 <john.michael.hall gmail.com> writes:
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
Jan 23
parent Walter Bright <newshound2 digitalmars.com> writes:
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.
Jan 24
prev sibling parent Siarhei Siamashka <siarhei.siamashka gmail.com> writes:
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: ```D 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: ```D int main(strings[] args) { ```
Jan 23