Talk:D (programming language): Difference between revisions

Content deleted Content added
Type naming policy: new section
Not relevant to contents of article.
 
(21 intermediate revisions by 16 users not shown)
Line 1:
{{Afdafd-merged-merge from|GtkD|GtkD|23 August 2011|date=August 2011}}
 
{{archives}}
{{WikiProject Computingbanner shell |class=StartC |importance1=}}
{{WikiProject Computing |importance=Low |software=y |software-importance=Low |science=yes |science-importance=Low |free-software=yes |free-software-importance=Low}}
{{WikiProject Computer science|class=Start
|importance=low
}}
 
Line 16 ⟶ 15:
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:
 
<sourcesyntaxhighlight lang="D">
int main()
{
Line 30 ⟶ 29:
return a;
}
</syntaxhighlight>
</source>
 
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 [http://www.digitalmars.com/d/2.0/function.htm 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.
Line 36 ⟶ 35:
So I would expect that:
 
<sourcesyntaxhighlight lang="D">
pivot = 4;
mySum(3, 5);
</syntaxhighlight>
</source>
would yield 3, but
 
<sourcesyntaxhighlight lang="D">
pivot = 5;
mySum(3, 5);
</syntaxhighlight>
</source>
would yield 8
 
Line 51 ⟶ 50:
 
: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. --[[User:CyberShadow|Vladimir]] ([[User talk:CyberShadow|talk]]) 11:45, 6 November 2010 (UTC)
 
 
::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.
 
<syntaxhighlight lang="D">
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;
}
</syntaxhighlight>
::will not compile, and compiler will report the issue:
 
<syntaxhighlight lang="text">
a.d:10:18: error: immutable function 'a.main.mysum' cannot access mutable data 'pivot'
10 | if (b <= pivot) // ref to enclosing-scope
</syntaxhighlight>
 
::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. [[Special:Contributions/81.6.34.172|81.6.34.172]] ([[User talk:81.6.34.172|talk]]) 20:15, 29 April 2020 (UTC)
 
== Pull the C# reference until examples? ==
Line 65 ⟶ 89:
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)? [[User:SBareSSomErMig|SBareSSomErMig]] ([[User talk:SBareSSomErMig|talk]]) 10:22, 6 March 2013 (UTC)
 
== Another D programming language in the 1980ies ==
== Type naming policy ==
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.
--[[User:Donald j axel|d-axel]] ([[User talk:Donald j axel|talk]]) 04:13, 7 February 2016 (UTC)
Wikipedia mentions the other "D" programming language as "Filetab D".
--[[User:Donald j axel|d-axel]] ([[User talk:Donald j axel|talk]]) 04:15, 7 February 2016 (UTC)
 
== External links modified ==
 
Hello fellow Wikipedians,
 
I have just modified one external link on [[D (programming language)]]. Please take a moment to review [https://en.wikipedia.org/w/index.php?diff=prev&oldid=798650300 my edit]. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit [[User:Cyberpower678/FaQs#InternetArchiveBot|this simple FaQ]] for additional information. I made the following changes:
*Added archive https://web.archive.org/web/20070224161328/http://ddbg.mainia.de/ to http://ddbg.mainia.de/
 
When you have finished reviewing my changes, you may follow the instructions on the template below to fix any issues with the URLs.
 
{{sourcecheck|checked=false|needhelp=}}
 
Cheers.—[[User:InternetArchiveBot|'''<span style="color:darkgrey;font-family:monospace">InternetArchiveBot</span>''']] <span style="color:green;font-family:Rockwell">([[User talk:InternetArchiveBot|Report bug]])</span> 03:22, 3 September 2017 (UTC)
 
== what became of the merger of the articles on gtkd and the d programming language? ==
 
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?
 
[[User:Son of eugene|Son of eugene]] ([[User talk:Son of eugene|talk]]) 20:03, 25 June 2021 (UTC)
 
== Influenced Go? I do not think sol. ==
 
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. [[Special:Contributions/2A02:168:F609:1:BEDA:2803:4006:38FD|2A02:168:F609:1:BEDA:2803:4006:38FD]] ([[User talk:2A02:168:F609:1:BEDA:2803:4006:38FD|talk]]) 17:38, 5 March 2023 (UTC)
: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. [[Special:Contributions/2A02:168:F609:1:BEDA:2803:4006:38FD|2A02:168:F609:1:BEDA:2803:4006:38FD]] ([[User talk:2A02:168:F609:1:BEDA:2803:4006:38FD|talk]]) 18:34, 5 March 2023 (UTC)
 
== usage of 'mathematical corellaries' ==
 
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 "cor'''e'''llaries" seems to be a typo of "cor'''o'''llaries". 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.
I don't think it's future proof name types way they are named currently.
 
- 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.
http://dlang.org/type.html
<pre>
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
</pre>
 
- string operators, in a sense, can also be called "mathematical operators". strings of characters can be defined and studied mathematically. [[Special:Contributions/187.61.153.177|187.61.153.177]] ([[User talk:187.61.153.177|talk]]) 00:10, 15 January 2024 (UTC)
This would be way better naming...
<pre>
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
</pre>
 
:@[[User:187.61.153.177|187.61.153.177]] - [[Help:Editing|Do it. There is nothing or no-one stopping you]], as long as you are trying to improve the encyclopedia. I would recommend implementing the first sentence of what you said. You probably won't see this, but [[WP:BOLD|you can do it]]. <span style="font-family:monospace;background:#368;padding:.2rem;color:white">''[[User:APenguinThatIsSilly|<span style="color:white">APenguinThatIsSilly</span>]]''(''[[User talk:APenguinThatIsSilly|<span style="color:#FEC">"talk"</span>]]'')</span> 21:13, 14 January 2025 (UTC)
Also I added two more there, "largest (un)signed integer implemented in hardware". <br />
triedoutd [[Special:Contributions/188.238.70.207|188.238.70.207]] ([[User talk:188.238.70.207|talk]]) 15:40, 4 September 2013 (UTC)