Re: Compile Time versus Run Time

2017-07-31 Thread inevzxui via Digitalmars-d-learn
On Monday, 31 July 2017 at 15:43:21 UTC, Martin Tschierschke 
wrote:
As a rookie in D programming I try to understand the power of 
templated functions with compile time parameters. With DMD 
2.074 a compile time format

(auto output = format!("Print this %s")(var);)

was introduced, now we all know that very many of this format 
strings are immutable, so wouldn't it be cool to automatically 
detect this and use the compile time version?


Without the need to think about it and to use an other syntax?
Is this theoretically possible?

Regards mt.


That's what writeln() does. The format is detected for each 
element of the variadic.


Re: How to test tuple in chain

2017-07-31 Thread inevzxui via Digitalmars-d-learn

On Monday, 31 July 2017 at 12:23:02 UTC, closescreen wrote:

I read my message. Sorry for my poor english and typos.


use res[0] and res[1] to get res.status and the res.output.



Re: Specify rhs at initialisation or assignment of typedef' d variable

2017-07-31 Thread inevzxui via Digitalmars-d-learn

On Monday, 31 July 2017 at 07:16:25 UTC, Cecil Ward wrote:
Say I have used Typedef! to create some new type and I declare 
a variable, constant or enum of that type. Is there a way that 
I can express a literal value on the rhs without having to use 
casts, as that seems to defeat the point of the nice type 
safety?


I may be asking for the impossible or _illogical_ here. In any 
case, I still get to keep the nice feature of not being able to 
mix up types with assignment from one variable to another.


Specific example is

mac_addr_48_t   my_mac_address = 0x112233445566uL;

Which now produces a compile time error after I changed to use 
an alias  = Typedef!uint64_t as opposed to just a straight 
alias = uint64_t earlier with no strong typing.


If struct + alias this is not strong enough the only solution is 
see is a helper template à la "octal" or "hexString", i.e a 
static cally checked string.