Talk:D (programming language)

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

HelloWorld[edit]

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

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)[reply]
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)[reply]

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)[reply]

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)[reply]


It does compile, but by default functions are (weakly) pure if they don't access any global or static mutable data. They are free to access non-mutable (i.e. const, immutable, or static initialized module / class / thread data) and non-global-non-static data, this includes the parent function data. To ensure somehow functional safety, one need strong purity, this can be done by marking a function as immutable, as well not using transitively mutable references in input and output arguments.
    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) immutable // pure function
    {
        if (b <= pivot) // ref to enclosing-scope
            return a + b;
        else
            return a;
    }
will not compile, and compiler will report the issue:
a.d:10:18: error: immutable function 'a.main.mysum' cannot access mutable data 'pivot'
   10 |         if (b <= pivot) // ref to enclosing-scope
If the pivot is made const or immutable, it will compile. In this sense the function will become strongly pure, but only during current execution of the scope. The context will be takes implicitly. https://dlang.org/spec/function.html#pure-functions provides some extra details, but details of pure functions inside other functions is not really well explained. 81.6.34.172 (talk) 20:15, 29 April 2020 (UTC)[reply]

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)[reply]

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)[reply]

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)[reply]

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)[reply]

External links modified[edit]

Hello fellow Wikipedians,

I have just modified one external link on D (programming language). Please take a moment to review my edit. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit this simple FaQ for additional information. I made the following changes:

When you have finished reviewing my changes, you may follow the instructions on the template below to fix any issues with the URLs.

This message was posted before February 2018. After February 2018, "External links modified" talk page sections are no longer generated or monitored by InternetArchiveBot. No special action is required regarding these talk page notices, other than regular verification using the archive tool instructions below. Editors have permission to delete these "External links modified" talk page sections if they want to de-clutter talk pages, but see the RfC before doing mass systematic removals. This message is updated dynamically through the template {{source check}} (last update: 18 January 2022).

  • If you have discovered URLs which were erroneously considered dead by the bot, you can report them with this tool.
  • If you found an error with any archives or the URLs themselves, you can fix them with this tool.

Cheers.—InternetArchiveBot (Report bug) 03:22, 3 September 2017 (UTC)[reply]

what became of the merger of the articles on gtkd and the d programming language?[edit]

At the top of the talk page, there's this prominent notice: The article GtkD was nominated for deletion. The discussion was closed on 23 August 2011 with a consensus to merge the content into D (programming language). If you find that such action has not been taken promptly, please consider assisting in the merger instead of re-nominating the article for deletion. To discuss the merger, please use this talk page.

August 23, 2011 is not quite 10 years ago. There's no mention of gtkd in the article, that i can see; the string 'gtkd' itself redirects to the article on gtk.

Per the notice, this is the right place to discuss the merger. Did it ever happen, or was mention of gtkd just washed away through a string of edits over time?

Son of eugene (talk) 20:03, 25 June 2021 (UTC)[reply]

Influenced Go? I do not think sol.[edit]

In a top infobox, I see that D influenced Go.

I find this doubtful.

D influenced some languages, including modern C++, Nim, etc. But I really doubt it influenced Go in anyway at all. Go has completely different execution model, typing system, syntax, no templates, different module system, different concurrency methods, different error control, no metaprogramming. I would be super hard to find ANY concept taken from D that got into Go.

The only thing vaguely similar is Go and D compilers speed, which were kind of new at the time (currently many other compiled languages like Zig and Nim are even faster in this regard). But modern D is much slower than Go in compilation area (partially due to D standard libraries growing big). Even if so, this is hardly an influence of any kind. 2A02:168:F609:1:BEDA:2803:4006:38FD (talk) 17:38, 5 March 2023 (UTC)[reply]

After thinking a bit more about this. There is one feature in Go which is very similar to D. That pointer and reference dereferences, all use dot, instead of arrow for pointers and dot for references or values. I am not sure if this was influenced by D tho. 2A02:168:F609:1:BEDA:2803:4006:38FD (talk) 18:34, 5 March 2023 (UTC)[reply]

01743082064[edit]

অনেক 103.106.167.225 (talk) 08:33, 4 April 2023 (UTC)[reply]

usage of 'mathematical corellaries'[edit]

the fifth paragraph under Features reads "Specific operators for string handling exist, visually distinct from mathematical corellaries". i believe this should be changed to something like "syntactically distinct from numerical operators", or just removed from the paragraph because:

- "visually" might be ableist. "syntactically" might also be more correct, as programming languages arent defined over what they visually look like, but in terms of (also) their syntax.

- the word "corellaries" seems to be a typo of "corollaries". a naive google search for "corellaries" turns up very few results (this page is the top result btw). wiktionary has no entry for it either.

- even if we correct it to "corollary" the phrase still is wrong. "mathematical corollaries" have nothing to do with the rest of the paragraph or page. the reference material for the phrase does not contain the words "corollaries" or "corellaries". i have no idea how this word ended up here.

- string operators, in a sense, can also be called "mathematical operators". strings of characters can be defined and studied mathematically. 187.61.153.177 (talk) 00:10, 15 January 2024 (UTC)[reply]