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

2010-09-09 Thread Kagamin
Andrej Mitrovic Wrote: > foreach (ubyte[] buffer; stdin.byChunk(bufferSize)) > { > immutable(ubyte)[] copy_buffer; > copy(buffer, copy_buffer); > > writeln(copy_buffer); // writes nothing > > send(tid, copy_buffer); > } Isn't destination the

Re: slow runtime

2010-09-09 Thread bearophile
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

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

2010-09-09 Thread bearophile
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

Re: slow runtime

2010-09-09 Thread Jonathan M Davis
On Thursday 09 September 2010 20:54:15 Dr. Smith wrote: > Jonathan, thank you for the quick response. I made some changes as you > suggested and got much more speed. For some code that I'd like to convert > to D, I am exploring the pros and cons of constructing a class library > (versus a C like f

Re: slow runtime

2010-09-09 Thread Jonathan M Davis
On Thursday 09 September 2010 20:17:23 Andrej Mitrovic wrote: > Related: Do stack variables get freed on exit or do they just get marked as > unused by the GC? Because I'm not seeing any memory increase over time. I > guess I have to read more about how allocation works. :p > > Jonathan M Davis Wr

Re: slow runtime

2010-09-09 Thread Dr. Smith
Jonathan, thank you for the quick response. I made some changes as you suggested and got much more speed. For some code that I'd like to convert to D, I am exploring the pros and cons of constructing a class library (versus a C like function library). My code here is just part of that exploration

Re: slow runtime

2010-09-09 Thread Jonathan M Davis
On Thursday 09 September 2010 19:40:47 Dr. Smith wrote: > The class code below runs terribly slow. Conversely, when converted into a > function (albeit returning only one value), it runs fast. Any insights > into this or suggestions to get a function to return multiple types at > once? > > ...li

Re: slow runtime

2010-09-09 Thread Andrej Mitrovic
Related: Do stack variables get freed on exit or do they just get marked as unused by the GC? Because I'm not seeing any memory increase over time. I guess I have to read more about how allocation works. :p Jonathan M Davis Wrote: _every time_ that you use hit or > hot in main(), you're callin

Re: slow runtime

2010-09-09 Thread Jonathan M Davis
On Thursday 09 September 2010 19:40:47 Dr. Smith wrote: > The class code below runs terribly slow. Conversely, when converted into a > function (albeit returning only one value), it runs fast. Any insights > into this or suggestions to get a function to return multiple types at > once? > > ...li

slow runtime

2010-09-09 Thread Dr. Smith
The class code below runs terribly slow. Conversely, when converted into a function (albeit returning only one value), it runs fast. Any insights into this or suggestions to get a function to return multiple types at once? ...library code... module testlib; import std.stdio, std.string; class

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

2010-09-09 Thread 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? iimport std.algorithm, std.concurrency, std.stdio; void main() { enum bufferSize = 4; auto tid = spawn(&fileWriter); // Read loop foreach (ubyte[

Re: Using getchar

2010-09-09 Thread Andrej Mitrovic
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 (sorry cant test right now) > > import std.stdio; > > void main() > {

Re: Using getchar

2010-09-09 Thread Jesse Phillips
On Mon, 06 Sep 2010 17:42:05 -0400, Andrej Mitrovic wrote: > I have some D1 code that I'm transfering to D2, and it's using getchar. > I think I need to flush the buffer or something because the loop tends > to skip: > > import std.c.stdio; > import std.stdio; > > void main() > { > char k; >

Re: Input handling? (newbie alert!)

2010-09-09 Thread Bernard Helyer
On Thu, 09 Sep 2010 18:07:43 -0700, Jonathan M Davis wrote: > Yes std.stdio.readln() would be a much better way to go. However, I'd > suggest using std.conv.parse() rather than std.conv.to(). It's less > picky about whitespace, and it allows you to deal with the case where > you have multiple value

Re: Input handling? (newbie alert!)

2010-09-09 Thread Jonathan M Davis
On Thursday 09 September 2010 17:48:47 Bernard Helyer wrote: > I've not time for a more full answer now (I'll try later), but please, > for the love of God, don't use scanf! As a general hint, use > std.stdio.readln to get input as a string, then use the `to` function > found in std.conv to convert

Re: Input handling? (newbie alert!)

2010-09-09 Thread Bernard Helyer
I've not time for a more full answer now (I'll try later), but please, for the love of God, don't use scanf! As a general hint, use std.stdio.readln to get input as a string, then use the `to` function found in std.conv to convert it into what you want: auto input = readln(); auto asInteg

Re: forks/pipes and std.socket

2010-09-09 Thread Nick Sabalausky
"Steven Schveighoffer" wrote in message news:op.vir82cineav...@localhost.localdomain... > On Thu, 09 Sep 2010 16:25:44 -0400, Nick Sabalausky wrote: > >> "Steven Schveighoffer" wrote in message >> news:op.vipr20xfeav...@localhost.localdomain... >>> On Tue, 07 Sep 2010 16:51:48 -0400, Nick Sabal

Re: std.conv.parse of string literals

2010-09-09 Thread bearophile
Andrej Mitrovic: > This might be related to that bug report you wrote where you could > assign one string literal to another. Right. And recently there's another similar bug report in Bugzilla. So I may add this case just to one of those bug reports. Bye, bearophile

Re: std.conv.parse of string literals

2010-09-09 Thread Andrej Mitrovic
This might be related to that bug report you wrote where you could assign one string literal to another. bearophile Wrote: > > But a string literal isn't a lvalue. This seems all wrong.

std.conv.parse of string literals

2010-09-09 Thread bearophile
This is a small D2 program that uses parse: import std.conv: parse; void main() { parse!int("111"); parse!int("111"); } Gives the error: std.conv.ConvError: std.conv(1122): Can't convert value `' of type string base 2 to type int But a string literal isn't a lvalue. This seems all wron

Re: forks/pipes and std.socket

2010-09-09 Thread Steven Schveighoffer
On Thu, 09 Sep 2010 16:25:44 -0400, Nick Sabalausky wrote: "Steven Schveighoffer" wrote in message news:op.vipr20xfeav...@localhost.localdomain... On Tue, 07 Sep 2010 16:51:48 -0400, Nick Sabalausky wrote: Ah cool, looking forward to it. I was just about ready to launch into a bunch of st

Re: forks/pipes and std.socket

2010-09-09 Thread Nick Sabalausky
"Steven Schveighoffer" wrote in message news:op.vipr20xfeav...@localhost.localdomain... > On Tue, 07 Sep 2010 16:51:48 -0400, Nick Sabalausky wrote: > >> >> Ah cool, looking forward to it. I was just about ready to launch into a >> bunch of std.process improvements myself ;) In the meantime, it

Re: Using IMPLIB with D dll's

2010-09-09 Thread Andrej Mitrovic
Forgive me for my ignorance, I neglected to use the /s switch for IMPLIB: $ implib /s mydll3.lib mydll.dll $ dmd test.d mydll3.lib $ test hello dll world However I still get a .lib file with no symbols if I use IMPLIB with a .def file instead of a .dll file. Is this a bug? Andrej Mitrovic Wrote

Re: Using IMPLIB with D dll's

2010-09-09 Thread Andrej Mitrovic
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 formats that have a 16bit word

Using IMPLIB with D dll's

2010-09-09 Thread Andrej Mitrovic
I'm trying to figure how to use IMPLIB with D DLLs. The DLL example from the samples folder in DMD: dll.d > http://pastebin.com/C9NJtqUV mydll.d > http://pastebin.com/8idbnge0 test.d > http://pastebin.com/6c953BSJ mydll.def > http://pastebin.com/4enbfbc7 First I'll show how to build without usin

Input handling? (newbie alert!)

2010-09-09 Thread Cavalary
Now I guess this has been asked and answered 1000 times before around here, but looking through discussions that don't even seem to thread properly (unless you're in the archive) would just confuse me more, and the few attempts at D tutorials for people who are not already skilled C++ programmers d