August 01
On Friday, 31 July 2020 at 17:55:54 UTC, Bruce Carneal wrote:

>
> Good writing for the not-quite-beginner-and-up audience Mike.  Reading it reminded me of how much I had been taking for granted, of how much power D provides with minimal drag.  Really hope I never have to go back to C++/CUDA.  Also enjoying your book.
>
> Looking forward to additional blog posts.

Thanks! I'm hoping for a few volunteers to step forward to produce some of those additional posts. There's a pile of unpublished D template know-how out there that would make for some interesting reading.
August 01
On Friday, 31 July 2020 at 22:58:07 UTC, Mario Kröplin wrote:
> On Friday, 31 July 2020 at 13:46:43 UTC, Mike Parker wrote:
>> The blog:
>> https://dlang.org/blog/2020/07/31/the-abcs-of-templates-in-d/
>
> Minor detail: in "Even shorter syntax" the point is not that the template has only one parameter, but that the template argument is only one token long (for example, no `char[]`).

Double thanks! The entirety of the first sentence in that section was problematic.
2 days ago
On Friday, 31 July 2020 at 17:57:58 UTC, H. S. Teoh wrote:

I choosed the following way regarding:
> 2) The regex is not initialized by ctRegex in order to avoid the
>   compile-time overhead; instead, it's initialized at program startup
>   time.

version(DigitalMars){
   auto reg(alias var)(){
                return(regex(var));
                pragma(msg,"regex used");
   }
}

version(LDC){
// reg!() is an alias method, which can check which kind of parameter it got
  auto reg(alias var)(){
       static if (__traits(compiles, {enum ctfeFmt = var;}) ){
                // "Promotion" to compile time value
                enum ctfeReg =  var ;
                pragma(msg, "ctRegex used");
                return(ctRegex!ctfeReg);

       }else{
                return(regex(var));
                pragma(msg,"regex used");
                }
       }
}

So when compiling with DMD my reg!("....") expression is using the runtime version.
When compiling with LDC (for release) I use the ctRegex version, if possible.
The (alias var) combined with the check if the var is known at compile time:
__traits(compiles, {enum ctfeFmt = var;}

I have to admit that the idea was mine, but the crafting only with the help of forum members!

// Function to mark all ocurences of the word offshore within html bold.
string markoffshore(string to_mark){
   return   to_mark.replaceAll(reg!(r"([oO]ffshore)"),"<b>$1</b>");
}


12 hours ago
On Friday, 31 July 2020 at 13:46:43 UTC, Mike Parker wrote:
> The blog:
> https://dlang.org/blog/2020/07/31/the-abcs-of-templates-in-d/

This is very well written! I want to share it with my coworkers using Java to see if it piques their interest.



Next ›   Last »
1 2