D - Example code
- Anon. (14/14) Mar 03 2004 Is there a read source of example code in D? Something a little more ext...
- =?ISO-8859-1?Q?Julio_Jim=E9nez?= (10/32) Mar 03 2004 Please... pick at http://www.digitalmars.com/d/arrays.html
- Ant (15/23) Mar 03 2004 that's old.
- Vathix (11/42) Mar 03 2004 I foreach over associative arrays all the time. There's even an example
- =?ISO-8859-1?Q?Julio_Jim=E9nez?= (63/63) Mar 03 2004 The wc2.d code: (from dmd examples)
- Anon. (11/43) Mar 03 2004 It was "Associative Array Example: word count" at the end of that very p...
- =?ISO-8859-1?Q?Julio_Jim=E9nez?= (19/33) Mar 04 2004 http://dui.sourceforge.net/
- Mike Jolley (11/14) Jun 10 2004 I would like to see a horribly complex problem solved with the full trea...
- Matthew (29/44) Jun 22 2004 Practically: check out the implementations of std.windows.registry.d, an...
- Walter (10/15) Jun 22 2004 enthusiastic
- Sean Kelly (8/12) Jun 22 2004 I'm not sure that C++ *is* more powerful. But discovering the technique...
- Walter (11/23) Jun 22 2004 mixins,
- Matthew (5/20) Jun 22 2004 Haven't time to debate it at the mo; that'll have to wait until next mon...
- Charlie (12/27) Jun 22 2004 As soon as their is a D implementation that is bug free, and usable ( a
- Walter (12/22) Jun 22 2004 than
- kinghajj (5/5) Jun 22 2004 I don't care if D doesn't become the *rage*, I'll use D as long as Walte...
- John Reimer (15/21) Jun 24 2004 A GUI for D is most certainly important, no doubt about that. But D's
- Charlie (3/26) Jun 22 2004 Phew thats a load off, you'll hear no more complaing from me :).
- Matthew (28/60) Jun 22 2004 With respect, I see this as being rather naive. There is a lot of intere...
- Kris (5/7) Jun 22 2004 Uhhh ... there's a boat load of samples over at dsource.org, not to ment...
- Matthew (3/10) Jun 22 2004 Great!
- Charlie (12/88) Jun 22 2004 I see potential as the keyword here, I want to move D from 'potential' t...
- Matthias Becker (23/37) Jun 23 2004 Hmm, currently there is no language avilable _for me_, that is a realy g...
- Sean Kelly (14/18) Jun 23 2004 Not true:
- Andy Friesen (18/33) Jun 23 2004 This isn't quite what Mattias was getting at. Here's a more general
- Sean Kelly (4/20) Jun 23 2004 Ah gotcha. This is the same as the problems with making a non-macro ver...
- Daniel Horn (17/50) Jun 23 2004 You can do this easily with template magic(tm) and automatic template
- Sean Kelly (6/8) Jun 23 2004 I agree that you can get pretty close with traits templates, but that's ...
- Norbert Nemec (9/13) Jun 23 2004 Depends on how you read it:
- Mark Junker (5/9) Jun 25 2004 I also think that D is very interesting and powerful, but IMHO it isn't
Is there a read source of example code in D? Something a little more extensive that those that come with the compiler without being horribly complex. Just some worked examples of using the various new (relative to C) language features. My current block is with hashes (associative arrays). I see from the wc sample that you can iterate a hash by 1) retrieving an array of all the keys in the hash 2) iterating that array using a numeric index 3) using the result (key) from that to index into the hash and retrieve the corresponding value. That works fine, but it requires the duplication of the storage required for the keys, which is expensive for large hashes. I was looking for an iterator something like perl5's "each" keyword? I such a thing possible, planned, hiding or just out of the question? Regards, anon.
Mar 03 2004
Anon. wrote:Is there a read source of example code in D? Something a little more extensive that those that come with the compiler without being horribly complex. Just some worked examples of using the various new (relative to C) language features. My current block is with hashes (associative arrays). I see from the wc sample that you can iterate a hash by 1) retrieving an array of all the keys in the hash 2) iterating that array using a numeric index 3) using the result (key) from that to index into the hash and retrieve the corresponding value. That works fine, but it requires the duplication of the storage required for the keys, which is expensive for large hashes. I was looking for an iterator something like perl5's "each" keyword? I such a thing possible, planned, hiding or just out of the question? Regards, anon.Please... pick at http://www.digitalmars.com/d/arrays.html and learn about Associative Arrays. (not require duplication)... read de wc2.d example :-) About D examples code, if you know about C, only read the language specifications there are a lot of examples (not full programs) but it's very easy to write your owns. More: pick at D links there are many sites with examples and tutorials regards Julio Jiménez
Mar 03 2004
In article <c258cm$1qu7$1 digitaldaemon.com>, =?ISO-8859-1?Q?Julio_Jim=E9nez?= says...Anon. wrote:that's old. (from memory) char[][char[]] hash; foreach ( char[] value ; hash.values ) { printf("value is %.*s\n", value); } check http://www.digitalmars.com/d/statement.html#foreach it's a pity associative arrays are not supported with the other foreach version: foreach ( int|uint, type ; array ) it could be: foreach ( char[] key, char[] value ; hash ) // not valid AntI see from the wc sample that you can iterate a hash by 1) retrieving an array of all the keys in the hash 2) iterating that array using a numeric index 3) using the result (key) from that to index into the hash and retrieve the corresponding value.
Mar 03 2004
Ant wrote:In article <c258cm$1qu7$1 digitaldaemon.com>, =?ISO-8859-1?Q?Julio_Jim=E9nez?= says...I foreach over associative arrays all the time. There's even an example http://www.digitalmars.com/d/statement.html#foreach : double[char[]] a; // index type is char[], value type is double ... foreach (char[] s, double d; a) { printf("a['%.*s'] = %g\n", s, d); } -- Christopher E. MillerAnon. wrote:that's old. (from memory) char[][char[]] hash; foreach ( char[] value ; hash.values ) { printf("value is %.*s\n", value); } check http://www.digitalmars.com/d/statement.html#foreach it's a pity associative arrays are not supported with the other foreach version: foreach ( int|uint, type ; array ) it could be: foreach ( char[] key, char[] value ; hash ) // not valid AntI see from the wc sample that you can iterate a hash by 1) retrieving an array of all the keys in the hash 2) iterating that array using a numeric index 3) using the result (key) from that to index into the hash and retrieve the corresponding value.
Mar 03 2004
In article <c25b2g$1vu0$1 digitaldaemon.com>, Vathix says...I foreach over associative arrays all the time. There's even an example http://www.digitalmars.com/d/statement.html#foreach : double[char[]] a; // index type is char[], value type is double ... foreach (char[] s, double d; a) { printf("a['%.*s'] = %g\n", s, d); }It is on the manuals! I just check the manuals before posting... :( need to check my eyes thanks. Ant
Mar 03 2004
In article <c25b2g$1vu0$1 digitaldaemon.com>, Vathix says...Ant wrote:Great! It seemed strange that a language that is so well thought through in almost every respect should require the contortions shown in the word count example at the end of the Arrays section of the manual. char[][] keys = dictionary.keys;// find all words in dictionary[] for (int i = 0; i < keys.length; i++) { char[] word; word = keys[i]; printf("%3d %.*s\n", dictionary[word], word); } I (now) see that the wc2.d in the samples/d directory uses foreach. Maybe this will act as a reminder for someone to update that page of the manual. FWIW. I still that that an iterator would make sense. Sometimes its isn't convenient to process all the keys of a hash in one loop. A pair of methods: aarray.first aarray.next maybe? Thanks all. Anon.In article <c258cm$1qu7$1 digitaldaemon.com>, =?ISO-8859-1?Q?Julio_Jim=E9nez?= says...I foreach over associative arrays all the time. There's even an example http://www.digitalmars.com/d/statement.html#foreach : double[char[]] a; // index type is char[], value type is double ... foreach (char[] s, double d; a) { printf("a['%.*s'] = %g\n", s, d); }Anon. wrote:that's old. (from memory) char[][char[]] hash; foreach ( char[] value ; hash.values ) { printf("value is %.*s\n", value); } check http://www.digitalmars.com/d/statement.html#foreach it's a pity associative arrays are not supported with the other foreach version: foreach ( int|uint, type ; array ) it could be: foreach ( char[] key, char[] value ; hash ) // not valid AntI see from the wc sample that you can iterate a hash by 1) retrieving an array of all the keys in the hash 2) iterating that array using a numeric index 3) using the result (key) from that to index into the hash and retrieve the corresponding value.-- Christopher E. Miller
Mar 03 2004
The wc2.d code: (from dmd examples) import std.c.stdio; import std.file; int main (char[][] args) { int w_total; int l_total; int c_total; int[char[]] dictionary; printf(" lines words bytes file\n"); foreach (char[] arg; args[1 .. args.length]) { char[] input; int w_cnt, l_cnt, c_cnt; int inword; int wstart; input = cast(char[])std.file.read(arg); for (int j = 0; j < input.length; j++) { char c; c = input[j]; if (c == '\n') ++l_cnt; if (c >= '0' && c <= '9') { } else if (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z') { if (!inword) { wstart = j; inword = 1; ++w_cnt; } } else if (inword) { char[] word = input[wstart .. j]; dictionary[word]++; inword = 0; } ++c_cnt; } if (inword) { char[] w = input[wstart .. input.length]; dictionary[w]++; } printf("%8lu%8lu%8lu %.*s\n", l_cnt, w_cnt, c_cnt, arg); l_total += l_cnt; w_total += w_cnt; c_total += c_cnt; } if (args.length > 2) { printf("--------------------------------------\n%8lu%8lu%8lu total", l_total, w_total, c_total); } printf("--------------------------------------\n"); foreach (char[] word1; dictionary.keys.sort) { printf("%3d %.*s\n", dictionary[word1], word1); } return 0; }
Mar 03 2004
In article <c258cm$1qu7$1 digitaldaemon.com>, =?ISO-8859-1?Q?Julio_Jim=E9nez?= says...Anon. wrote:It was "Associative Array Example: word count" at the end of that very page that gave me my mistaken impression :)Is there a read source of example code in D? Something a little more extensive that those that come with the compiler without being horribly complex. Just some worked examples of using the various new (relative to C) language features. My current block is with hashes (associative arrays). I see from the wc sample that you can iterate a hash by 1) retrieving an array of all the keys in the hash 2) iterating that array using a numeric index 3) using the result (key) from that to index into the hash and retrieve the corresponding value. That works fine, but it requires the duplication of the storage required for the keys, which is expensive for large hashes. I was looking for an iterator something like perl5's "each" keyword? I such a thing possible, planned, hiding or just out of the question? Regards, anon.Please... pick at http://www.digitalmars.com/d/arrays.htmland learn about Associative Arrays. (not require duplication)... read de wc2.d example :-) About D examples code, if you know about C, only read the language specifications there are a lot of examples (not full programs) but it's very easy to write your owns.I've always found it quicker to learn a language by reading through code written by other people with a reasonable amount of expertise than to learn it by piecing together my own code by leaping all over the manula to pick up he pieces. The latter technique tends to lead to mistaken impressions and bad habits.More: pick at D links there are many sites with examples and tutorialsIf you could point me at a few of tehse many sites, that would be really useful.regards Julio Jiménezregards, Anion
Mar 03 2004
Anon. wrote: ...If you could point me at a few of tehse many sites, that would be really useful.http://dui.sourceforge.net/ you can learn about classes and interfacing to C libraries http://int19h.tamb.ru/ some projects and examples http://jcc_7.tripod.com/d/tutor/ Simple D tutorial http://www.dprogramming.com/ Little tutorial and some projects http://www.codemoon.com/cm/dpage.php Programs in D About the wc.d example, remember it's only an example; not the better way to do that.... wc2.d is a little better, but an example too. D give you the freedom to do what you need in your own way. Look at dmd/src/phobos/internal/aaA.d (Implementation of associative array) you can study it and implement the functions you need ;-) No need to wait another one write it for you! Regards, Julioregards Julio Jiménezregards, Anion
Mar 04 2004
In article <c246jl$301q$1 digitaldaemon.com>, Anon. says...Is there a read source of example code in D? Something a little more extensive that those that come with the compiler without being horribly complex. Just some worked examples of using the various new (relative to C) language features.I would like to see a horribly complex problem solved with the full treatment in C++ and D side by side. When I say nontrivial, I mean, I've seen the text-processing stuff and it's some nice syntax, but I could use perl for that. I need to see something big that would require design patterns in C++. D seems to automatically solve some major problems, like header dependencies that would require specific techniques to handle when writing C++. Good job. but there are a lot of unexpected interactions among language features that have been found and the C++ standard has at least tried to address. I'm not giving up on C++ yet. If D can do better than the examples given in "Modern C++ Design", I'm listening.
Jun 10 2004
Practically: check out the implementations of std.windows.registry.d, and the WinSTL reg_key_sequence<> and reg_value_sequence<> classes (ftp://ftp.digitalmars.com/stlsoft-1.7.1.zip). They had the same author - me - and give a pretty good illustration of the respective powers of the two languages, and a fair and unbiased comparison of the effort and results of the implementation a non-trivial problem. Philosophically: I'm not giving up on C++ yet and, while I am *very* enthusiastic about D, I do not seeing it ever replace C++. I wouldn't worry about your having those hard-won skills become redundant. C++ has a long life ahead of it, probably about as long as D's. Where D does have the advantage, however, is that it's easier to learn and teach, and has almost as much power as C++. Finally, you're posting on the wrong NG. This one's obsolete. Try news://news.digitalmars.com/digitalmars.D -- Matthew Wilson Author: "Imperfect C++", Addison-Wesley, 2004 (http://www.imperfectcplusplus.com) Contributing editor, C/C++ Users Journal (http://www.synesis.com.au/articles.html#columns) Director, Synesis Software (www.synesis.com.au) STLSoft moderator (http://www.stlsoft.org) ----------------------------------------------------- "Mike Jolley" <Mike_member pathlink.com> wrote in message news:cabkok$c63$1 digitaldaemon.com...In article <c246jl$301q$1 digitaldaemon.com>, Anon. says...someIs there a read source of example code in D? Something a little more extensive that those that come with the compiler without being horribly complex. Justinworked examples of using the various new (relative to C) language features.I would like to see a horribly complex problem solved with the full treatmentC++ and D side by side. When I say nontrivial, I mean, I've seen the text-processing stuff and it's some nice syntax, but I could use perl for that. I need to see something big that would require design patterns in C++. D seems to automatically solve some major problems, like header dependencies that would require specific techniques to handle when writing C++. Good job. but there are a lot of unexpected interactions among language features that have been found and the C++ standard has at least tried to address. I'm not giving up on C++ yet. If D can do better than the examples given in "Modern C++ Design",I'mlistening.
Jun 22 2004
"Matthew" <admin stlsoft.dot.dot.dot.dot.org> wrote in message news:cb99je$1ugm$1 digitaldaemon.com...Philosophically: I'm not giving up on C++ yet and, while I am *very*enthusiasticabout D, I do not seeing it ever replace C++. I wouldn't worry about yourhavingthose hard-won skills become redundant. C++ has a long life ahead of it,probablyabout as long as D's. Where D does have the advantage, however, is thatit'seasier to learn and teach, and has almost as much power as C++.D has a lot of powerful capabilities that are absent from C++. Why is C++ more powerful? I don't believe it is. For example, you can't do DbC, mixins, nested functions, delegates, etc., in C++. C++'s support for unicode is mostly a disaster. Using gc in C++ is only for experts.
Jun 22 2004
In article <cbag08$sai$1 digitaldaemon.com>, Walter says...D has a lot of powerful capabilities that are absent from C++. Why is C++ more powerful? I don't believe it is. For example, you can't do DbC, mixins, nested functions, delegates, etc., in C++. C++'s support for unicode is mostly a disaster. Using gc in C++ is only for experts.I'm not sure that C++ *is* more powerful. But discovering the techniques that really demonstrate this can take quite a while--it wasn't until maybe 1997 that people really started to explore the full potential of templates. I'm still new enough with D that I find myself frustrated trying to do some things I take for granted in C++, but I think much of that will go away as I learn new techniques. Overall I think D has the potential to be more powerful than C++. Sean
Jun 22 2004
"Sean Kelly" <sean f4.ca> wrote in message news:cbagp2$tg3$1 digitaldaemon.com...In article <cbag08$sai$1 digitaldaemon.com>, Walter says...mixins,D has a lot of powerful capabilities that are absent from C++. Why is C++ more powerful? I don't believe it is. For example, you can't do DbC,thatnested functions, delegates, etc., in C++. C++'s support for unicode is mostly a disaster. Using gc in C++ is only for experts.I'm not sure that C++ *is* more powerful. But discovering the techniquesreally demonstrate this can take quite a while--it wasn't until maybe 1997thatpeople really started to explore the full potential of templates. I'mstill newenough with D that I find myself frustrated trying to do some things Itake forgranted in C++, but I think much of that will go away as I learn newtechniques.Overall I think D has the potential to be more powerful than C++.I think you make a great point. Attempting to do a rote translation of C++ code into D is going to be frustrating; but once one gets used to thinking in D, doing a rote translation of D to C++ is going to be impractical.
Jun 22 2004
"Walter" <newshound digitalmars.com> wrote in message news:cbag08$sai$1 digitaldaemon.com..."Matthew" <admin stlsoft.dot.dot.dot.dot.org> wrote in message news:cb99je$1ugm$1 digitaldaemon.com...Haven't time to debate it at the mo; that'll have to wait until next month. If you like, I can rephrase "has almost as much power as C++" to be "has _nearly_ as many places in the programming world that you can poke it".Philosophically: I'm not giving up on C++ yet and, while I am *very*enthusiasticabout D, I do not seeing it ever replace C++. I wouldn't worry about yourhavingthose hard-won skills become redundant. C++ has a long life ahead of it,probablyabout as long as D's. Where D does have the advantage, however, is thatit'seasier to learn and teach, and has almost as much power as C++.D has a lot of powerful capabilities that are absent from C++. Why is C++ more powerful? I don't believe it is. For example, you can't do DbC, mixins, nested functions, delegates, etc., in C++. C++'s support for unicode is mostly a disaster. Using gc in C++ is only for experts.
Jun 22 2004
As soon as their is a D implementation that is bug free, and usable ( a complier must work 100% everytime), I will agree that D is more powerful than C++. I dont mean to be rude, and know that I love D and hope it will succeed, but I think the window of oppurtunity for D is rapdily shutting. Its been what over 3 years in development ?, and from my perspective its farther from 1.0 than it was 4 months ago. Am I alone in thinking we need _one_ solid release, that won't be antiquated 3 months later ? We ( by we I mean Walter :P ) could probably improve it , and add cool new features forever, and while I don't want to rush it, I'm afraid the clock is ticking. Charlie In article <cbag08$sai$1 digitaldaemon.com>, Walter says..."Matthew" <admin stlsoft.dot.dot.dot.dot.org> wrote in message news:cb99je$1ugm$1 digitaldaemon.com...Philosophically: I'm not giving up on C++ yet and, while I am *very*enthusiasticabout D, I do not seeing it ever replace C++. I wouldn't worry about yourhavingthose hard-won skills become redundant. C++ has a long life ahead of it,probablyabout as long as D's. Where D does have the advantage, however, is thatit'seasier to learn and teach, and has almost as much power as C++.D has a lot of powerful capabilities that are absent from C++. Why is C++ more powerful? I don't believe it is. For example, you can't do DbC, mixins, nested functions, delegates, etc., in C++. C++'s support for unicode is mostly a disaster. Using gc in C++ is only for experts.
Jun 22 2004
"Charlie" <Charlie_member pathlink.com> wrote in message news:cbatrq$1fu2$1 digitaldaemon.com...As soon as their is a D implementation that is bug free, and usable ( a complier must work 100% everytime), I will agree that D is more powerfulthanC++. I dont mean to be rude, and know that I love D and hope it will succeed,but Ithink the window of oppurtunity for D is rapdily shutting. Its been whatover 3years in development ?, and from my perspective its farther from 1.0 thanit was4 months ago. Am I alone in thinking we need _one_ solid release, thatwon't beantiquated 3 months later ? We ( by we I mean Walter :P ) could probably improve it , and add cool new features forever, and while I don't want torushit, I'm afraid the clock is ticking.I hear what you're saying, and I agree. What happened is it became clear that D needed a few more things in order to write the kind of code we need for it. My plan is to finish up the typeinfo changes. Thereafter it will be bug fixes and library work.
Jun 22 2004
I don't care if D doesn't become the *rage*, I'll use D as long as Walter works on it. However, something that could help it *alot* would be to add a standard GUI library into Phobos, hopefully cross-platform for Win32 and Linux/Gtk. People don't want to make command-line apps anymore, esp. not for Win32!
Jun 22 2004
kinghajj wrote:I don't care if D doesn't become the *rage*, I'll use D as long as Walter works on it. However, something that could help it *alot* would be to add a standard GUI library into Phobos, hopefully cross-platform for Win32 and Linux/Gtk. People don't want to make command-line apps anymore, esp. not for Win32!A GUI for D is most certainly important, no doubt about that. But D's current instability is making GUI implementations fall victim to a kind of circular dependency that stifles further progress (what's that western idiom that Walter always uses?... the chicken and egg problem). Creating a complicated and powerful GUI requires a stable language implementation. That's something that D is not quite yet. So what we have here is a case where the language needs libraries, but complicated libraries (like GUI's) need a stable language (one that doesn't break library compilation after each new release). So that, I think, is why everybody is pining away for bug fixes. Apparently bug-fixing is next on Walter's agenda anyway, so hopefully everything will stablize and everyone will be happy, happy, happy. Later, John
Jun 24 2004
Phew thats a load off, you'll hear no more complaing from me :). C In article <cbavs1$1j9h$1 digitaldaemon.com>, Walter says..."Charlie" <Charlie_member pathlink.com> wrote in message news:cbatrq$1fu2$1 digitaldaemon.com...As soon as their is a D implementation that is bug free, and usable ( a complier must work 100% everytime), I will agree that D is more powerfulthanC++. I dont mean to be rude, and know that I love D and hope it will succeed,but Ithink the window of oppurtunity for D is rapdily shutting. Its been whatover 3years in development ?, and from my perspective its farther from 1.0 thanit was4 months ago. Am I alone in thinking we need _one_ solid release, thatwon't beantiquated 3 months later ? We ( by we I mean Walter :P ) could probably improve it , and add cool new features forever, and while I don't want torushit, I'm afraid the clock is ticking.I hear what you're saying, and I agree. What happened is it became clear that D needed a few more things in order to write the kind of code we need for it. My plan is to finish up the typeinfo changes. Thereafter it will be bug fixes and library work.
Jun 22 2004
With respect, I see this as being rather naive. There is a lot of interest in D, and much of that stretches outside what's visible on this forum. While I believe C++ has a long and happy (albeit hard) future ahead of it, C++ is less and less accessible to people who are not already skilled in it. The other "modern" languages/technologies -which I assume you are alluding to - such as .NET and Java are not now, and never will, represent a viable alternative to C++ for the majority of its areas of strength. We will continue to have the choice of doing bulk of non-GUI, non Web-service work done in C or, for the brave/skilled/motivated, C++. This is where D comes in. D is *far* more accessible than C++, has relatively few flaws in comparison to the dumbed-down languages/technologies of Java and .NET, and will be nearly (IMO) as powerful/general-purpose as D. Hence D has a very good chance at becoming the best choice for a great many purposes, and I fail to see anything that is quickly subsuming that potential position. I think that chance is at least 20%, and probably around 40% or more. In my book, that's *well* worth sticking around and finding out. However, I agree that we need to get 1.0 happening, and I hope it can happen within the next 2-3 months. (I intend to get stuck into DTL in July in a big way, with a hope of DTL 1.0 shipping with D 1.0). What would be good would be if there were several non-trivial samples included in the 1.0 distribution. Any takers?? I'll commit to making reggrep robust and friendly if others will also contribute some samples. We also need to get a book on D, but's that's another story ... ;) "Charlie" <Charlie_member pathlink.com> wrote in message news:cbatrq$1fu2$1 digitaldaemon.com...As soon as their is a D implementation that is bug free, and usable ( a complier must work 100% everytime), I will agree that D is more powerful than C++. I dont mean to be rude, and know that I love D and hope it will succeed, but I think the window of oppurtunity for D is rapdily shutting. Its been what over3years in development ?, and from my perspective its farther from 1.0 than itwas4 months ago. Am I alone in thinking we need _one_ solid release, that won'tbeantiquated 3 months later ? We ( by we I mean Walter :P ) could probably improve it , and add cool new features forever, and while I don't want to rush it, I'm afraid the clock is ticking. Charlie In article <cbag08$sai$1 digitaldaemon.com>, Walter says..."Matthew" <admin stlsoft.dot.dot.dot.dot.org> wrote in message news:cb99je$1ugm$1 digitaldaemon.com...Philosophically: I'm not giving up on C++ yet and, while I am *very*enthusiasticabout D, I do not seeing it ever replace C++. I wouldn't worry about yourhavingthose hard-won skills become redundant. C++ has a long life ahead of it,probablyabout as long as D's. Where D does have the advantage, however, is thatit'seasier to learn and teach, and has almost as much power as C++.D has a lot of powerful capabilities that are absent from C++. Why is C++ more powerful? I don't believe it is. For example, you can't do DbC, mixins, nested functions, delegates, etc., in C++. C++'s support for unicode is mostly a disaster. Using gc in C++ is only for experts.
Jun 22 2004
"Matthew" wroteWhat would be good would be if there were several non-trivial samplesincluded inthe 1.0 distribution. Any takers??Uhhh ... there's a boat load of samples over at dsource.org, not to mention all the projects over there. I can't imagine you consider the latter to be trivial <g>
Jun 22 2004
"Kris" <someidiot earthlink.dot.dot.dot.net> wrote in message news:cbb5lh$1sh1$1 digitaldaemon.com..."Matthew" wroteGreat!What would be good would be if there were several non-trivial samplesincluded inthe 1.0 distribution. Any takers??Uhhh ... there's a boat load of samples over at dsource.org, not to mention all the projects over there. I can't imagine you consider the latter to be trivial <g>
Jun 22 2004
With respect, I see this as being rather naive. There is a lot of interest in D, and much of that stretches outside what's visible on this forum.What did i say that was naive, i mentioned nor implied nothing on the interest of D, only that it is _time_ for some soldification.Hence D has a very good chance at becoming the best choice for a great many purposes, and I fail to see anything that is quickly subsuming that potential position.I see potential as the keyword here, I want to move D from 'potential' to its rightful position at number one, and the only way I see that happening is with a solid 1.0.In my book, that's *well* worth sticking around and finding out.Must you take every post as an oppurtunity for shameless self promotion ? This isn't even a complete sentence.However, I agree that we need to get 1.0 happening, and I hope it can happen within the next 2-3 months. (I intend to get stuck into DTL in July in a big way, with a hope of DTL 1.0 shipping with D 1.0).And I am happy for this :).What would be good would be if there were several non-trivial samples included in the 1.0 distribution.JCC has a good tutorial/example base going at www.dsource.org , i think many of these would do well. Charlie In article <cbb4pn$1rd6$1 digitaldaemon.com>, Matthew says...With respect, I see this as being rather naive. There is a lot of interest in D, and much of that stretches outside what's visible on this forum. While I believe C++ has a long and happy (albeit hard) future ahead of it, C++ is less and less accessible to people who are not already skilled in it. The other "modern" languages/technologies -which I assume you are alluding to - such as .NET and Java are not now, and never will, represent a viable alternative to C++ for the majority of its areas of strength. We will continue to have the choice of doing bulk of non-GUI, non Web-service work done in C or, for the brave/skilled/motivated, C++. This is where D comes in. D is *far* more accessible than C++, has relatively few flaws in comparison to the dumbed-down languages/technologies of Java and .NET, and will be nearly (IMO) as powerful/general-purpose as D. Hence D has a very good chance at becoming the best choice for a great many purposes, and I fail to see anything that is quickly subsuming that potential position. I think that chance is at least 20%, and probably around 40% or more. In my book, that's *well* worth sticking around and finding out. However, I agree that we need to get 1.0 happening, and I hope it can happen within the next 2-3 months. (I intend to get stuck into DTL in July in a big way, with a hope of DTL 1.0 shipping with D 1.0). What would be good would be if there were several non-trivial samples included in the 1.0 distribution. Any takers?? I'll commit to making reggrep robust and friendly if others will also contribute some samples. We also need to get a book on D, but's that's another story ... ;) "Charlie" <Charlie_member pathlink.com> wrote in message news:cbatrq$1fu2$1 digitaldaemon.com...As soon as their is a D implementation that is bug free, and usable ( a complier must work 100% everytime), I will agree that D is more powerful than C++. I dont mean to be rude, and know that I love D and hope it will succeed, but I think the window of oppurtunity for D is rapdily shutting. Its been what over3years in development ?, and from my perspective its farther from 1.0 than itwas4 months ago. Am I alone in thinking we need _one_ solid release, that won'tbeantiquated 3 months later ? We ( by we I mean Walter :P ) could probably improve it , and add cool new features forever, and while I don't want to rush it, I'm afraid the clock is ticking. Charlie In article <cbag08$sai$1 digitaldaemon.com>, Walter says..."Matthew" <admin stlsoft.dot.dot.dot.dot.org> wrote in message news:cb99je$1ugm$1 digitaldaemon.com...Philosophically: I'm not giving up on C++ yet and, while I am *very*enthusiasticabout D, I do not seeing it ever replace C++. I wouldn't worry about yourhavingthose hard-won skills become redundant. C++ has a long life ahead of it,probablyabout as long as D's. Where D does have the advantage, however, is thatit'seasier to learn and teach, and has almost as much power as C++.D has a lot of powerful capabilities that are absent from C++. Why is C++ more powerful? I don't believe it is. For example, you can't do DbC, mixins, nested functions, delegates, etc., in C++. C++'s support for unicode is mostly a disaster. Using gc in C++ is only for experts.
Jun 22 2004
"Charlie" <Charlie_member pathlink.com> wrote in message news:cbb6iv$1tuc$1 digitaldaemon.com...D,With respect, I see this as being rather naive. There is a lot of interest inaand much of that stretches outside what's visible on this forum.What did i say that was naive, i mentioned nor implied nothing on the interest of D, only that it is _time_ for some soldification.Hence D has a very good chance at becoming the best choice for a great many purposes, and I fail to see anything that is quickly subsuming that potential position.I see potential as the keyword here, I want to move D from 'potential' to its rightful position at number one, and the only way I see that happening is withsolid 1.0.How about you shove your head up your arse? "In my book" is phraseology for "In my opinion", or "from my point of view". Nothing more.In my book, that's *well* worth sticking around and finding out.Must you take every post as an oppurtunity for shameless self promotion ? This isn't even a complete sentence.
Jun 22 2004
How about you shove your head up your arse?How about you take your head out of yours."In my book" is phraseology for "In my opinion", or "from my point of view". Nothing more.You'll forgive my mistake. Charlie In article <cbb9hh$21ts$2 digitaldaemon.com>, Matthew says..."Charlie" <Charlie_member pathlink.com> wrote in message news:cbb6iv$1tuc$1 digitaldaemon.com...D,With respect, I see this as being rather naive. There is a lot of interest inaand much of that stretches outside what's visible on this forum.What did i say that was naive, i mentioned nor implied nothing on the interest of D, only that it is _time_ for some soldification.Hence D has a very good chance at becoming the best choice for a great many purposes, and I fail to see anything that is quickly subsuming that potential position.I see potential as the keyword here, I want to move D from 'potential' to its rightful position at number one, and the only way I see that happening is withsolid 1.0.How about you shove your head up your arse? "In my book" is phraseology for "In my opinion", or "from my point of view". Nothing more.In my book, that's *well* worth sticking around and finding out.Must you take every post as an oppurtunity for shameless self promotion ? This isn't even a complete sentence.
Jun 23 2004
While I believe C++ has a long and happy (albeit hard) future ahead of it, C++ is less and less accessible to people who are not already skilled in it. The other "modern" languages/technologies -which I assume you are alluding to - such as .NET and Java are not now, and never will, represent a viable alternative to C++ for the majority of its areas of strength. We will continue to have the choice of doing bulk of non-GUI, non Web-service work done in C or, for the brave/skilled/motivated, C++. This is where D comes in. D is *far* more accessible than C++, has relatively few flaws in comparison to the dumbed-down languages/technologies of Java and .NET, and will be nearly (IMO) as powerful/general-purpose as D. Hence D has a very good chance at becoming the best choice for a great many purposes, and I fail to see anything that is quickly subsuming that potential position. I think that chance is at least 20%, and probably around 40% or more. In my book, that's *well* worth sticking around and finding out.Hmm, currently there is no language avilable _for me_, that is a realy good choice "for a great many purposes". A lot of things are just way to complicated to do in languages like C++ and D. I'd love to have te expressivness and power of languages like SML or OCaml. But there are other situations where I simply want a larg OO-model and there C++ or D fit a lot better. Imagine you want to write a function that simply doubles it's argument. In ML it's no problem: fun double x = 2 * x; In C++ you can't even do it as you'd need a typeof to find the return-type. And even in D it's more complicated than it looks like, as the arguments of a function aren't in scope of the returntype (correct me if I'm wrong). so it gets something like: template TheReturnType(T) { alias typeof(2*new T()) TheReturnType; } template doubleFunction (T) { TheReturnType!(T) doubleFunction (T value) { return 2*value; } } I'd like a language that is somewhere inbetween D and SML.
Jun 23 2004
In article <cbc56h$c1n$1 digitaldaemon.com>, Matthias Becker says...Imagine you want to write a function that simply doubles it's argument. In ML it's no problem: fun double x = 2 * x; In C++ you can't even do it as you'd need a typeof to find the return-type.Not true: template<typename T> T Double( T val ) { return val * 2; } int x = 5; x = Double( x ); And in D: template(T) { T Double( T val ) { return val * 2; } } int x = 5; x = Double!(typeof(x))( x ); Template functions are one place where I still consider C++ superior to D. Sean
Jun 23 2004
Sean Kelly wrote:In article <cbc56h$c1n$1 digitaldaemon.com>, Matthias Becker says...This isn't quite what Mattias was getting at. Here's a more general example of the same notion: In ML: fun multiply x y = x * y; And in D: template ReturnType(A, B) { alias typeof(A.init*B.init) ReturnType; } template multiply(A, B) { ReturnType!(A, B) multiply(A a, B b) { return a * b; } } This form will properly deduce the return type regardless of the types of A and B. (this is only an issue when they aren't the same) C++ is utterly helpless in this regard, since it doesn't have typeof. -- andyImagine you want to write a function that simply doubles it's argument. In ML it's no problem: fun double x = 2 * x; In C++ you can't even do it as you'd need a typeof to find the return-type.Not true: [... code ...] Template functions are one place where I still consider C++ superior to D.
Jun 23 2004
In article <cbcbuu$mre$1 digitaldaemon.com>, Andy Friesen says...This isn't quite what Mattias was getting at. Here's a more general example of the same notion: In ML: fun multiply x y = x * y; And in D: template ReturnType(A, B) { alias typeof(A.init*B.init) ReturnType; } template multiply(A, B) { ReturnType!(A, B) multiply(A a, B b) { return a * b; } } This form will properly deduce the return type regardless of the types of A and B. (this is only an issue when they aren't the same) C++ is utterly helpless in this regard, since it doesn't have typeof.Ah gotcha. This is the same as the problems with making a non-macro version of min and max work correctly in C++. Sean
Jun 23 2004
You can do this easily with template magic(tm) and automatic template instantiation in C++ Check it out http://cvs.sourceforge.net/viewcvs.py/brook/brook/include/brtvector.hpp http://cvs.sourceforge.net/viewcvs.py/brook/brook/include/type_promotion.hpp type promotion sets up the casting order then brtvector uses it That's what I did :-) This is across Vector Types as well as across types of vectors (int,float)->float (double,float)->double ... ... it would have been a LOT neater if you could have partial specialization--but VC6 and gcc-2.95 didn't support that and those were some of my targets Sean Kelly wrote:In article <cbcbuu$mre$1 digitaldaemon.com>, Andy Friesen says...This isn't quite what Mattias was getting at. Here's a more general example of the same notion: In ML: fun multiply x y = x * y; And in D: template ReturnType(A, B) { alias typeof(A.init*B.init) ReturnType; } template multiply(A, B) { ReturnType!(A, B) multiply(A a, B b) { return a * b; } } This form will properly deduce the return type regardless of the types of A and B. (this is only an issue when they aren't the same) C++ is utterly helpless in this regard, since it doesn't have typeof.Ah gotcha. This is the same as the problems with making a non-macro version of min and max work correctly in C++. Sean
Jun 23 2004
In article <cbcjdn$13dp$1 digitaldaemon.com>, Daniel Horn says...You can do this easily with template magic(tm) and automatic template instantiation in C++I agree that you can get pretty close with traits templates, but that's far from a simple solution. It also becomes more complicated once user defined types are involved. Especially since all that works is just trying to replicate a one line macro :) Sean
Jun 23 2004
Walter wrote:D has a lot of powerful capabilities that are absent from C++. Why is C++ more powerful? I don't believe it is. For example, you can't do DbC, mixins, nested functions, delegates, etc., in C++. C++'s support for unicode is mostly a disaster. Using gc in C++ is only for experts.Depends on how you read it: * "D is more powerful than C++ in general" - definitely * "D is more powerful than C++ in every respect" - not yet. There is a number of points lacking. Most important from my perspective: Full support for expression templates. To be more specific: -> implicit instantiation -> casting overloading for structs and/or struct constructors (static opCall is a crude hack but insufficient in some cases)
Jun 23 2004
Walter schrieb:D has a lot of powerful capabilities that are absent from C++. Why is C++ more powerful? I don't believe it is. For example, you can't do DbC, mixins, nested functions, delegates, etc., in C++. C++'s support for unicode is mostly a disaster. Using gc in C++ is only for experts.I also think that D is very interesting and powerful, but IMHO it isn't ready for productional use yet. Best regards, Mark Junker
Jun 25 2004