Three articles on D

data pulverizer data.pulverizer at gmail.com
Mon Jun 8 01:17:27 UTC 2020


On Monday, 8 June 2020 at 00:43:34 UTC, Paul Backus wrote:
> On Monday, 8 June 2020 at 00:25:38 UTC, data pulverizer wrote:
>> On Sunday, 7 June 2020 at 23:34:56 UTC, Paul Backus wrote:
>>>
>>> The examples here seem a bit contrived and unrealistic. It 
>>> might be difficult for readers to understand how and why they 
>>> would apply these techniques to their own code.
>>>
>>
>> It would probably be helpful for you to pick an example and 
>> describe what you mean. From my point of view I'm targeting 
>> people writing numerical code and Julia. Someone like that 
>> will look at the article and think "hmm okay interesting ...".
> [...]
>> The second example getting static array size is from code that 
>> actually I use. The code is small in size and simple to follow.
>
> See, that's one of the examples I had in mind, because the way 
> I'd get the length of a static array in real code is
>
>     arr.length
>
> I assumed you knew about that and were just using the example 
> to demonstrate template argument deduction. :)

I assumed that arr.length is always run-time for arrays - but I 
just checked with a simple example and it works for static arrays 
at compile time. I can now see why you were saying it was 
contrived - because you don't need the template to get the 
length. Fair enough.

>
> I'm not familiar with Julia's value types, and reading the 
> linked page doesn't give me a clear idea what they are used 
> for. Again, the example does a decent job showing how template 
> value parameters [1] work, but it doesn't give me much of a 
> clue about why I'd want to use them. Perhaps that's just me, 
> though, and a programmer with a background in Julia would 
> understand better.
>
> [1] 
> https://dlang.org/spec/template.html#template_value_parameter

They are more similar to template alias parameters 
(https://dlang.org/spec/template.html#aliasparameters) but you 
can dispatch on anything - you don't have to specify a type 
(compiler deduces).

The official template documentation looks as if it has been 
updated, the last time I saw it, it wasn't this detailed. Great!



More information about the Digitalmars-d mailing list