Jump to page: 1 24  
Page
Thread overview
D idioms list
Jan 08, 2015
ponce
Jan 08, 2015
uri
Jan 08, 2015
ponce
Jan 08, 2015
uri
Jan 08, 2015
bearophile
Jan 08, 2015
ponce
Jan 08, 2015
Szymon Gatner
Jan 08, 2015
ketmar
Jan 08, 2015
Szymon Gatner
Jan 08, 2015
ponce
Jan 08, 2015
Szymon Gatner
Jan 08, 2015
ketmar
Jan 08, 2015
Foo
Jan 08, 2015
Foo
Jan 08, 2015
ponce
Jan 09, 2015
Foo
Jan 08, 2015
Adam D. Ruppe
Jan 08, 2015
ponce
Jan 08, 2015
ketmar
Jan 08, 2015
ponce
Jan 09, 2015
ketmar
Jan 09, 2015
ketmar
Jan 09, 2015
ponce
Jan 08, 2015
Artur Skawina
Jan 08, 2015
weaselcat
Jan 09, 2015
ketmar
Jan 10, 2015
Walter Bright
Jan 10, 2015
weaselcat
Jan 10, 2015
Walter Bright
Jan 11, 2015
Russel Winder
Jan 11, 2015
Walter Bright
Jan 15, 2015
Vlad Levenfeld
Jan 15, 2015
ponce
Mar 09, 2016
Muhavare
January 08, 2015
I've started a list of curated D tips and tricks here: http://p0nce.github.io/d-idioms/

Anything that you wished you learned earlier at one point in the D world is welcome to be added or suggested.

I think the focus should be on "stuff that could make you more productive, or is just funky" but that is up to debate.

Of course the D Cookbook still stays irreplaceable for a consistent, in-depth discussion of being D-enabled.

Thoughts?
January 08, 2015
On Thursday, 8 January 2015 at 10:21:26 UTC, ponce wrote:
> I've started a list of curated D tips and tricks here: http://p0nce.github.io/d-idioms/
>
> Anything that you wished you learned earlier at one point in the D world is welcome to be added or suggested.
>
> I think the focus should be on "stuff that could make you more productive, or is just funky" but that is up to debate.
>
> Of course the D Cookbook still stays irreplaceable for a consistent, in-depth discussion of being D-enabled.
>
> Thoughts?

This is great, thanks.

Something I personally would find useful is a comparison between the C++ way and idiomatic D with Phobos. I finding coming from C/C++ to D very easy but I'm always wondering if I'm doing things the "D" way.

Cheers,
uri
January 08, 2015
On Thursday, 8 January 2015 at 10:30:38 UTC, uri wrote:
>
> This is great, thanks.
>
> Something I personally would find useful is a comparison between the C++ way and idiomatic D with Phobos. I finding coming from C/C++ to D very easy but I'm always wondering if I'm doing things the "D" way.
>
> Cheers,
> uri

I'm not familiar with the terse, range-heavy, UFCS style that has emerged from Phobos so I'm not sure if I can write that.

What could help is a list of tasks for which you asked yourself what the "D" way was. Is there one?
January 08, 2015
On Thursday, 8 January 2015 at 10:35:07 UTC, ponce wrote:
> On Thursday, 8 January 2015 at 10:30:38 UTC, uri wrote:
>>
>> This is great, thanks.
>>
>> Something I personally would find useful is a comparison between the C++ way and idiomatic D with Phobos. I finding coming from C/C++ to D very easy but I'm always wondering if I'm doing things the "D" way.
>>
>> Cheers,
>> uri
>
> I'm not familiar with the terse, range-heavy, UFCS style that has emerged from Phobos so I'm not sure if I can write that.
>
> What could help is a list of tasks for which you asked yourself what the "D" way was. Is there one?

No I admit I don't have any real list. It's always an "in the moment" sort of thing and I then just choose a D-ish/C++ style and promptly forget the exact details.

I'll start to compile a list each time this comes up. And if I find any good D idioms in the process I'll include them in the list as well.

Thanks,
uri
January 08, 2015
ponce:

> I'm not familiar with the terse, range-heavy, UFCS style that has emerged from Phobos

In Rosettacode I have inserted tons of examples of that coding style.

An example, given a tuple of arbitrary length, with items all of the same type, how do you compute the total of its items?

The last way I've invented is:

myTuple[].only.sum

It's also @nogc. But it causes a little of template bloat.

