他の言語をある程度知っている人はこれを読めばD言語の基礎をマスターでき,D言語の氷山の一角くらいは知ることができると思います.対象バージョンはdmd 2.059です.
ASCIIかUTFしか受け付けません.それ以外の文字コードで書くとコンパイルエラーになります.
D言語のmainはCとは違い以下のようなシグネチャです.
| // Written in the D programming language. | |
| /** | |
| * High peformance downloader | |
| * | |
| * Implemented according to <a href="http://yusukebe.com/archives/20120229/072808.html">this implementation</a>. | |
| * | |
| * Example: | |
| * ----- | |
| * dmd -L-lcurl -run downloader.d |
| function Klass(x) | |
| { | |
| this.member = { | |
| x: x, | |
| }; | |
| } | |
| Klass.prototype = { | |
| get x() { | |
| return this.member.x; |
| $ find path_to_sourcedir/ -name '*.php' > cscope.files | |
| $ cscope -b | |
| $ cat ~/.vimrc | |
| ... | |
| if has('cscope') | |
| nnoremap <Leader>s :<C-u>scs find s <C-R>=expand("<cword>")<CR><CR> | |
| nnoremap <Leader>g :<C-u>scs find g <C-R>=expand("<cword>")<CR><CR> | |
| nnoremap <Leader>c :<C-u>scs find c <C-R>=expand("<cword>")<CR><CR> | |
| nnoremap <Leader>t :<C-u>scs find t <C-R>=expand("<cword>")<CR><CR> |
| // 初期値とstepを指定して永遠にカウントするItrator | |
| class Counter[T:Numeric](init:T = 0,step:T = 1) extends Iterator[T] { | |
| var cnt = init | |
| def hasNext = true | |
| def next = { | |
| cnt = implicitly[Numeric[T]].plus(cnt, step) | |
| cnt | |
| } | |
| // 自分をStreamにする | |
| def asStream = Stream.continually( next ) |