March 20, 2012
On 3/20/2012 12:02 PM, Andrei Alexandrescu wrote:
> What are your faves? I have a few in mind, but wouldn't want to influence answers.

Although array slices have been in D nearly since the beginning, I had little idea they would become so darn useful and foundational. They originated from an idea by Jan Knepper.

The unexpected utility of them explains why they haven't appeared in other languages (yet).
March 20, 2012
On 3/20/12 4:43 PM, Walter Bright wrote:
> On 3/20/2012 12:02 PM, Andrei Alexandrescu wrote:
>> What are your faves? I have a few in mind, but wouldn't want to
>> influence answers.
>
> Although array slices have been in D nearly since the beginning, I had
> little idea they would become so darn useful and foundational. They
> originated from an idea by Jan Knepper.
>
> The unexpected utility of them explains why they haven't appeared in
> other languages (yet).

Go has slices. (Unlike D slices, they include capacity.)

Andrei
March 20, 2012
Andrei Alexandrescu wrote:
> What are your faves?

opDispatch was expectantly successful for me. I haven't seen it
often used in examples or others peoples code, but it allows for
some really awesome stuff.

For instance, who says D doesn't have multiple inheritance?

struct A { void a() { writeln("a"); } }
struct B { void b() { writeln("b"); } }
struct C {
       private A _a;
       private B _b;
       void opDispatch(string s)() {
         static if (__traits(hasMember, A, s))
mixin("_a."~s~"();");
           else if (__traits(hasMember, B, s))
mixin("_b."~s~"();");
           else static assert("Method not found.");
       }
}

void main() {
       auto c = C();
       c.a();
       c.b();
}

and similarly, "alias x this" is useful for pseudo hierarchy. The
only down-side to doing this is that Mono-D doesn't currently
parse the syntax.

March 20, 2012
Le 20/03/2012 20:02, Andrei Alexandrescu a écrit :
> I plan to give a talk at Lang.NEXT
> (http://channel9.msdn.com/Events/Lang-NEXT/Lang-NEXT-2012) with the
> subject above. There are a few features of D that turned out to be
> successful, in spite of them being seemingly unimportant or diverging
> from related consecrated approaches.
>
> What are your faves? I have a few in mind, but wouldn't want to
> influence answers.
>
>
> Thanks,
>
> Andrei

To me it is pragma(msg, blabla) and slices.
March 20, 2012
deadalnix wrote:
> Le 20/03/2012 20:02, Andrei Alexandrescu a écrit :
>> I plan to give a talk at Lang.NEXT
>> (http://channel9.msdn.com/Events/Lang-NEXT/Lang-NEXT-2012) with the
>> subject above. There are a few features of D that turned out to be
>> successful, in spite of them being seemingly unimportant or diverging
>> from related consecrated approaches.
>>
>> What are your faves? I have a few in mind, but wouldn't want to
>> influence answers.
>>
>>
>> Thanks,
>>
>> Andrei
>
> To me it is pragma(msg, blabla) and slices.

Yes, pragma(msg, ...) is very handy when debugging templates and generic code.
March 20, 2012
On 3/20/12, Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> wrote:
> What are your faves? I have a few in mind, but wouldn't want to influence answers.

Here's one: C compatibility.

Maybe it wasn't "unlikely" to be successful but most new languages don't seem to care about C compatibility all that much. It's been a boon for D though.
March 20, 2012
I really love CTFE, even though it's sometimes pretty slow, maybe because I am axaggerating it …

One more thing are these slices, they really impressed me when working with pointers, float* v; v[x..y] = foo; ! awesome, no more memcpy

And of yourse opDispatch, I haven't used it a lot yet, just in gl3n for vector swizzling, I've seen glms swizzling ... I thought I can never do this in D, I made it in nearly no time and 10 lines of code!
March 20, 2012
On 3/20/12, Andrej Mitrovic <andrej.mitrovich@gmail.com> wrote:
> Here's one: C compatibility.

Now a real one: auto type inference. Could you possibly imagine what the type name should be on the left-hand side?

? x = retro(stride(chain([1, 2], [3, 4]), 2));

Who knows. auto is great for these higher-level types.
March 20, 2012
- Type inference
- alias
- foreach
- Everything about arrays/slices
- Built-in associative arrays that support nearly any type as a key
- Reference semantics for classes
- All the niceities of ctors compared with C++'s ctors
- Backtick strings
- Scope guards (And even finally: I head somewhere C++ doesn't even have
finally: Is that true?!?)
- GC
- Name any of D's metaprogramming features

Many of those can seem like simple things, but I'd *hate* to have to get by without them. Heck, most of them I now take for granted.

Alias in particular is a much bigger deal than it seems since it's seemingly trivial but can be *incredibly* helpful with templates *and* with importing.

Actually, looking at this list, I'm now starting to get a little worried about an upcoming C++ project... No doubt I'll be trying to reinvent a lot of D in it. Probably in ugly hackish ways.


March 20, 2012
On 3/20/2012 2:51 PM, Andrei Alexandrescu wrote:
> On 3/20/12 4:43 PM, Walter Bright wrote:
>> On 3/20/2012 12:02 PM, Andrei Alexandrescu wrote:
>>> What are your faves? I have a few in mind, but wouldn't want to
>>> influence answers.
>>
>> Although array slices have been in D nearly since the beginning, I had
>> little idea they would become so darn useful and foundational. They
>> originated from an idea by Jan Knepper.
>>
>> The unexpected utility of them explains why they haven't appeared in
>> other languages (yet).
>
> Go has slices. (Unlike D slices, they include capacity.)

Can you, in Go:

1. slice a static string?
2. slice any arbitrary data?

1 2 3 4 5 6 7 8 9 10 11
Top | Discussion index | About this forum | D home