Bye,
bearophile
January 08, 2015
On Thursday, 8 January 2015 at 10:21:26 UTC, ponce wrote:
> I've started a list of curated D tips and tricks here: http://p0nce.github.io/d-idioms/
>
> Anything that you wished you learned earlier at one point in the D world is welcome to be added or suggested.
>
> I think the focus should be on "stuff that could make you more productive, or is just funky" but that is up to debate.
>
> Of course the D Cookbook still stays irreplaceable for a consistent, in-depth discussion of being D-enabled.
>
> Thoughts?

They are really cool, thanks :)

Question:

Where did this syntax came from? It is not documented for 'import' keyword.(first time I see that D has built-in resource compiler):

ubyte[] sdlBytes = cast(ubyte[]) import("SDL2.dll");
January 08, 2015
On Thu, 08 Jan 2015 11:24:34 +0000
Szymon Gatner via Digitalmars-d-announce
<digitalmars-d-announce@puremagic.com> wrote:

> On Thursday, 8 January 2015 at 10:21:26 UTC, ponce wrote:
> > I've started a list of curated D tips and tricks here: http://p0nce.github.io/d-idioms/
> >
> > Anything that you wished you learned earlier at one point in the D world is welcome to be added or suggested.
> >
> > I think the focus should be on "stuff that could make you more productive, or is just funky" but that is up to debate.
> >
> > Of course the D Cookbook still stays irreplaceable for a consistent, in-depth discussion of being D-enabled.
> >
> > Thoughts?
> 
> They are really cool, thanks :)
> 
> Question:
> 
> Where did this syntax came from? It is not documented for 'import' keyword.(first time I see that D has built-in resource compiler):
> 
> ubyte[] sdlBytes = cast(ubyte[]) import("SDL2.dll");
it is documented: http://dlang.org/expression.html#ImportExpression it's a nice D habit of overloading keywords.


January 08, 2015
On Thursday, 8 January 2015 at 10:56:00 UTC, bearophile wrote:
> ponce:
>
>> I'm not familiar with the terse, range-heavy, UFCS style that has emerged from Phobos
>
> In Rosettacode I have inserted tons of examples of that coding style.
>
> An example, given a tuple of arbitrary length, with items all of the same type, how do you compute the total of its items?
>
> The last way I've invented is:
>
> myTuple[].only.sum
>
> It's also @nogc. But it causes a little of template bloat.
>
> Bye,
> bearophile

Cool. I will link to the Rosettacode D pages since I've used them in the past when time-constrained, especially all things regarding text files.
January 08, 2015
On Thursday, 8 January 2015 at 11:31:14 UTC, ketmar via Digitalmars-d-announce wrote:
> On Thu, 08 Jan 2015 11:24:34 +0000
> Szymon Gatner via Digitalmars-d-announce
> <digitalmars-d-announce@puremagic.com> wrote:
>
>> On Thursday, 8 January 2015 at 10:21:26 UTC, ponce wrote:
>> > I've started a list of curated D tips and tricks here: http://p0nce.github.io/d-idioms/
>> >
>> > Anything that you wished you learned earlier at one point in the D world is welcome to be added or suggested.
>> >
>> > I think the focus should be on "stuff that could make you more productive, or is just funky" but that is up to debate.
>> >
>> > Of course the D Cookbook still stays irreplaceable for a consistent, in-depth discussion of being D-enabled.
>> >
>> > Thoughts?
>> 
>> They are really cool, thanks :)
>> 
>> Question:
>> 
>> Where did this syntax came from? It is not documented for 'import' keyword.(first time I see that D has built-in resource compiler):
>> 
>> ubyte[] sdlBytes = cast(ubyte[]) import("SDL2.dll");
> it is documented: http://dlang.org/expression.html#ImportExpression
> it's a nice D habit of overloading keywords.

Ah, thanks. Follow up then: can such imported string be used for mixin?
January 08, 2015
On Thursday, 8 January 2015 at 11:41:43 UTC, Szymon Gatner wrote:
>>> 
>>> Question:
>>> 
>>> Where did this syntax came from? It is not documented for 'import' keyword.(first time I see that D has built-in resource compiler):
>>> 
>>> ubyte[] sdlBytes = cast(ubyte[]) import("SDL2.dll");
>> it is documented: http://dlang.org/expression.html#ImportExpression
>> it's a nice D habit of overloading keywords.
>
> Ah, thanks. Follow up then: can such imported string be used for mixin?

Yes.

« First   ‹ Prev
1 2 3 4