Re: piping processes

2011-12-01 Thread Regan Heath
On Wed, 30 Nov 2011 23:35:58 -, NMS nathanms...@gmail.com wrote: Is there a cross-platform way to create a new process and get its i/o streams? Like java.lang.Process? No. It different on windows and unix platforms, tho most/many of the unix platforms are similar. std.process is

Re: piping processes

2011-12-01 Thread Dejan Lekic
NMS wrote: Is there a cross-platform way to create a new process and get its i/o streams? Like java.lang.Process? I doubt. However, you can use platform-specific popen() (POSIX) and _popen() (Windows) for that. I recently talked about this on IRC. At the moment Phobos uses system() ,

Re: Formatted date

2011-12-01 Thread Stewart Gordon
On 03/11/2011 23:58, Lishaak Bystroushaak wrote: Hello. Is there any way how to format date with formating strings? snip Yes. See the datetime stuff in http://pr.stewartsplace.org.uk/d/sutil/ Stewart.

Re: piping processes

2011-12-01 Thread Andrej Mitrovic
I can't find my thread in the archives yet, but I made a similar inquiry a few days ago. You can see a few examples for Windows here: https://github.com/AndrejMitrovic/DWinProgramming/tree/master/Samples/Extra/RedirectChildHandle

Re: Formatted date

2011-12-01 Thread Stewart Gordon
On 04/11/2011 00:51, Jonathan M Davis wrote: On Thursday, November 03, 2011 16:58 Lishaak Bystroushaak wrote: Hello. Is there any way how to format date with formating strings? Something like strftime in python; http://docs.python.org/library/datetime.html#strftime-and-strptime-behavior Not

Re: piping processes

2011-12-01 Thread Dejan Lekic
We talked about that too on IRC - the conclusion was - we should have std.pipe module with (at least) AnonymousPipe, and NamedPipe classes.

Re: piping processes

2011-12-01 Thread Regan Heath
On Thu, 01 Dec 2011 11:28:50 -, Dejan Lekic dejan.le...@gmail.com wrote: We talked about that too on IRC - the conclusion was - we should have std.pipe module with (at least) AnonymousPipe, and NamedPipe classes. Definitely. I will have a hunt for my misplaced code but it had some sort

Re: piping processes

2011-12-01 Thread Regan Heath
On Thu, 01 Dec 2011 11:29:52 -, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: I can't find my thread in the archives yet, but I made a similar inquiry a few days ago. You can see a few examples for Windows here:

Re: piping processes

2011-12-01 Thread Andrej Mitrovic
On 12/1/11, Regan Heath re...@netmail.co.nz wrote: I know these are basic examples, but I think in RedirectChildHandle.d, CreateChildProcess, you should (ideally) be closing childStdoutWrite and childStdinRead /after/ CreateProcess. If you don't you get 2 copies of them, one in the child and

Re: piping processes

2011-12-01 Thread Andrej Mitrovic
On 12/1/11, Regan Heath re...@netmail.co.nz wrote: you should (ideally) be closing childStdoutWrite and childStdinRead /after/ CreateProcess. If you don't you get 2 copies of them, one in the child and one in the parent. Ok so I should move CloseHandle(childStdoutWrite) immediately after a

Re: piping processes

2011-12-01 Thread Steven Schveighoffer
On Thu, 01 Dec 2011 06:10:00 -0500, Regan Heath re...@netmail.co.nz wrote: On Wed, 30 Nov 2011 23:35:58 -, NMS nathanms...@gmail.com wrote: Is there a cross-platform way to create a new process and get its i/o streams? Like java.lang.Process? No. It different on windows and unix

Re: piping processes

2011-12-01 Thread Steven Schveighoffer
On Thu, 01 Dec 2011 08:24:25 -0500, Steven Schveighoffer schvei...@yahoo.com wrote: On Thu, 01 Dec 2011 06:10:00 -0500, Regan Heath re...@netmail.co.nz wrote: std.process is rather limited in it's current incarnation but I think Steve is working on a bit update.. It's ready for review,

Re: Concurrency Read/Write and Pure

