|
the D programming language |
ImLeftFooted
Member #3,935
October 2003
|
Quote: Ahh sorry no, its about the same, except D doesn't have that nasty header include c preprocessor crap to deal with. Yes I enjoy the "nasty header include" feature. Thats not to say its for everybody, but its a feature that I enjoy very much and 'modern languages' appear to be dropping. |
Thomas Fjellstrom
Member #476
June 2000
|
You actually enjoy having to handle the following: #define FOO 100+1 int foo = FOO * 2; // does not do what any sane person would expect And: // bar.h #include "foo.h" // foo.h #include "bar.h" Really? -- |
bamccaig
Member #7,536
July 2006
|
Thomas Fjellstrom said:
#define FOO 100+1 int foo = FOO * 2; // does not do what any sane person would expect
If that's what you want it to do then it's very useful. Otherwise, use parenthesis. Oooh, hard. Thomas Fjellstrom said:
// bar.h #include "foo.h" // foo.h #include "bar.h"
I don't quite understand this part... Those are useless comments and equally useless comments could be applied in D. import foo.bar; // zoo.car import zoo.car; // foo.bar I don't understand the Java package system... Where the hell do they come from and how do I make mine available on the system!? The answer seems to be with the classpath which means I have to do the same thing as include it, but instead I have to add it to the system's classpath or I have to pass it everytime I compile. I think... Stupid! In college when we built GUI apps using NetBeans everything was automatically set up so the programs would run from the IDE... If you tried to compile and run outside the IDE the classpath was missing a ton of packages and that basically meant we couldn't actually use them... How does D's (C♭'s) package system work? Where do the packages come from and how do you add them to a build? P.S. In the time I've spent trying to learn how D does things I've learned that D's documentation sucks. -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
Thomas Fjellstrom
Member #476
June 2000
|
Quote: If that's what you want it to do then it's very useful. Otherwise, use parenthesis. Oooh, hard. Wow. Learn to think once in a while. Its about having to handle that specially. shouldn't be necessary. Quote: I don't quite understand this part... Those are useless comments and equally useless comments could be applied in D. Doubly for this one. -- |
Onewing
Member #6,152
August 2005
|
Quote: I don't quite understand this part... He's mentioning the circular logic of bar.h including foo.h and vice versa, which is confusing. It's like trying to define a word by using a word that is defined by the word you are trying to define. Wha? [edit] see above post. ------------ |
Hard Rock
Member #1,547
September 2001
|
Quote:
Doubly for this one. Does that even work? In any case you can get around this by using forward declaration. Quote: I don't understand the Java package system... Where the hell do they come from and how do I make mine available on the system!? The answer seems to be with the classpath which means I have to do the same thing as include it, but instead I have to add it to the system's classpath or I have to pass it everytime I compile. I think... Stupid! In college when we built GUI apps using NetBeans everything was automatically set up so the programs would run from the IDE... If you tried to compile and run outside the IDE the classpath was missing a ton of packages and that basically meant we couldn't actually use them... I've got a suggestion for you. Why don't you actually try figuring out how it works rather then guessing on something which you apparently know nothing about? In any case they work nearly identical to dlls. You have a global classpath you can put all your libraries in, you can also just drop them next to the application your are running and they will automatically be detected. _________________________________________________ |
spellcaster
Member #1,493
September 2001
|
No, it doesn't work. Unless you take care. That's his point. -- |
bamccaig
Member #7,536
July 2006
|
Thomas Fjellstrom said: Wow. Learn to think once in a while. Its about having to handle that specially. shouldn't be necessary. If you were writing the expression you would need the parenthesis anyway. It's no more work than an expression normally requires. And if you actually want FOO*2 to expand into 100+1*2 then it's useful and necessary. Thomas Fjellstrom said:
Doubly for this one. A few simple preprocessor instructions handle that. It's nothing that should make or break the deadline. If you're going to illustrate that it's better to separate them so that it looks like the code is from different sources. It takes of couple of seconds and makes what you're trying to say clear. bar.h... spellcaster said: At some point, this thread moved from "look how nice D is" to "see, C++ isn't THAT bad, see? SEE?!" No, it went from "D does things nicely" to "C/C++ sucks" to "No, C/C++ doesn't suck". -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
Kitty Cat
Member #2,815
October 2002
|
Quote: And a javadoc-like documentation system is built into the compiler, which means that you'll often get html documentation of the public API by just compiling with the -D argument. It's built in to make it more likely that at least basic docs are available. One could argue, no docs are better than bad/incomplete/incorrect docs. If you're not willing to take the time to make proper documentation, the "documentation" is generally not worth reading (just look at ALSA). -- |
spellcaster
Member #1,493
September 2001
|
The point is not that you can't do something with C/C++. It's that some things are - compared to todays standards - not really elegant. -- |
Thomas Fjellstrom
Member #476
June 2000
|
Quote: Afterall, it's not very often you see a file with a single preprocessor instruction. Its called an example. Pseudo code even. Quote: If you were writing the expression you would need the parenthesis anyway. Not really: const int foo = 1+2; int bar = foo * 2; You can do that now, and should. But people like their pre processor -- |
Matthew Leverton
Supreme Loser
January 1999
|
As Snoopy once said, "Good jokes are wasted on birds." |
bamccaig
Member #7,536
July 2006
|
Thomas Fjellstrom said: Its called an example. Pseudo code even. An unclear example is a poor example. Take a second to make your point clear or expect to clarify. And your example was code. Pseudocode is... bar.h... foo.h... Thomas Fjellstrom said: You can do that now, and should. But people like their pre processor Which you can do in C++ as well... You don't need D for that. -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
Thomas Fjellstrom
Member #476
June 2000
|
It was perfectly clear to everyone else. Why not you? You need hand holding perhaps? -- |
bamccaig
Member #7,536
July 2006
|
Thomas Fjellstrom said: It was perfectly clear to everyone else. Why not you? You need hand holding perhaps? I'm busy with other things. I assumed you were capable of expressing ideas. And "everyone" in this case is like 4 people. Maybe they're just used to interpreting your posts. -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
Thomas Fjellstrom
Member #476
June 2000
|
Yup. Same old bamccaig. Expecting everyone else to hand hold him cause he's "too busy" to think for himself. -- |
Tobias Dammers
Member #2,604
August 2002
|
bamccaig: What are you, mentally challenged? The example is perfectly clear. If you have two files, foo.h and bar.h, each one including the respective other, then you are in a nasty situation. Each file is, by itself, perfectly OK, and you cannot see by looking at any one of them that something is wrong. But use them together, and the compiler will yell at you. And while the example is overly simple (as to clarify things: it is boiled down to the essential part), it illustrates the problem in a way that everybody who has encountered circular dependency issues before will recognize it. #include "child.h" class cParent { protected: cChild* child; int bar; public: int get_bar() const { return bar; } int get_child_foo() const { if (child) return child->get_foo(); else return 0; } }; (child.h) #include "parent.h" class cChild { protected: cParent* parent; int foo; public: int get_foo() const { return foo; } int get_parent_bar() const { if (parent) return parent->get_bar(); else return 42; } }; The solution in this scenario would be to put the function bodies of one class into a separate .cpp file, at least those that use an instance of the other class by value, or dereference a pointer to one. There are 2 problems with this: --- |
bamccaig
Member #7,536
July 2006
|
Tobias Dammers said: What are you, mentally challenged? No. Are you? Tobias Dammers said: The example is perfectly clear...it illustrates the problem in a way that everybody who has encountered circular dependency issues before will recognize it. Perfectly clear. I haven't encountered circular dependency issues before. It sounds silly to have two classes each with a member of each other. Do you have an actual correct model where it's applicable? (I've never modeled anything like that before so it's hard to imagine). -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
spellcaster
Member #1,493
September 2001
|
Quote: Mind you, your example was a million times better than Thomas Fjellstrom's. Please PM me when we start comparing penis sizes. -- |
Hard Rock
Member #1,547
September 2001
|
Quote: It was perfectly clear to everyone else. Why not you? I'll probably look like an idiot for writing this, but initially the way you wrote it I didn't follow what you were trying to show either. I can now understand why you wrote it like that (less bbcode) but in any case.... _________________________________________________ |
ImLeftFooted
Member #3,935
October 2003
|
Tobias said:
Of course it only becomes a problem when a project grows huge, and it isn't obvious at a glance which files exactly cause the problem. And the solution, while simple and easy, isn't a very satisfactory one. Consider these classes: Exactly! and D dumbs down the linking interface so circular dependencies are harder to solve. On a personal note my style prefers to have the class skeleton in its own file (keeping file size down is an ongoing problem for me). |
Jonny Cook
Member #4,055
November 2003
|
I've always thought that if a program required circular referencing, in many cases, it was because of a design flaw. After working with a program written in C# and seeing how many circular references have been made, and how absolutely horrible it is to work with the code, I'm starting to like C/C++s way of making it hard to do circular references. It prevents people from making circular references all the time, and thus, requires them to put more thought into their design. Of course, that's just my theory. It could be wrong. The face of a child can say it all, especially the mouth part of the face. |
bamccaig
Member #7,536
July 2006
|
Dustin Dettmer said: Exactly! and D dumbs down the linking interface so circular dependencies are harder to solve. Are circular dependencies even an issue in D? I thought the whole point was that D eliminates that problem... -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
Onewing
Member #6,152
August 2005
|
Quote: Please PM me when we start comparing penis sizes. "...and I see your Schwartz is as big as mine. Let's see how well you handle it." ------------ |
bamccaig
Member #7,536
July 2006
|
spellcaster said: Please PM me when we start comparing penis sizes. I need an adult! I need an adult! -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
|
|