Re: Module-based programming

2013-07-26 Thread Rikki Cattermole
On Friday, 26 July 2013 at 09:12:27 UTC, Land wrote: I'm confused when it comes to modules. I've read somewhere that modules are basically 'singleton classes' and that anything that doesn't need its own state should not needlessly be put inside a class. But what if I want to create a simple O

Re: mixin string to template - advice needed

2013-07-26 Thread anonymous
On Friday, 26 July 2013 at 20:33:29 UTC, Marek Janukowicz wrote: I have a repetitive piece of code that I'm now generating using string mixin. I humbly ask someone more skilled with D to review the code and help me transforming it into regular template mixin (as I would gladly avoid string mixi

mixin string to template - advice needed

2013-07-26 Thread Marek Janukowicz
Hello I have a repetitive piece of code that I'm now generating using string mixin. I humbly ask someone more skilled with D to review the code and help me transforming it into regular template mixin (as I would gladly avoid string mixin if possible). string flaggedAttr(string type, string n

Re: Fastest way to compare dates using two unix timestamps?

2013-07-26 Thread Jonathan M Davis
On Friday, July 26, 2013 21:51:39 Gary Willoughby wrote: > I'm writing a program that deals a lot with dates in unix > timestamp format. I need to 'normalise' this timestamp to only > give me the date and not the time. To do this i thought of using > only midnight on that day. > > Here is the firs

Fastest way to compare dates using two unix timestamps?

2013-07-26 Thread Gary Willoughby
I'm writing a program that deals a lot with dates in unix timestamp format. I need to 'normalise' this timestamp to only give me the date and not the time. To do this i thought of using only midnight on that day. Here is the first attempt to normalise these dates: protected uint trimU

Re: Should I Use std.ascii.isWhite or std.uni.isWhite?

2013-07-26 Thread Meta
On Friday, 26 July 2013 at 17:58:21 UTC, Dmitry Olshansky wrote: You are spot on. In case you want to further dig into Unicode characters and properties, there is this nice tool: http://unicode.org/cldr/utility/list-unicodeset.jsp?a=%5B%3AN%3A%5D&g= (e.g. this link shows all of 'N' = Number char

Re: Should I Use std.ascii.isWhite or std.uni.isWhite?

2013-07-26 Thread Dmitry Olshansky
26-Jul-2013 09:54, Meta пишет: On Friday, 26 July 2013 at 05:06:45 UTC, Jonathan M Davis wrote: [snip] That makes sense. I know that the first 127 unicode characters are equivalent to the 7-bit ASCII charset, but it confused me that the module is named std.ascii when it actually operates on un

Re: Interesting line in the recent Dr Dobbs article about profiling?

2013-07-26 Thread Dmitry Olshansky
25-Jul-2013 22:15, Gary Willoughby пишет: I've just read the article over at Dr Dobbs by Walter http://www.drdobbs.com/cpp/increasing-compiler-speed-by-over-75/240158941 and this line caught my eye: Even if you know your code well, you're likely wrong about where the performance bottlenecks a

Re: Build / Package system

2013-07-26 Thread Trent
On Thursday, 25 July 2013 at 17:59:23 UTC, Elie Morisse wrote: On Wednesday, 30 May 2012 at 08:13:34 UTC, Sputnik wrote: There is a build and/or package managment system for D2 that is working? I googled, and I only can find things like dsss or cmaked that don't get updated from a long time ago.

Re: Module-based programming

2013-07-26 Thread Ali Çehreli
On 07/26/2013 08:33 AM, Land wrote: > What about inheritance and interfaces, > though? Am I supposed to put all the interface/inherited methods into > the object At least technically, yes. There is no other way for interfaces and function overriding. > and all the other, utility methods, as f

Re: Copying copy?

2013-07-26 Thread monarch_dodra
On Friday, 26 July 2013 at 15:31:06 UTC, bearophile wrote: Dicebot: Not possible, front is 'dchar' for char arrays: So do I have to use foreach loops to fill a char[] lazily? :-) Bye, bearophile You could also use appender. Appender supports it: // import std.array, std.algorithm, std

Re: Module-based programming

2013-07-26 Thread Land
Thanks for all the replies. What about inheritance and interfaces, though? Am I supposed to put all the interface/inherited methods into the object and all the other, utility methods, as free functions? Do I understand that correctly?

Re: Copying copy?

2013-07-26 Thread bearophile
Dicebot: Not possible, front is 'dchar' for char arrays: So do I have to use foreach loops to fill a char[] lazily? :-) Bye, bearophile

Re: Copying copy?

