November 19, 2016
On Friday, 18 November 2016 at 21:28:44 UTC, ketmar wrote:
> On Friday, 18 November 2016 at 20:31:57 UTC, Igor Shirkalin wrote:
>> After 2 hours of brain breaking (as D newbie) I have come to:
>>
>> <code D>
>> uint_array.map!(v=>"%x".format(v)).join(", ")
>> </code D>
>> Why 2 hours? Because I have started with 'joiner' function and aftewords found out the 'join'.
>>
>> To my mind there is more simple form for this task in D (about formatting).
>
> sure ;-)
>
> import std.stdio;
> import std.format;
> void main () {
>   uint[$] a = [42, 69];
>   string s = "%(%s, %)".format(a);
>   writefln(s);
> }

Please don't post non-d.
People might use it an then complain that it does not work.

November 19, 2016
On Saturday, 19 November 2016 at 00:28:36 UTC, Stefan Koch wrote:
> Please don't post non-d.
it slipped accidentally, sorry. ;-)

for OP: `uint[2] a = [42, 69];` is the correct syntax.
November 19, 2016
On Friday, 18 November 2016 at 21:28:44 UTC, ketmar wrote:
> On Friday, 18 November 2016 at 20:31:57 UTC, Igor Shirkalin wrote:
>> After 2 hours of brain breaking (as D newbie) I have come to:
>>
>> <code D>
>> uint_array.map!(v=>"%x".format(v)).join(", ")
>> </code D>
>> Why 2 hours? Because I have started with 'joiner' function and aftewords found out the 'join'.
>>
>> To my mind there is more simple form for this task in D (about formatting).
>
> sure ;-)
>
> import std.stdio;
> import std.format;
> void main () {
>   uint[$] a = [42, 69];
>   string s = "%(%s, %)".format(a);
>   writefln(s);
> }

Accepted.
Is it really needed to call 'writefln'? I mean 'f'.
November 19, 2016
On Saturday, 19 November 2016 at 00:28:36 UTC, Stefan Koch wrote:
>> import std.stdio;
>> import std.format;
>> void main () {
>>   uint[$] a = [42, 69];
>>   string s = "%(%s, %)".format(a);
>>   writefln(s);
>> }
>
> Please don't post non-d.
> People might use it an then complain that it does not work.

Let these people to complain. ;)
November 19, 2016
On Saturday, 19 November 2016 at 17:12:13 UTC, Igor Shirkalin wrote:
>>   string s = "%(%s, %)".format(a);
>>   writefln(s);
>> }
>
> Accepted.
> Is it really needed to call 'writefln'? I mean 'f'.

no. it's a leftover from the code without format. it originally was `writefln("%(%s, %)", a);`, but i wanted to show `format` function too, and forgot to remove `f`. actually, it is a BUG to call `writefln` here, 'cause who knows, `s` may contain '%', and then boom! all hell broke loose. ;-)
November 19, 2016
On Saturday, 19 November 2016 at 20:54:32 UTC, ketmar wrote:
> On Saturday, 19 November 2016 at 17:12:13 UTC, Igor Shirkalin wrote:
>>>   string s = "%(%s, %)".format(a);
>>>   writefln(s);
>>> }
>>
>> Accepted.
>> Is it really needed to call 'writefln'? I mean 'f'.
>
> no. it's a leftover from the code without format. it originally was `writefln("%(%s, %)", a);`, but i wanted to show `format` function too, and forgot to remove `f`. actually, it is a BUG to call `writefln` here, 'cause who knows, `s` may contain '%', and then boom! all hell broke loose. ;-)

Got it! Thanks.
November 21, 2016
On Saturday, 19 November 2016 at 00:47:00 UTC, ketmar wrote:
> On Saturday, 19 November 2016 at 00:28:36 UTC, Stefan Koch wrote:
>> Please don't post non-d.
> it slipped accidentally, sorry. ;-)
>
> for OP: `uint[2] a = [42, 69];` is the correct syntax.

"uint[$] a = [42, 69];"

haha for a moment I thought that this was the way of D to create a fixed-size array without explicit setting the size (like what u can do in c++ :))
November 21, 2016
On Monday, 21 November 2016 at 12:08:30 UTC, Patric Dexheimer wrote:
> On Saturday, 19 November 2016 at 00:47:00 UTC, ketmar wrote:
>> On Saturday, 19 November 2016 at 00:28:36 UTC, Stefan Koch wrote:
>>> Please don't post non-d.
>> it slipped accidentally, sorry. ;-)
>>
>> for OP: `uint[2] a = [42, 69];` is the correct syntax.
>
> "uint[$] a = [42, 69];"
>
> haha for a moment I thought that this was the way of D to create a fixed-size array without explicit setting the size (like what u can do in c++ :))

That was a proposal for D that was rejected in the last moment by Andrei. My guess is that ketmar's modified dmd has that feature implemented.
November 21, 2016
On Monday, November 21, 2016 12:08:30 Patric Dexheimer via Digitalmars-d- learn wrote:
> On Saturday, 19 November 2016 at 00:47:00 UTC, ketmar wrote:
> > On Saturday, 19 November 2016 at 00:28:36 UTC, Stefan Koch
> >
> > wrote:
> >> Please don't post non-d.
> >
> > it slipped accidentally, sorry. ;-)
> >
> > for OP: `uint[2] a = [42, 69];` is the correct syntax.
>
> "uint[$] a = [42, 69];"
>
> haha for a moment I thought that this was the way of D to create
> a fixed-size array without explicit setting the size (like what u
> can do in c++ :))

No. D doesn't have that, though it's easy enough to do the same thing with a helper template. However, Ketmar seems to like to use his own fork of dmd where he made changes to the language based on his preferences. IIRC, it was proposed at one point that $ be used in this manner to create a static array while inferring its size (it might have even had a PR which was rejected), and presumably, Ketmar added it to his own compiler, because he liked the feature. But for better or worse, it's not standard D, and if the PR was rejected like I think it was, then it likely never will become standard D. Someone could create a DIP for it though and argue for it. If they did that convincingly enough, maybe it would become a feature. I suspect that the response will be though that since it's easy enough to just create a template to do the same thing, it's not worth adding to the language.

- Jonathan M Davis

November 21, 2016
On Monday, 21 November 2016 at 12:44:47 UTC, Jonathan M Davis wrote:
> On Monday, November 21, 2016 12:08:30 Patric Dexheimer via Digitalmars-d- learn wrote:
> No. D doesn't have that, though it's easy enough to do the same thing with a helper template. However, Ketmar seems to like to use his own fork of dmd where he made changes to the language based on his preferences. IIRC, it was proposed at one point that $ be used in this manner to create a static array while inferring its size (it might have even had a PR which was rejected), and presumably, Ketmar added it to his own compiler, because he liked the feature. But for better or worse, it's not standard D, and if the PR was rejected like I think it was, then it likely never will become standard D. Someone could create a DIP for it though and argue for it. If they did that convincingly enough, maybe it would become a feature. I suspect that the response will be though that since it's easy enough to just create a template to do the same thing, it's not worth adding to the language.
>
> - Jonathan M Davis

https://p0nce.github.io/d-idioms/#@nogc-Array-Literals:-Breaking-the-Limits