2011-12-01 Thread Adam
Ahh, ok. Thank you, that helps quite a bit.

Re: writef %d of string

2011-12-01 Thread Stewart Gordon
On 12/10/2011 23:41, bearophile wrote: This code, that a sane language/language implementation refuses at compile-time, runs: It's perfectly legal code, so the best a compiler can correctly do is give a warning. Some C(++) compilers understand printf and will warn if the format string

Re: Formatted date

2011-12-01 Thread Jonathan M Davis
On Thursday, December 01, 2011 11:28:39 Stewart Gordon wrote: On 04/11/2011 00:51, Jonathan M Davis wrote: On Thursday, November 03, 2011 16:58 Lishaak Bystroushaak wrote: Hello. Is there any way how to format date with formating strings? Something like strftime in python;

Abstract functions in child classes

2011-12-01 Thread Adam
Ok, starting to feel like I'm missing something obvious... The abstract keyword in the language reference states: Functions declared as abstract can still have function bodies. This is so that even though they must be overridden, they can still provide �base class functionality.� So, they must

Re: Abstract functions in child classes

2011-12-01 Thread Regan Heath
On Thu, 01 Dec 2011 17:50:48 -, Adam a...@anizi.com wrote: Ok, starting to feel like I'm missing something obvious... This: void main() { Child child = new Child; } also produces the (expected) error. Basically dmd was letting you get away with the abstract class

Re: Abstract functions in child classes

2011-12-01 Thread Adam
I saw that a few minutes after posting as well, but if the only time it's going to actually check the definition is if I instantiate it, well... that's not so good for me if I'm writing implementations to be used at a later date. Hm. Guess we'll see. :)

Re: Abstract functions in child classes

2011-12-01 Thread Simen Kjærås
On Thu, 01 Dec 2011 18:50:48 +0100, Adam a...@anizi.com wrote: Ok, starting to feel like I'm missing something obvious... The abstract keyword in the language reference states: Functions declared as abstract can still have function bodies. This is so that even though they must be overridden,

Re: Abstract functions in child classes

2011-12-01 Thread Steven Schveighoffer
On Thu, 01 Dec 2011 12:58:24 -0500, Regan Heath re...@netmail.co.nz wrote: On Thu, 01 Dec 2011 17:50:48 -, Adam a...@anizi.com wrote: Ok, starting to feel like I'm missing something obvious... This: void main() { Child child = new Child; } also produces the

Re: Abstract functions in child classes

2011-12-01 Thread Adam
I can see the case for a grand-child, but if a class does not provide a definition for an abstract member, is that class not, by association, abstract? Classes become abstract if they are defined within an abstract attribute, or if any of the virtual member functions within it are declared as

Re: Abstract functions in child classes

2011-12-01 Thread Adam
Because the function in this case has no definition in the base abstract class (Parent), but is referenced / called by Parent's members. I did not want Parent to provide a default definition for the function precisely because a large point of the abstract was that method.

Re: Abstract functions in child classes

2011-12-01 Thread Simen Kjærås
On Thu, 01 Dec 2011 19:19:49 +0100, Adam a...@anizi.com wrote: I can see the case for a grand-child, but if a class does not provide a definition for an abstract member, is that class not, by association, abstract? Of course. That's what I said. Or meant, at any rate. Classes become

Profile DMD

2011-12-01 Thread Nick Sabalausky
Is there an easy way to profile DMD similar to how DMD itself has the -profile switch?

Re: Profile DMD

2011-12-01 Thread Timon Gehr
On 12/01/2011 07:42 PM, Nick Sabalausky wrote: Is there an easy way to profile DMD similar to how DMD itself has the -profile switch? Use DMC, I guess. http://www.digitalmars.com/ctg/trace.html

Split a range into equal parts?