2013-07-26 Thread Dicebot
On Friday, 26 July 2013 at 14:46:23 UTC, bearophile wrote: import std.range, std.algorithm; void main() { char[5] arr; auto r = 5.iota.map!(i => cast(char)(i + 'a')); static assert(is(typeof(r.front) == char)); // OK r.copy(arr[]); // error } Not possible, front is 'dchar' for c

Re: Module-based programming

2013-07-26 Thread Ali Çehreli
On 07/26/2013 05:13 AM, Dicebot wrote: > On Friday, 26 July 2013 at 09:12:27 UTC, Land wrote: >> struct Shader >> { >> // Field >> // Field >> // Field >> } >> >> // Method >> // Method >> // Method >> // Method > > I personally favor this approach whenever possible, it fits nicely

Re: Copying copy?

2013-07-26 Thread monarch_dodra
On Friday, 26 July 2013 at 14:46:23 UTC, bearophile wrote: monarch_dodra: I reacted to your bug entry. Thank you very much for your comments. I am wrong all the time... I have written a small answer. However, copy could be improved with the knowledge that a dchar can be streamed into a s

Re: Copying copy?

2013-07-26 Thread bearophile
monarch_dodra: I reacted to your bug entry. Thank you very much for your comments. I am wrong all the time... I have written a small answer. However, copy could be improved with the knowledge that a dchar can be streamed into a series of chars (EG, the way an appender!(char[]) can handle

Re: Copying copy?

2013-07-26 Thread H. S. Teoh
On Fri, Jul 26, 2013 at 02:48:05PM +0200, monarch_dodra wrote: > On Friday, 26 July 2013 at 12:16:02 UTC, bearophile wrote: > >Ali Çehreli: > > > >>I agree. I would expect copy to maintain the same type. > > > >http://d.puremagic.com/issues/show_bug.cgi?id=10718 > > > >Bye, > >bearophile > > I rea

Re: Module-based programming

2013-07-26 Thread Dicebot
On Friday, 26 July 2013 at 13:11:33 UTC, JS wrote: But what about protection semantics? Access to this? Properties? Virtual functions? Non-public methods should not be free functions. Same goes for virtual ones. Access to this is no different from access to first parameter of function. That

Re: Module-based programming

2013-07-26 Thread John Colvin
On Friday, 26 July 2013 at 13:11:33 UTC, JS wrote: On Friday, 26 July 2013 at 11:58:13 UTC, John Colvin wrote: On Friday, 26 July 2013 at 11:42:25 UTC, JS wrote: On Friday, 26 July 2013 at 09:12:27 UTC, Land wrote: I'm confused when it comes to modules. I've read somewhere that modules are ba

Re: Module-based programming

2013-07-26 Thread JS
On Friday, 26 July 2013 at 11:58:13 UTC, John Colvin wrote: On Friday, 26 July 2013 at 11:42:25 UTC, JS wrote: On Friday, 26 July 2013 at 09:12:27 UTC, Land wrote: I'm confused when it comes to modules. I've read somewhere that modules are basically 'singleton classes' and that anything that d

Re: Copying copy?

2013-07-26 Thread monarch_dodra
On Friday, 26 July 2013 at 12:16:02 UTC, bearophile wrote: Ali Çehreli: I agree. I would expect copy to maintain the same type. http://d.puremagic.com/issues/show_bug.cgi?id=10718 Bye, bearophile I reacted to your bug entry. I don't think copy's behavior should be *changed*. That would vi

Re: Copying copy?

2013-07-26 Thread bearophile
Ali Çehreli: I agree. I would expect copy to maintain the same type. http://d.puremagic.com/issues/show_bug.cgi?id=10718 Bye, bearophile

Re: Should I Use std.ascii.isWhite or std.uni.isWhite?

2013-07-26 Thread bearophile
Jonathan M Davis: Which function you use depends on what you're trying to do. Right. I have just added this: http://d.puremagic.com/issues/show_bug.cgi?id=10717 Bye, bearophile

Re: Module-based programming

2013-07-26 Thread Dicebot
On Friday, 26 July 2013 at 09:12:27 UTC, Land wrote: struct Shader { // Field // Field // Field } // Method // Method // Method // Method I personally favor this approach whenever possible, it fits nicely with UFCS and allows to keep data type signature clean from unrelated st

Re: Module-based programming

2013-07-26 Thread John Colvin
On Friday, 26 July 2013 at 11:42:25 UTC, JS wrote: On Friday, 26 July 2013 at 09:12:27 UTC, Land wrote: I'm confused when it comes to modules. I've read somewhere that modules are basically 'singleton classes' and that anything that doesn't need its own state should not needlessly be put insi

Re: Module-based programming

2013-07-26 Thread JS
On Friday, 26 July 2013 at 09:12:27 UTC, Land wrote: I'm confused when it comes to modules. I've read somewhere that modules are basically 'singleton classes' and that anything that doesn't need its own state should not needlessly be put inside a class. But what if I want to create a simple O

Re: Build / Package system

2013-07-26 Thread QAston
On Wednesday, 30 May 2012 at 08:13:34 UTC, Sputnik wrote: There is a build and/or package managment system for D2 that is working? I googled, and I only can find things like dsss or cmaked that don't get updated from a long time ago. I really need to manage to get a project to compile in Windows

Re: Module-based programming

2013-07-26 Thread Jacob Carlborg
On 2013-07-26 11:12, Land wrote: I'm confused when it comes to modules. I've read somewhere that modules are basically 'singleton classes' and that anything that doesn't need its own state should not needlessly be put inside a class. Modules are not singleton classes. They haven't much to do w

Module-based programming

2013-07-26 Thread Land
I'm confused when it comes to modules. I've read somewhere that modules are basically 'singleton classes' and that anything that doesn't need its own state should not needlessly be put inside a class. But what if I want to create a simple OpenGL shader object. Do I create a class like this: cla

Re: Should I Use std.ascii.isWhite or std.uni.isWhite?

2013-07-26 Thread Jonathan M Davis
On Friday, July 26, 2013 07:54:42 Meta wrote: > Am I right in thinking that std.uni.isNumber > will match things outside of the basic 0..9? Yes. Expect all of the isX functions in std.uni to return true for characters outside of ASCII. - Jonathan M Davis