SlideShare a Scribd company logo
D

    Thu, September 22, 2009
• tama : repeatedly
•         T

  •
•                         (     )

•                     D       ...
•

•D
D言語をたまには真面目に紹介してみる
D
• Digital Mars   Walter

  •                       M$

•
  •                            (

•
•   DMD         •   GDC

    •               •   GCC


•   D.NET           •          → LDC

    •           •   LDC

•   DLI             •   LLVM

    •       …
                    •   GDC
DMD

•
• 1-2
  •
•       1   2   3
1
    2
•
•
    • arr + 10
•
    • Ruby       arr[1..7]
const / immutable
• const
  • const
• immutable
  •
•             (   )
• pure
• nothrow
• ref int foo() { ...; return *p; }
  ref

    foo = 3;
•
•
• op*
• override
• alias this (       )
class Foo
{
                         Foo foo;
   Bar bar;
                         foo.func; // bar.func call
   alias bar this;
}
Template
• C++
 •              !() → Foo!(int)(args);

 • C++            +α

   • template
• Mixin
Template
•
    template Foo(T)
    {
      class Foo { }
      void foo() { }
    }
•
    template Foo(T)
    {
      class Foo { }
                       class Foo(T) { }
    }
Mixin
•              •   Template


    •   D          •   Ruby mixin


                   •


    TMP
               mixin
TMP
•                             •
    •   static if                 •
    •   is
                                  •
    •   concept if
                                  •
    •
                                  •   etc...
        •    alias   etc...
static if
•          if
is
•
concept if
• template
•                TLS

• shared
  • shared
•                      __gshared

• synchronized
•       enum

    •
• final switch
 •
 •
enum
enum Foo : string { A = “a”, B = “b”, C = “c” }

final switch (foo) {
case Foo.A, Foo.B: ... break;
case Foo.C: ... break; // break
// default:
}
• Eiffel
•        in/out   invariant

•
  • release
void func(int v)   int func()      class Foo
in                 out(r)          {
{                  {                  int v;
   assert(v);         assert(r);
}                  }                   invariant()
body               body                {
{                  {                      assert(v);
   ...                return 0;        }
}                  }               }
• unittest {}
•
  int foo() { return 0; }
  unittest
  {
     assert(foo == 0);
  }
GC

•
•             GC

    •   GC   ML

•             GC
DIP
• D improve proposal
  •
  •
    •
•
•
•
•
•
• etc...
•              2

    • Andrei         ML

    •
•3
  •
•                  Noop   C#   (ry
Phobos
std.range
• Range
 • Phobos
   • R.I.P opApply
 • Iterators must go
• Range
 •                      etc...
range
• Recurrence
auto fib = recurrence!("a[n-1] + a[n-2]")(1, 1);
foreach (e; take(10, fib)) { writeln(e); }
• random
int[] a = [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ];
auto rnd = Random(unpredictableSeed);
foreach (e; randomCover(a, rnd)) { writeln(e); }
std.contract
• enforce
  auto file = fopen(“hoge.d”)
  if (file is null)
      throw new Exception;


  auto file = enforce(fopen(“hoge.d”))
  //            null
std.regex
•                std.regexp

• PCRE              ECMA standard
auto r = regex("ab");
foreach(m; match("abcabcabab", r))
{
   writefln("%s[%s]%s", m.pre, m.hit, m.post);
}
• std.algorithm
 • STL
• std.variant
 • Variant
• std.traits
 • TMP          template
• Andrei
 • Boost::Optional
 • net
 •                     replace

• Tango            …
Appendix
• D official site
 •
• The Case for D
 •
• C/C++            D   2.0

More Related Content

D言語をたまには真面目に紹介してみる