Talk:D (programming language)

From Wikipedia, the free encyclopedia
Jump to: navigation, search
WikiProject Computing / Software (Rated C-class, Low-importance)
WikiProject icon This article is within the scope of WikiProject Computing, a collaborative effort to improve the coverage of computers, computing, and information technology on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
C-Class article C  This article has been rated as C-Class on the project's quality scale.
 Low  This article has been rated as Low-importance on the project's importance scale.
Taskforce icon
This article is supported by WikiProject Software (marked as Low-importance).
 
WikiProject Computer science (Rated C-class, Low-importance)
WikiProject icon This article is within the scope of WikiProject Computer science, a collaborative effort to improve the coverage of Computer science related articles on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
C-Class article C  This article has been rated as C-Class on the project's quality scale.
 Low  This article has been rated as Low-importance on the project's importance scale.
 

HelloWorld[edit]

Where is HelloWorld? —Preceding unsigned comment added by 12.15.136.26 (talk) 21:03, 14 October 2010 (UTC)

D's Hello World is pretty boring. I think it'd only waste space in the article. --Vladimir (talk) 01:05, 23 October 2010 (UTC)
But all the others have HelloWorld. In VB it's just MsgBox("Hello, World!") but we still have it. --Joshua Issac (talk) 00:47, 15 November 2010 (UTC)

Purity of mySum function in the "Functional" section (1.1.4)[edit]

I am not a D programmer, so I may misunderstand the language's semantics, but I am confused about how the mySum function could be considered pure:

int main()
{
    int[] a1 = [0,1,2,3,4,5,6,7,8,9];
    int[] a2 = [6,7,8,9];
    int pivot = 5;
 
    pure int mysum(int a, int b) // pure function
    {
        if (b <= pivot) // ref to enclosing-scope
            return a + b;
        else
            return a;
    }

The value mySum produces depends on the value of pivot from the enclosing scope. If the numerical value of pivot in mySum was fixed at the time mySum is defined, then mySum would be only depend on its arguments, and could arguably be called a pure function, but from what I infer from the section on nested functions on the function page of D's reference manual, the value of pivot in mySum is the value of pivot in the enclosing scope at the time mySum is called.

So I would expect that:

pivot = 4;
mySum(3, 5);

would yield 3, but

pivot = 5;
mySum(3, 5);

would yield 8

Unfortunately I don't have a D compiler installed on my computer, so I cannot check this myself. —Preceding unsigned comment added by 67.168.77.169 (talk) 08:16, 6 November 2010 (UTC)

The code indeed compiles. I think that the idea is that nested functions have a hidden argument - a pointer to their enclosing scope (main's local variables). However, that doesn't explain why the code continues to compile when pivot is moved outside main(), or if you add a call to a non-pure function in mySum - these sound like compiler bugs. --Vladimir (talk) 11:45, 6 November 2010 (UTC)

Pull the C# reference until examples?[edit]

Given the way it reads, I'm not sure why C# is even listed without more direct examples as to what it inherited from C# that isn't already considered from Java (a predecessor).68.163.243.231 (talk) 22:07, 12 November 2010 (UTC)

Misleading statement about C compatibility?[edit]

The second sentence under the Features section currently ends by saying "and as such [D] is not compatible with C/C++ source code". This sentence may be misleading given that D code can call libraries written in C. This is indeed discussed in more detail in the Interaction with Other Systems section. Should this statement be removed or clarified? Milez (talk) 20:57, 15 February 2013 (UTC)

Explain the concurrent section[edit]

The section about concurrent programming only contains source code. Should there not be some sort of explanation to why it is concurrent and what the code does (besides from the very thin information in the comments)? SBareSSomErMig (talk) 10:22, 6 March 2013 (UTC)

Type naming policy[edit]

I don't think it's future proof name types way they are named currently.

http://dlang.org/type.html

void    -       no type
bool    false   boolean value
byte    0       signed 8 bits
ubyte   0       unsigned 8 bits
short   0       signed 16 bits
ushort  0       unsigned 16 bits
int     0       signed 32 bits
uint    0       unsigned 32 bits
long    0L      signed 64 bits
ulong   0L      unsigned 64 bits
cent    0       signed 128 bits (reserved for future use)
ucent   0       unsigned 128 bits (reserved for future use)
float   float.nan       32 bit floating point
double  double.nan      64 bit floating point
real    real.nan        largest FP size implemented in hardware (Implementation Note: 80 bits for x86 CPUs or double size, whichever is larger)
ifloat  float.nan*1.0i  imaginary float
idouble double.nan*1.0i imaginary double
ireal   real.nan*1.0i   imaginary real
cfloat  float.nan+float.nan*1.0i        a complex number of two float values
cdouble double.nan+double.nan*1.0i      complex double
creal   real.nan+real.nan*1.0i  complex real
char    0xFF    unsigned 8 bit UTF-8
wchar   0xFFFF  unsigned 16 bit UTF-16
dchar   0x0000FFFF      unsigned 32 bit UTF-32

This would be way better naming...

void    -       no type
bool    false   boolean value
s8int   0       signed 8 bits
u8int   0       unsigned 8 bits
s16int  0       signed 16 bits
u16int  0       unsigned 16 bits
s32int  0       signed 32 bits
u32int  0       unsigned 32 bits
s64int  0L      signed 64 bits
u64int  0L      unsigned 64 bits
s128int 0       signed 128 bits (reserved for future use)
u128int 0       unsigned 128 bits (reserved for future use)
sLint   0       largest signed integer implemented in hardware
uLint   0       largest unsigned integer implemented in hardware
n32float        float.nan       32 bit floating point
n64float        double.nan      64 bit floating point
nLfloat real.nan        largest FP size implemented in hardware (Implementation Note: 80 bits for x86 CPUs or double size, whichever is larger)
i32float        float.nan*1.0i  imaginary float
i64float        double.nan*1.0i imaginary double
iLfloat real.nan*1.0i   imaginary real
c32float        float.nan+float.nan*1.0i        a complex number of two float values
c64float        double.nan+double.nan*1.0i      complex double
cLfloat real.nan+real.nan*1.0i  complex real
b8char  0xFF    unsigned 8 bit UTF-8
b16char 0xFFFF  unsigned 16 bit UTF-16
b32dchar        0x0000FFFF      unsigned 32 bit UTF-32

Also I added two more there, "largest (un)signed integer implemented in hardware".
triedoutd 188.238.70.207 (talk) 15:40, 4 September 2013 (UTC)

Metaprogramming[edit]

Is there any reason the factorial example uses ulong instead of int? In example code clarity rules and for most readers int would be clearer. 70.124.88.175 (talk) 04:36, 23 September 2013 (UTC)

Another D programming language in the 1980ies[edit]

I remembered - and found out that I remembered correctly - that there was a language "D" for TSX-11 PDP-11 OS with preemptive multitasking, very good OS for its time. I think "D" was used for writing Lex-11. I have added a link under talk for TSX-11 wikipedia page. --d-axel (talk) 04:13, 7 February 2016 (UTC) Wikipedia mentions the other "D" programming language as "Filetab D". --d-axel (talk) 04:15, 7 February 2016 (UTC)