Re: slow runtime

2010-09-10 Thread Andrej Mitrovic
No worries, I'm just investigating. I don't need real-time performance any time soon. :) I have seen a pluggable .NET system that has to run in real-time. If that's possible in .net, I'm sure it will be possible in D (if it isn't already). Thanks for all your input! On Sat, Sep 11, 2010 at 5:23

Re: slow runtime

2010-09-10 Thread Jonathan M Davis
On Friday 10 September 2010 19:40:10 Andrej Mitrovic wrote: > What about gc.disable() and gc.enable() ? If I'm sure that I won't > allocate anything within a section of code and I have to guarantee > realtime performance, then I could disable the gc temporarily. > Although this is not exactly what

Re: slow runtime

2010-09-10 Thread Andrej Mitrovic
This page might need to be updated soon: http://www.digitalmars.com/d/2.0/memory.html It refers to custom allocators, overloading new and delete, and using scope for stack allocation. On Sat, Sep 11, 2010 at 4:40 AM, Andrej Mitrovic wrote: > What about gc.disable() and gc.enable() ? If I'm sure

Re: slow runtime

2010-09-10 Thread Andrej Mitrovic
What about gc.disable() and gc.enable() ? If I'm sure that I won't allocate anything within a section of code and I have to guarantee realtime performance, then I could disable the gc temporarily. Although this is not exactly what it states in the section on memory management: "Call std.gc.disable

Re: slow runtime

2010-09-10 Thread Jonathan M Davis
On Friday 10 September 2010 17:36:06 Andrej Mitrovic wrote: > This is why I'm happy to see some people (Leandro in particular) are > already working on different GC designs for D. :) > > So to evade the GC's pauses as much as possible, one would stick with > using structs or preallocate all needed

Re: slow runtime

2010-09-10 Thread Andrej Mitrovic
This is why I'm happy to see some people (Leandro in particular) are already working on different GC designs for D. :) So to evade the GC's pauses as much as possible, one would stick with using structs or preallocate all needed data before a critical section? I'll have to get more into that event

Re: Input handling? (newbie alert!)

2010-09-10 Thread Jonathan M Davis
On Friday 10 September 2010 09:47:47 bearophile wrote: > Cavalary: > > No idea what got into me to try to teach myself some programming > > (and particularly something as advanced as D) these days. > > With D you may learn some ideas of informatics. > > Bye, > bearophile You mean computer scienc

Re: slow runtime

2010-09-10 Thread Jonathan M Davis
On Friday 10 September 2010 09:44:10 bearophile wrote: > Andrej Mitrovic: > > So does that mean the GC doesn't make any pauses, unless it requires more > > memory from the OS? > > When you ask memory to the GC, it may perform collections, so it performs > some computations, even if no new memory g

Re: assoc. array sort or preserve order

2010-09-10 Thread Jesse Phillips
Dr. Smith Wrote: > Is there a way to preserve an array's original order, or to sort an assoc arr > by key? No, Associative arrays can not preserve this for performance reasons. Though you can do the following. import std.algorithm; import std.stdio; void main() { double [string][string] val

assoc. array sort or preserve order

2010-09-10 Thread Dr. Smith
Is there a way to preserve an array's original order, or to sort an assoc arr by key? With code like the following, the values of the string indices allow foreach to needlessly re-order the array: ... double[string][string] val; ... foreach(string1, row; val) { foreach(string2, col; row) { wr

Re: forks/pipes and std.socket

2010-09-10 Thread Nick Sabalausky
"Steven Schveighoffer" wrote in message news:op.vitle0kgeav...@localhost.localdomain... > On Thu, 09 Sep 2010 18:29:55 -0400, Nick Sabalausky wrote: > > >> Maybe the OS is just allowing me to use the wrong file descriptor? > > OK, after downloading the latest dmd, testing your code, and perplexi

Re: Input handling? (newbie alert!)

2010-09-10 Thread Jesse Phillips
Cavalary Wrote: > Ruby code (can't break it, if you enter floats it just rounds > down, if you enter non-numbers it just assumes zero, so no errors): Since you got your answer I would just like to point out that this is not the philosophy driving D. If you are storing to an int what you give it

Re: Input handling? (newbie alert!)

2010-09-10 Thread bearophile
Cavalary: > No idea what got into me to try to teach myself some programming > (and particularly something as advanced as D) these days. With D you may learn some ideas of informatics. Bye, bearophile

Re: slow runtime

2010-09-10 Thread bearophile
Andrej Mitrovic: > So does that mean the GC doesn't make any pauses, unless it requires more > memory from the OS? When you ask memory to the GC, it may perform collections, so it performs some computations, even if no new memory gets asked to the OS. Bye, bearophile

Re: Using getchar

2010-09-10 Thread Andrej Mitrovic
Yeah, there's a different way of waiting for an actual key press. I've done it in Python once. But this code was from a dsource tutorial, I didn't write it. :) I'll find a way to do it properly. Rory McGuire Wrote: > Not sure how you'd make it so that you don't have to wait for the > return pre

Re: ubyte[] -> immutable(ubyte)[]

2010-09-10 Thread Andrej Mitrovic
Yeah, one would think the destination is on the left (just like the standard C way of doing it), but it's not. I checked it in the docs and the source. And idup works, thanks. Kagamin Wrote: > Andrej Mitrovic Wrote: > > > foreach (ubyte[] buffer; stdin.byChunk(bufferSize)) > > { > >

Re: ubyte[] -> immutable(ubyte)[]

2010-09-10 Thread Andrej Mitrovic
Ah, idup. Too obvious, but I missed it. Thanks. Pelle Wrote: > std.algorithm.copy will copy an input range into an output range. An > array is a valid output range, but does not append as you seem to > expect. Instead, it fills the array. > > int[] a = new int[](3); > copy([1,2,3],a); > assert

Re: ubyte[] -> immutable(ubyte)[]

2010-09-10 Thread Andrej Mitrovic
bearophile Wrote: > Andrej Mitrovic: > > I'm trying to use algorithm.copy, but I get back nothing in the copy > > buffer. How do I to copy an array of ubyte's? > > a[] = b[]; > > Bye, > bearophile No, that wouldn't work. It complains about conversion from mutable to immutable. idup works fin

Re: slow runtime

2010-09-10 Thread Andrej Mitrovic
Let's see if I got this right. The GC asks for some memory from the OS, and keeps it in a pool. Then when we have to allocate an array, we take some memory from the GC pool. And when we no longer need the array, the memory gets put back into the pool to be reused. So does that mean the GC doesn'

Re: Question about typeof(this)

2010-09-10 Thread Pelle
On 09/10/2010 03:20 PM, Jacob Carlborg wrote: On 2010-09-07 22:32, Don wrote: Jacob Carlborg wrote: On 2010-09-07 17:29, Don wrote: Jacob Carlborg wrote: I'm reading http://www.digitalmars.com/d/2.0/declaration.html#Typeof where it says: "typeof(this) will generate the type of what this woul

Re: Using getchar

2010-09-10 Thread Jesse Phillips
On Thu, 09 Sep 2010 21:44:43 -0400, Andrej Mitrovic wrote: > Jesse Phillips Wrote: > >> Hello, >> >> I didn't get much feedback on what was thought about it. I think I'll >> try the Phobos mailing list... > > Okay, give it a try. :) > >> without my library the code would look something like (s

Re: forks/pipes and std.socket

2010-09-10 Thread Steven Schveighoffer
On Thu, 09 Sep 2010 18:29:55 -0400, Nick Sabalausky wrote: Maybe the OS is just allowing me to use the wrong file descriptor? OK, after downloading the latest dmd, testing your code, and perplexing a while, then reading the source of phobos, I realized that you are using std.stream.File,

Re: Question about typeof(this)

2010-09-10 Thread Jacob Carlborg
On 2010-09-07 22:32, Don wrote: Jacob Carlborg wrote: On 2010-09-07 17:29, Don wrote: Jacob Carlborg wrote: I'm reading http://www.digitalmars.com/d/2.0/declaration.html#Typeof where it says: "typeof(this) will generate the type of what this would be in a non-static member function, even if n

Re: Input handling? (newbie alert!)

2010-09-10 Thread Cavalary
Well, I was just looking through examples, and if those used scanf I assumed that was the way to go... Thanks, actually learned a few more things out of this (auto and try). No idea what the parameter after catch is supposed to do, what cast is or how to use parse since it was just mentioned, but a

Re: Using getchar

2010-09-10 Thread Rory McGuire
Its not skipping its looping on "a\r\n" if you're on windows. Linux it does the same but only "a\n". Not sure how you'd make it so that you don't have to wait for the return press. Probably has something to do with console settings, which are probably platform dependent. -Rory Andrej Mitrovic

Re: Using IMPLIB with D dll's

2010-09-10 Thread Don
Andrej Mitrovic wrote: One other thing. I'm trying to use a tool called objconv, it allows modification of .lib files, e.g. adding aliases to existing symbols. I was trying to add aliases to existing symbols and make them have underscores, but the tool complains that I can't use OMF file forma

Re: slow runtime

2010-09-10 Thread Pelle
On 09/10/2010 10:17 AM, Jonathan M Davis wrote: On Friday 10 September 2010 00:50:32 bearophile wrote: Jonathan M Davis: Aren't they _always_ on the heap? void main() { int[10] a; int[] b = a[]; } Bye, bearophile Ah, good point. When you have a slice of a static array as opposed

Re: ubyte[] -> immutable(ubyte)[]

2010-09-10 Thread Pelle
On 09/10/2010 04:40 AM, Andrej Mitrovic wrote: I'm trying to use algorithm.copy, but I get back nothing in the copy buffer. How do I to copy an array of ubyte's? iimport std.algorithm, std.concurrency, std.stdio; void main() { enum bufferSize = 4; auto tid = spawn(&

Re: slow runtime

2010-09-10 Thread Jonathan M Davis
On Friday 10 September 2010 00:50:32 bearophile wrote: > Jonathan M Davis: > > Aren't they _always_ on the heap? > > void main() { > int[10] a; > int[] b = a[]; > } > > Bye, > bearophile Ah, good point. When you have a slice of a static array as opposed to a dynamic arra allocated with

Re: slow runtime

2010-09-10 Thread bearophile
Jonathan M Davis: > Aren't they _always_ on the heap? void main() { int[10] a; int[] b = a[]; } Bye, bearophile

Re: slow runtime

2010-09-10 Thread Jonathan M Davis
On Thursday 09 September 2010 23:23:45 bearophile wrote: > Jonathan M Davis: > > Now, dynamic arrays live on the stack, even if their references don't, > > Dynamic arrays are generally on the heap. > > Bye, > bearophile Aren't they _always_ on the heap? Their references are obviously on the stac