Working with modules

2013-02-15 Thread Colin Grogan
Hi all, I have a question regarding how to lay out my code. I wish to have a project directory structure that resembles java projects (As I'm comfortable working in that sort of environment For example: $PROJHOME |-/src - Source code |-/lib - third party libraries |-/bin

Re: Working with modules

2013-02-15 Thread Dmitry Olshansky
15-Feb-2013 13:51, Colin Grogan пишет: [snip] This is where my problem occurs. To illustrate: $PROJHOME |-/src |- utils |- Logger.d |- Properties.d |- SSHTool.d |- engine I want to put Logger.d, Properties.d and SSHTool.d into

Re: std.container.RedBlackTree versus C++ std::set

2013-02-15 Thread Namespace
I am starting to understand the difficulty with ref being too restrictive. Some kind of const ref in the language would have helped indeed. But it would probably cause some allocation difficulties for actual constants... or worse? Search for 'auto ref' or right after 'rvalue references' and

Re: Working with modules

2013-02-15 Thread Jonathan M Davis
On Friday, February 15, 2013 10:51:00 Colin Grogan wrote: Does anyone here have any alternatives for me so that in my 'engine' or 'main' classes I can simply write: import utils; and still have my source files neatly laid out in manageable chunks? The only way that you can have a

Re: Working with modules

2013-02-15 Thread Colin Grogan
On Friday, 15 February 2013 at 10:01:35 UTC, Jonathan M Davis wrote: On Friday, February 15, 2013 10:51:00 Colin Grogan wrote: Does anyone here have any alternatives for me so that in my 'engine' or 'main' classes I can simply write: import utils; and still have my source files neatly

Re: Working with modules

2013-02-15 Thread Jonathan M Davis
On Friday, February 15, 2013 11:31:40 Colin Grogan wrote: So, I have my structure like so: $PROJHOME |-src | |-utils | |- Logger.d // contains module utils.Logger |- Props.d // contains module utils.Props |- utils.d //

Re: Working with modules

2013-02-15 Thread Dicebot
On Friday, 15 February 2013 at 10:31:41 UTC, Colin Grogan wrote: Ah, ok. So, I have my structure like so: $PROJHOME |-src |-utils |- Logger.d // contains module utils.Logger |- Props.d // contains module utils.Props |- utils.d // contains module

Re: Working with modules

2013-02-15 Thread Colin Grogan
On Friday, 15 February 2013 at 10:40:57 UTC, Dicebot wrote: On Friday, 15 February 2013 at 10:31:41 UTC, Colin Grogan wrote: Ah, ok. So, I have my structure like so: $PROJHOME |-src |-utils |- Logger.d // contains module utils.Logger |- Props.d // contains module

Re: Working with modules

2013-02-15 Thread Colin Grogan
Ok, I had a minute so I tested it out. I had the following: src/main.d: import utils._; void main(string[] args){ logger l = new logger(); props p = new props(); l.print(); p.print(); } src/utils/_.d module utils._; public import utils.props,

Re: Working with modules

2013-02-15 Thread Jacob Carlborg
On 2013-02-15 12:04, Colin Grogan wrote: Ah ok, now I get it. Note that in Java you declare a package wheres in D you declare a module. If you have something like this in Java: // Baz.java package bar.foo; You would do this in D: // Baz.d module bar.foo.Baz; -- /Jacob Carlborg

rdmd hung?

2013-02-15 Thread Dan
I use emacs and have command that runs rdmd. Very rarely, as a guess maybe one in 100 calls to build, rdmd does not make any progress and I have to kill it. So, a ps -efww shows something like below and over 15 minutes have passed (normally max time to build and run is a couple of seconds)

Re: std.container.RedBlackTree versus C++ std::set

2013-02-15 Thread monarch_dodra
On Thursday, 14 February 2013 at 20:33:21 UTC, Ivan Kazmenko wrote: Rob T wrote: When I look at the std.container source code, it seems that the payload element is passed by value multiple times unnecessarily, so to minimize copy construction you'll have to implement element as a class and

Re: std.container.RedBlackTree versus C++ std::set

2013-02-15 Thread Steven Schveighoffer
On Fri, 15 Feb 2013 12:11:55 -0500, monarch_dodra monarchdo...@gmail.com wrote: Also keep in mind that a b is implemented as two calls to a.opCmp(b), and a.opCmp(b) is itself usually implemented as two calls to something something else (!) Huh? a b is implemented as a.opCmp(b) 0,

Re: std.container.RedBlackTree versus C++ std::set

2013-02-15 Thread Dan
On Friday, 15 February 2013 at 17:42:30 UTC, Steven Schveighoffer wrote: On Fri, 15 Feb 2013 12:11:55 -0500, monarch_dodra monarchdo...@gmail.com wrote: Also keep in mind that a b is implemented as two calls to a.opCmp(b), and a.opCmp(b) is itself usually implemented as two calls to

Re: std.container.RedBlackTree versus C++ std::set

2013-02-15 Thread monarch_dodra
On Friday, 15 February 2013 at 17:42:30 UTC, Steven Schveighoffer wrote: On Fri, 15 Feb 2013 12:11:55 -0500, monarch_dodra monarchdo...@gmail.com wrote: Also keep in mind that a b is implemented as two calls to a.opCmp(b), and a.opCmp(b) is itself usually implemented as two calls to

Re: std.container.RedBlackTree versus C++ std::set

2013-02-15 Thread Dan
On Thursday, 14 February 2013 at 20:53:26 UTC, Jonathan M Davis wrote: And Walter and Andrei both seem to think that having expensive postlbits is a design mistake. The range stuff sort of tries to support it with the move* primitives, but Andrei's been wanting to argue for just assuming

Re: std.container.RedBlackTree versus C++ std::set

2013-02-15 Thread Namespace
When you say things like Andrei was considering phasing out postblits... I get nervous. Can we please have some comments from Andrei/Walter about what the plans are? I'm not asking for the ultimate solution - just to know the general direction and where this issue stands at present. Is there

Re: rdmd hung?

2013-02-15 Thread jerro
No progress is being made. So, my questions: - is this a potential deadlock in rdmd? I believe it attempts to parallelize the work. - has anyone experienced this? I don't remember experiencing this with rdmd, but I have seen something similar with my scripts that were starting processes

Re: std.container.RedBlackTree versus C++ std::set

2013-02-15 Thread Dan
On Thursday, 14 February 2013 at 19:31:36 UTC, Steven Schveighoffer wrote: If it was pass by ref, then rbt.insert(5) would not work. And in fact, I wouldn't want things passed by ref if the element is int. What is the reason for the second objection - is just performance? Is performance

Re: std.container.RedBlackTree versus C++ std::set

2013-02-15 Thread Jonathan M Davis
On Friday, February 15, 2013 20:12:08 Dan wrote: Granted the no rvalue passing is a pain - but is it a big deal in library/generic code? Yes, it's a big deal. Any place that it's part of an API, it's a big deal. It forces you to create what are essentially useless variables all over the place

Re: std.container.RedBlackTree versus C++ std::set

2013-02-15 Thread Namespace
They're not going to do that until they've decided, and AFAIK, they haven't. Attempting to essentially confront them and get them to say what they plan to do generally doesn't get you anywhere - especially since they're unlikely to say much until they actually are planning to do it, and it's

Re: std.container.RedBlackTree versus C++ std::set

2013-02-15 Thread Jonathan M Davis
On Friday, February 15, 2013 21:16:51 Namespace wrote: They're not going to do that until they've decided, and AFAIK, they haven't. Attempting to essentially confront them and get them to say what they plan to do generally doesn't get you anywhere - especially since they're unlikely to

Re: std.container.RedBlackTree versus C++ std::set

2013-02-15 Thread Jonathan M Davis
On Friday, February 15, 2013 21:37:46 Jonathan M Davis wrote: On Friday, February 15, 2013 21:16:51 Namespace wrote: They're not going to do that until they've decided, and AFAIK, they haven't. Attempting to essentially confront them and get them to say what they plan to do

Re: std.container.RedBlackTree versus C++ std::set

2013-02-15 Thread Namespace
Again: My intention was not const. And you're right, but there was so many discussions about const (since dmd 2.057; also in the last few days) and as every discussion here: after page 2 is the topic changed. I'm also very sure that neither Walter nor Andrei see a (important) reason for

Re: std.container.RedBlackTree versus C++ std::set

2013-02-15 Thread Steven Schveighoffer
On Fri, 15 Feb 2013 13:14:21 -0500, Dan dbdavid...@yahoo.com wrote: When you say things like Andrei was considering phasing out postblits... I get nervous. Can we please have some comments from Andrei/Walter about what the plans are? I'm not asking for the ultimate solution - just to know

Re: std.container.RedBlackTree versus C++ std::set

2013-02-15 Thread Jonathan M Davis
On Friday, February 15, 2013 22:41:24 Namespace wrote: Again: My intention was not const. I know. What I'm saying applies in general. And you're right, but there was so many discussions about const (since dmd 2.057; also in the last few days) and as every discussion here: after page 2 is the

Re: std.container.RedBlackTree versus C++ std::set

2013-02-15 Thread Jonathan M Davis
On Friday, February 15, 2013 16:53:36 Steven Schveighoffer wrote: On Fri, 15 Feb 2013 13:14:21 -0500, Dan dbdavid...@yahoo.com wrote: When you say things like Andrei was considering phasing out postblits... I get nervous. Can we please have some comments from Andrei/Walter about what the

Re: std.container.RedBlackTree versus C++ std::set

2013-02-15 Thread Namespace
They definitely agree that it's a problem. They just don't see it as having as high a priority as you do. For me it is not a priority (anymore). I use C++ again. It's just a question of how and when. - Jonathan M Davis Yes as I said: I count the versions. :)

Re: std.container.RedBlackTree versus C++ std::set

2013-02-15 Thread Steven Schveighoffer
On Fri, 15 Feb 2013 13:02:39 -0500, Dan dbdavid...@yahoo.com wrote: On Friday, 15 February 2013 at 17:42:30 UTC, Steven Schveighoffer wrote: On Fri, 15 Feb 2013 12:11:55 -0500, monarch_dodra monarchdo...@gmail.com wrote: Also keep in mind that a b is implemented as two calls to

Re: std.container.RedBlackTree versus C++ std::set

2013-02-15 Thread monarch_dodra
On Friday, 15 February 2013 at 22:06:55 UTC, Steven Schveighoffer wrote: With opcmp: int opCmp(int a, int b) { return a - b; } Genius! Now I feel bad for every time I've done integral opCmp with double ternary operators :(

Re: std.container.RedBlackTree versus C++ std::set

2013-02-15 Thread H. S. Teoh
On Fri, Feb 15, 2013 at 11:49:53PM +0100, monarch_dodra wrote: On Friday, 15 February 2013 at 22:06:55 UTC, Steven Schveighoffer wrote: With opcmp: int opCmp(int a, int b) { return a - b; } Genius! Now I feel bad for every time I've done integral opCmp with double ternary

Re: std.container.RedBlackTree versus C++ std::set

2013-02-15 Thread Jonathan M Davis
On Friday, February 15, 2013 23:49:53 monarch_dodra wrote: On Friday, 15 February 2013 at 22:06:55 UTC, Steven Schveighoffer wrote: With opcmp: int opCmp(int a, int b) { return a - b; } Genius! Now I feel bad for every time I've done integral opCmp with double ternary

Re: std.container.RedBlackTree versus C++ std::set

2013-02-15 Thread Steven Schveighoffer
On Fri, 15 Feb 2013 17:49:53 -0500, monarch_dodra monarchdo...@gmail.com wrote: On Friday, 15 February 2013 at 22:06:55 UTC, Steven Schveighoffer wrote: With opcmp: int opCmp(int a, int b) { return a - b; } Genius! Now I feel bad for every time I've done integral opCmp with double

Re: std.container.RedBlackTree versus C++ std::set

2013-02-15 Thread Steven Schveighoffer
On Fri, 15 Feb 2013 18:41:51 -0500, Steven Schveighoffer schvei...@yahoo.com wrote: There needs to be some extra checking, possibly with the carry flag. And further to that point, my generated assembly for a b also is similarly flawed, so it still may be better to do opCmp. -Steve

Re: std.container.RedBlackTree versus C++ std::set

2013-02-15 Thread bearophile
Steven Schveighoffer: Actually, I'm not as smart as you think ;) There needs to be some extra checking, possibly with the carry flag. For example: 0x7000 - (-0x7000) would be less than zero as a resulting integer. But it would work with shorts or bytes! I remember a page about

Re: Aliasing specialized template stuct in his module leads troubles

2013-02-15 Thread Rob T
One more thing about this. If I leave in the alias in the same module where the template is defined, and also re-define the same alias in the other modules that make use out of it, the libraries will compile OK, but I'll get linking errors when I try to build an executable and link in the

Re: A little of coordination for Rosettacode

2013-02-15 Thread Jos van Uden
On 5-2-2013 23:44, bearophile wrote: Jos van Uden: Partial translation of the universal_turing_machine-Ruby: http://codepad.org/nUXLzAg2 I'd have to first read up on the subject. It's a simple task, just to implement an universal Turing machine. It's a matter of finding a balance between

Re: std.container.RedBlackTree versus C++ std::set

2013-02-15 Thread Dan
On Friday, 15 February 2013 at 23:41:50 UTC, Steven Schveighoffer wrote: In any case, the example was bad, the point that which is better depends on the situation is still correct. The compiler has to do something with ab. I would hope for a fundamental type it can avoid the lowering and just

Re: Aliasing specialized template stuct in his module leads troubles

2013-02-15 Thread Rob T
On Tuesday, 4 September 2012 at 22:46:00 UTC, Ivan Agafonov wrote: I have my library module: module mylib.vector; // alias Vector!(float, 4) Vector4f; struct Vector(T, uint size) { T[size] array = 0; ... }

Re: A little of coordination for Rosettacode

2013-02-15 Thread bearophile
Jos van Uden: The Universal Turing Machine is working. There are many different ways to solve this Task in D. You can write a very strongly typed Ada-like program, or a weakly typed Ruby-like program. Both have advantages and disadvantages (as years pass I am leaning more toward a stronger

Re: A little of coordination for Rosettacode

2013-02-15 Thread bearophile
Instead of using toString() maybe it's better to add a printTape, and let run() return nothing. I have also converted UTM to a struct, because for this little program it doesn't need to be a class (and there is no need of new). I meant the opposite, sorry: printTape() == toString() Bye,

Ping qznc: Re: A little of coordination for Rosettacode

2013-02-15 Thread Jos van Uden
On 5-2-2013 20:45, Jos van Uden wrote: By the way, I think 'Qznc' may want to have a look at 'The dining philosophers': http://rosettacode.org/wiki/Dining_philosophers

Re: A little of coordination for Rosettacode

2013-02-15 Thread bearophile
A first revision, do you like the toString? http://codepad.org/qhH2XpMx - - - - - - - - - - - The modified code contains still an enum that gets converted to char and then to int. I am not going to write code like that in my own production code :-) - - - - - - - - - - - To improve this

Re: Working with modules

2013-02-15 Thread Jeremy DeHaan
On Friday, 15 February 2013 at 10:01:35 UTC, Jonathan M Davis wrote: On Friday, February 15, 2013 10:51:00 Colin Grogan wrote: Does anyone here have any alternatives for me so that in my 'engine' or 'main' classes I can simply write: import utils; and still have my source files neatly

Re: Ping qznc: Re: A little of coordination for Rosettacode

2013-02-15 Thread qznc
On Saturday, 16 February 2013 at 02:23:42 UTC, Jos van Uden wrote: On 5-2-2013 20:45, Jos van Uden wrote: By the way, I think 'Qznc' may want to have a look at 'The dining philosophers': http://rosettacode.org/wiki/Dining_philosophers Am I the new rosetta concurency guy? :) I should find

Re: Working with modules

2013-02-15 Thread Mike Parker
On Saturday, 16 February 2013 at 03:50:12 UTC, Jeremy DeHaan wrote: I was actually going to post a similar question, but it looks like this would be a better place to post! I know that a module can only be defined once, but I feel like there could be times where it would be helpful to be able

Re: Working with modules

2013-02-15 Thread Jonathan M Davis
On Friday, February 15, 2013 20:14:41 Ali Çehreli wrote: On 02/15/2013 07:50 PM, Jeremy DeHaan wrote: I know that a module can only be defined once, but I feel like there could be times where it would be helpful to be able to have the same module defined in separate files There may be