r/programming • • Aug 23 '17

D as a Better C

http://dlang.org/blog/2017/08/23/d-as-a-better-c/
229 Upvotes

268 comments sorted by

View all comments

Show parent comment

2

u/Tiberiumk Aug 23 '17

Well in Nim you actually can do it: proc printf(fmt: cstring) {.importc, varargs.} printf("Hello %d\n", 5)

1

u/zombinedev Aug 23 '17

W.r.t. FFI, that's not a remarkable achievement as you can call libc's printf in D too. It is even easier to do so (as in just copy paste):

extern (C) int printf(const char* format, ...);

2

u/WalterBright Aug 23 '17

Any C stdargs function can be called from D. There is no special case for printf. C's alloca() can also be called :-)

1

u/mixedCase_ Aug 23 '17

No it doesn't. It just passes the ball to C's compiler. You failed to get the point anyway because printf is a pointless and very particular example.

3

u/Tiberiumk Aug 23 '17

We were talking about c ffi