March 04, 2006 Re: D - more or less power than C++? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kevin Bealer | "Kevin Bealer" <Kevin_member@pathlink.com> wrote in message news:ducrhk$6j3$1@digitaldaemon.com... > foreach(char[] k, foo v; x) { > // print all elements in order > } The wc example shows how to print the elements of an associative array in order. |
March 04, 2006 Re: D - more or less power than C++? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Def | "Def" <Def_member@pathlink.com> wrote in message news:duct3u$atg$1@digitaldaemon.com... > In article <duab09$1arn$1@digitaldaemon.com>, Walter Bright says... > >>I see this often and am a bit perplexed by it. What power do you feel is missing? > > Maybe you're simply looking at the wrong place. It might not be the > language > itself - maybe D is missing a really good and comprehensive tutorial. > Imagine > the C++ crowd that wants to migrate to D, and how they struggle to figure > out > "the D way to do things". And then, when nothings works as expected, they > tend > to say "if D only had [some C++ feature]". Not everyone has fun learning > by > searching the web. ;-) It is my impression that C++ people who find D lacking are trying to compile essentially C++ code in D, instead of looking at D on its own merits. > So with a good D tutorial and documentation that has been written with D > in mind > from the beginning, D might seem as powerful as it actually is to the > people who > are new to D. The documentation certainly could be better. |
March 04, 2006 Re: D - more or less power than C++? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | In article <dud1s8$idk$1@digitaldaemon.com>, Walter Bright says... > > >"Kevin Bealer" <Kevin_member@pathlink.com> wrote in message news:ducrhk$6j3$1@digitaldaemon.com... >> foreach(char[] k, foo v; x) { >> // print all elements in order >> } > >The wc example shows how to print the elements of an associative array in order. Sometimes its good to be able to get the least element, greatest element, and so on, quicker than O(N). PQs can do one or the other, but it's hard to do lookups by value. This is a low priority for most people I suspect. Kevin |
March 04, 2006 Re: D - more or less power than C++? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Derek Parnell | Walter, I know you are a busy person and this might have been missed, so I repeat the question for you. On Sat, 04 Mar 2006 15:02:35 +1100, Walter Bright <newshound@digitalmars.com> wrote: > The private/protected stuff works like it does in C++. I'm not a C++ person so excuse my ignorance please, but are you saying that fully qualified references in C++ will override private/protected attributes? It does this in D. //--- foo.d -- private void Foo() { } // -------------- //--- test.d -- import foo; void main() { foo.Foo(); // Compiles! Foo(); // Doesn't compile. } -- Derek Parnell Melbourne, Australia |
March 04, 2006 Re: D - more or less power than C++? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote: > "Andrew Fedoniouk" <news@terrainformatica.com> wrote in message news:dubfs7$95p$1@digitaldaemon.com... >> >> 1) Again, what will happen if on_scope_success will throw? > > I believe I answered that. Throwing in on_scope is like throwing in a destructor or in a finally block. It's a very bad idea, and will probably produce a double fault exception. The same issue exists with C++. DMD will throw the new exception and the old one will be discarded. .NET (or C# at any rate) has the same basic behavior, though it may be the the original exception that is retained in .NET, I can't remember offhand. I think the current approach is arguably better than a call to terminate, as the C++ approach reduces the general utility of RAII. >> 2) As I said before, implementation of on_scope_success >> seems like artificial to D. In syntax and in implementation. > > If by that you mean it is unique to D, then yes, it is. But it is based on work done by experts in the field who have attempted to bash C++ into doing it, and those experts have reviewed on_scope. They've helped me understand what the issues are, and what the solution should look like, and I've implemented that solution. So I have a lot of confidence that it is the right solution. > > I know that it's unfamiliar, and it took me a while to get it. For what it's worth, Andrei has put all of his articles online at http://erdani.org/publications/ His original article on ScopeGuard is well worth reading. A direct link is here: http://www.cuj.com/documents/s=8000/cujcexp1812alexandr/alexandr.htm Sean |
March 04, 2006 Re: D - more or less power than C++? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote:
> "Def" <Def_member@pathlink.com> wrote in message news:duct3u$atg$1@digitaldaemon.com...
>
>>In article <duab09$1arn$1@digitaldaemon.com>, Walter Bright says...
>>
>>
>>>I see this often and am a bit perplexed by it. What power do you feel is
>>>missing?
>>
>>Maybe you're simply looking at the wrong place. It might not be the language
>>itself - maybe D is missing a really good and comprehensive tutorial. Imagine
>>the C++ crowd that wants to migrate to D, and how they struggle to figure out
>>"the D way to do things". And then, when nothings works as expected, they tend
>>to say "if D only had [some C++ feature]". Not everyone has fun learning by
>>searching the web. ;-)
>
>
> It is my impression that C++ people who find D lacking are trying to compile essentially C++ code in D, instead of looking at D on its own merits.
>
>
>>So with a good D tutorial and documentation that has been written with D in mind
>>from the beginning, D might seem as powerful as it actually is to the people who
>>are new to D.
>
>
> The documentation certainly could be better.
>
>
It took me a while to figure out how to code simple programs in D ..
Learning D isn't hard at all when you have C++/Java background, but finding good D tutorials is!
|
March 05, 2006 Re: D - more or less power than C++? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | "Walter Bright" <newshound@digitalmars.com> wrote in message news:ducnmj$rv$3@digitaldaemon.com... > Right. I discovered this too. For the lack of an existing term, I called this "inspectability", which is defined as being able to tell what code is doing *without* needing to examine declarations or header files. For example, what are the various things that f(x) can mean in C++? (There are quite a few!) Code is not inspectable in C++. Any piece of code in C++, you have essentially no reliable touchstone as to what it is doing without examining all the header files. And in D, f(x) can be visually ambiguous as well - is the parameter in, out, or inout? That's one of the minor niggles I have with out and inout params in D - it's never really obvious when you're using them, so you have to look at the docs to find out. out and inout are required at the call site in C# (or rather, out and "ref"), and it does look pretty and self-documenting. |
March 05, 2006 Re: D - more or less power than C++? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Derek Parnell | In article <op.s5wvjbrq6b8z09@ginger.vic.bigpond.net.au>, Derek Parnell says... > >Walter, >I know you are a busy person and this might have been missed, so I repeat >the question for you. > >On Sat, 04 Mar 2006 15:02:35 +1100, Walter Bright > <newshound@digitalmars.com> wrote: > >> The private/protected stuff works like it does in C++. > > I'm not a C++ person so excuse my ignorance please, but are you saying > that fully qualified references in C++ will override private/protected > attributes? It does this in D. > > //--- foo.d -- > private void Foo() { } > > // -------------- > > //--- test.d -- > import foo; > void main() > { > foo.Foo(); // Compiles! > Foo(); // Doesn't compile. > } > >-- >Derek Parnell >Melbourne, Australia Has this been reported as a bug over in D.bugs? - Dave |
March 05, 2006 Re: D - more or less power than C++? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kevin Bealer | "Kevin Bealer" <Kevin_member@pathlink.com> wrote in message news:dud3g6$lm3$1@digitaldaemon.com... > Sometimes its good to be able to get the least element, greatest element, > and so > on, quicker than O(N). PQs can do one or the other, but it's hard to do > lookups > by value. This is a low priority for most people I suspect. Sometimes, yes. D's AA implementation, however, will work satisfactorilly for 98% of the cases. There's always some case that needs a special setup, and for that, one will need to use a custom user defined type. That's true of the STL as well. |
March 05, 2006 Re: D - more or less power than C++? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | This is not directly related to the language but I think it is essential, it is actually more essential than a few more features: 1. The language needs a good modern multi platform IDE and a great compiler, that does a good error reporting, that can work from a different directory than the root c:\dmd 2. Good documentation (much better than the current one. 3. A good debugger (some people use and need one), it should be intergrated into the IDE. 4. A great library with lots of low level system independent functions (something like .NET class library) but that abstract some OS specific functionality to give a hint: like user information, home folders, etc. 5. Some sort of GUI library even if it is not part of the official specification or distribution. 6. Official support/management for bindings for the essential third party libraries: incl. multimedia, GUIs, etc. 7. Tutorials, samples, etc. Is there any built in XML support? If you have that you'll attract much wider audience, especially beginners, that could be turned down if they bump into the wall of information luck. I know this is a huge task but perhaps you can start some sort of committee to overlook and develop such "standard" features? |
Copyright © 1999-2021 by the D Language Foundation