2011-12-01 Thread Andrej Mitrovic
Makeshift terrible implementation: import std.range; int[][] split(int[] src, int parts) { int[][] result; int len = src.length / parts; int iter; while (!src.empty) { if (iter == parts-1) { result ~= src[]; break; }

Re: Split a range into equal parts?

2011-12-01 Thread Andrej Mitrovic
Found it: std.range.chunks

.classinfo by Class name

2011-12-01 Thread Adam
Hello again! A third question on D: Is there an argument type I can provide for a method signature which would require a user to provide classinfo or a class name for a class of a particular type? That is, suppose I have a Class called Fruit. Is there some constraint I can impose, either in the

Re: .classinfo by Class name

2011-12-01 Thread Adam
Nevermind - sorry for the clutter. For those who are apparently as dense as I am, this can be roughly accomplished via Template specialization: class Fruit {} class Apple : Fruit {} class Celery {} void mustBeFruit(T : Fruit)() { writeln(T.classinfo.name); } void main() {

Re: .classinfo by Class name

2011-12-01 Thread Justin Whear
.classinfo is for getting information about an object at __runtime__. For the example given here, you don't even need templates: void mustBeFruit(Fruit fruit) { writeln(fruit.classinfo.name); } Since Apple, Banana, and Orange inherit from Fruit, they __are__ Fruit and can be passed to

std.json dynamic initialization of JSONValue

2011-12-01 Thread Kai Meyer
I'm finding std.json extremely well written, with one glaring exception. I can't seem to figure out how to do this: JSONValue root = JSONValue(null, JSON_TYPE.OBJECT); root.object[first_object] = JSONValue(null, JSON_TYPE.OBJECT); root.object[first_string] = JSONValue(first_string,

Re: std.json dynamic initialization of JSONValue

2011-12-01 Thread Adam D. Ruppe
On Thu, Dec 01, 2011 at 03:45:35PM -0700, Kai Meyer wrote: I can't seem to figure out how to do this: You might do it with a template that goes through various types. Check out web.d in here: https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff/ and search for

Re: Formatted date

2011-12-01 Thread Jonathan M Davis
On Thursday, December 01, 2011 22:33:00 Stewart Gordon wrote: On 01/12/2011 16:44, Jonathan M Davis wrote: On Thursday, December 01, 2011 11:28:39 Stewart Gordon wrote: snip I could've sworn it was you I was talking to about the stuff in my library before. Are you an imposter? Why

Re: .classinfo by Class name

2011-12-01 Thread Adam
Ah; I should have clarified - I didn't want an *instance* of the class, just to be able to restrict the signature or use of a method to provide class info specific to a type of class.

Re: Formatted date

2011-12-01 Thread Stewart Gordon
On 01/12/2011 22:57, Jonathan M Davis wrote: snip There's a halfway decent chance that I posted in this thread prior to reading anything about your library or before I looked at it at all. And both Lishaak's and your computers had their clocks set several days fast at the time? Stewart.

Re: Formatted date

2011-12-01 Thread Jonathan M Davis
On Friday, December 02, 2011 00:00:09 Stewart Gordon wrote: On 01/12/2011 22:57, Jonathan M Davis wrote: snip There's a halfway decent chance that I posted in this thread prior to reading anything about your library or before I looked at it at all. And both Lishaak's and your computers

Re: writef %d of string

2011-12-01 Thread bearophile
Stewart Gordon: It's perfectly legal code, If that code is legal, then in my opinion it's the rules of the language that are wrong and in need to be changed :-) Some C(++) compilers understand printf and will warn if the format string doesn't match the arguments, but even this is rare AIUI.

Re: Abstract functions in child classes

2011-12-01 Thread Jacob Carlborg
On 2011-12-01 19:18, Steven Schveighoffer wrote: On Thu, 01 Dec 2011 12:58:24 -0500, Regan Heath re...@netmail.co.nz wrote: On Thu, 01 Dec 2011 17:50:48 -, Adam a...@anizi.com wrote: Ok, starting to feel like I'm missing something obvious... This: void main() { Child child = new Child;

Re: Abstract functions in child classes

2011-12-01 Thread Jacob Carlborg
On 2011-12-01 19:14, Simen Kjærås wrote: On Thu, 01 Dec 2011 18:50:48 +0100, Adam a...@anizi.com wrote: Ok, starting to feel like I'm missing something obvious... The abstract keyword in the language reference states: Functions declared as abstract can still have function bodies. This is so