Re: char e string em linguagem D

2017-07-13 Thread dark777 via Digitalmars-d-learn
On Thursday, 13 July 2017 at 22:30:29 UTC, crimaniak wrote: On Thursday, 13 July 2017 at 21:49:40 UTC, dark777 wrote: Pessoal eu fiz o seguinte programa em C++. https://pastebin.com/CvVv6Spn porem tentei fazer o equivalente em D mas nao entendi muito bem... https://pastebin.com/2xw9geRR

Re: nogc string concatenation?

2017-07-13 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 14 July 2017 at 00:40:38 UTC, FoxyBrown wrote: Anyone have an efficient implementation that is easy to use? If you are OK with just a range spanning the two or more strings, then you could use chain as is.

Re: WTF is going on! Corrupt value that is never assigned

2017-07-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 14 July 2017 at 00:33:12 UTC, FoxyBrown wrote: What I'm trying to do is fairly straightforward but I've wasted nearly 2 days on it. //added this so it would all compile import core.sys.windows.windows; import core.stdc.stdio; import core.stdc.stdlib; import std.stdio; import

nogc string concatenation?

2017-07-13 Thread FoxyBrown via Digitalmars-d-learn
Anyone have an efficient implementation that is easy to use?

Re: WTF is going on! Corrupt value that is never assigned

2017-07-13 Thread FoxyBrown via Digitalmars-d-learn
On Thursday, 13 July 2017 at 23:30:39 UTC, Moritz Maxeiner wrote: On Thursday, 13 July 2017 at 22:53:45 UTC, FoxyBrown wrote: On Thursday, 13 July 2017 at 20:35:19 UTC, Moritz Maxeiner wrote: On Thursday, 13 July 2017 at 18:22:34 UTC, FoxyBrown wrote: The following code is pretty screwed up,

Re: WTF is going on! Corrupt value that is never assigned

2017-07-13 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 13 July 2017 at 22:53:45 UTC, FoxyBrown wrote: On Thursday, 13 July 2017 at 20:35:19 UTC, Moritz Maxeiner wrote: On Thursday, 13 July 2017 at 18:22:34 UTC, FoxyBrown wrote: The following code is pretty screwed up, even though it doesn't look like it. I have a buf, a simple malloc

Re: WTF is going on! Corrupt value that is never assigned

2017-07-13 Thread FoxyBrown via Digitalmars-d-learn
On Thursday, 13 July 2017 at 20:35:19 UTC, Moritz Maxeiner wrote: On Thursday, 13 July 2017 at 18:22:34 UTC, FoxyBrown wrote: The following code is pretty screwed up, even though it doesn't look like it. I have a buf, a simple malloc which hold the results of a win32 call. I am then trying to

Re: char e string em linguagem D

2017-07-13 Thread Basile B. via Digitalmars-d-learn
On Thursday, 13 July 2017 at 22:30:29 UTC, crimaniak wrote: On Thursday, 13 July 2017 at 21:49:40 UTC, dark777 wrote: char[] stalman() { return cast(char[])` ((__-^^-,-^^-__)) *---***---* *--|o o|--*

Re: char e string em linguagem D

2017-07-13 Thread crimaniak via Digitalmars-d-learn
On Thursday, 13 July 2017 at 21:49:40 UTC, dark777 wrote: Pessoal eu fiz o seguinte programa em C++. https://pastebin.com/CvVv6Spn porem tentei fazer o equivalente em D mas nao entendi muito bem... https://pastebin.com/2xw9geRR alguem poderia me ajudar? Se acepta utilizar intervalos en

char e string em linguagem D

2017-07-13 Thread dark777 via Digitalmars-d-learn
Pessoal eu fiz o seguinte programa em C++. https://pastebin.com/CvVv6Spn porem tentei fazer o equivalente em D mas nao entendi muito bem... https://pastebin.com/2xw9geRR alguem poderia me ajudar?

Re: WTF is going on! Corrupt value that is never assigned

2017-07-13 Thread ag0aep6g via Digitalmars-d-learn
On 07/13/2017 08:22 PM, FoxyBrown wrote: res = EnumServicesStatusExW(schSCManager, SC_ENUM_TYPE.SC_ENUM_PROCESS_INFO, servicesType, SERVICE_STATE_ALL, cast(ubyte*)buf, 5, , , , cast(const(char)*)null); The cast to `char*` here looks odd. The 'W' suffix in the function name

Re: Read from terminal when enter is pressed, but do other stuff in the mean time...

2017-07-13 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 13 July 2017 at 15:52:57 UTC, Dustmight wrote: How do I read in input from the terminal without sitting there waiting for it? I've got code I want to run while there's no input, and then code I want to act on input when it comes in. How do I do both these things? As Stefan

Re: WTF is going on! Corrupt value that is never assigned

2017-07-13 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 13 July 2017 at 18:22:34 UTC, FoxyBrown wrote: The following code is pretty screwed up, even though it doesn't look like it. I have a buf, a simple malloc which hold the results of a win32 call. I am then trying to copy over the data in buf to a D struct. But when copying the

Re: Silly struct behaviour

2017-07-13 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jul 13, 2017 at 06:48:27PM +, JN via Digitalmars-d-learn wrote: > On Thursday, 13 July 2017 at 18:09:46 UTC, H. S. Teoh wrote: > > > > It's not quite so simple. Consider for example: > > > > struct Foo { int bar; } > > struct Oof { int bar; } > > > > void process(Foo

Re: Silly struct behaviour

2017-07-13 Thread JN via Digitalmars-d-learn
On Thursday, 13 July 2017 at 18:09:46 UTC, H. S. Teoh wrote: It's not quite so simple. Consider for example: struct Foo { int bar; } struct Oof { int bar; } void process(Foo foo) { } void process(Oof oof) { formatDisk(); } void main() {

Re: Silly struct behaviour

2017-07-13 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 13 July 2017 at 18:45:45 UTC, JN wrote: I know that's a wrong syntax, I was just showing an example. Yes, here it will work, but if you want to initialize only some fields (poor man's keyword arguments), you can't use the default constructor. easily fixable by using

WTF is going on! Corrupt value that is never assigned

2017-07-13 Thread FoxyBrown via Digitalmars-d-learn
The following code is pretty screwed up, even though it doesn't look like it. I have a buf, a simple malloc which hold the results of a win32 call. I am then trying to copy over the data in buf to a D struct. But when copying the strings, the buf location changes, screwing up the copying

Re: Silly struct behaviour

2017-07-13 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jul 13, 2017 at 06:07:31PM +, JN via Digitalmars-d-learn wrote: > Consider: > > struct Foo > { > int bar; > } > > void processFoo(Foo foo) > { > } > > void main() > { > Foo f = {bar: 5}; > processFoo(f);// ok > processFoo(Foo(5)); //

Silly struct behaviour

2017-07-13 Thread JN via Digitalmars-d-learn
Consider: struct Foo { int bar; } void processFoo(Foo foo) { } void main() { Foo f = {bar: 5}; processFoo(f);// ok processFoo(Foo(5)); // ok processFoo({bar: 5}); // fail processFoo(Foo({bar: 5}));// fail }

Re: Read from terminal when enter is pressed, but do other stuff in the mean time...

2017-07-13 Thread Ali Çehreli via Digitalmars-d-learn
On 07/13/2017 08:52 AM, Dustmight wrote: How do I read in input from the terminal without sitting there waiting for it? I've got code I want to run while there's no input, and then code I want to act on input when it comes in. How do I do both these things? If you're fine with buffered input,

Re: Read from terminal when enter is pressed, but do other stuff in the mean time...

2017-07-13 Thread NotSpooky via Digitalmars-d-learn
On Thursday, 13 July 2017 at 15:52:57 UTC, Dustmight wrote: How do I read in input from the terminal without sitting there waiting for it? I've got code I want to run while there's no input, and then code I want to act on input when it comes in. How do I do both these things? Might want to

Re: Read from terminal when enter is pressed, but do other stuff in the mean time...

2017-07-13 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 13 July 2017 at 15:52:57 UTC, Dustmight wrote: How do I read in input from the terminal without sitting there waiting for it? I've got code I want to run while there's no input, and then code I want to act on input when it comes in. How do I do both these things? You have to ask

Read from terminal when enter is pressed, but do other stuff in the mean time...

2017-07-13 Thread Dustmight via Digitalmars-d-learn
How do I read in input from the terminal without sitting there waiting for it? I've got code I want to run while there's no input, and then code I want to act on input when it comes in. How do I do both these things?

Re: Idiomatic FFT(W) Wrapper

2017-07-13 Thread John Colvin via Digitalmars-d-learn
On Thursday, 13 July 2017 at 12:49:40 UTC, Per Nordlöw wrote: Have anybody constructed an idiomatic D wrapper for FFTW? No, sorry, although I have used the library quite a bit in D. http://www.fftw.org/fftw3_doc/Tutorial.html#Tutorial I'm specifically concerned about -

Idiomatic FFT(W) Wrapper

2017-07-13 Thread Per Nordlöw via Digitalmars-d-learn
Have anybody constructed an idiomatic D wrapper for FFTW? http://www.fftw.org/fftw3_doc/Tutorial.html#Tutorial I'm specifically concerned about - `RefCounted`-wrapping of the C structures `fftw_complex` and `fftw_plan` - range semantics, lazy evaluation and caching of result in

Re: Why do array literals default to object.Object[]?

2017-07-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/12/17 1:24 AM, Brandon Buck wrote: On Wednesday, 12 July 2017 at 02:06:41 UTC, Steven Schveighoffer wrote: I'm sure there's a bug filed somewhere on this... Is this bug worthy? I can search for one and comment and/or create one if I can't find one. Found it. It was mistakenly closed:

Re: Bad file descriptor in File destructor

2017-07-13 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 13 July 2017 at 10:56:20 UTC, unDEFER wrote: Seems I have found. I must do: try{ File file; try { file = File(path); } catch (Exception exp) { return; } //Some actions with file } catch (ErrnoException) { return; } Well, yes, you

Re: Bad file descriptor in File destructor

2017-07-13 Thread unDEFER via Digitalmars-d-learn
Thank you. I will write if will find the reason of description corruption.

Re: 2D game physics, macOS

2017-07-13 Thread Joel via Digitalmars-d-learn
On Thursday, 13 July 2017 at 09:53:05 UTC, Jacob Carlborg wrote: On 2017-07-13 02:34, Joel wrote: It doesn't look like there's any thing I can use. I've come across: dbox, dchip, and blaze. Blaze is dsource. dbox is alpha and hasn't been updated for 3 years. dchip [1] hasn't been updated

Re: Bad file descriptor in File destructor

2017-07-13 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 13 July 2017 at 11:15:56 UTC, Moritz Maxeiner wrote: --- ubyte[File.sizeof] _file; ref File file() { return *(cast(File*) &_file[0]); } [create File instance and assign to file] scope (exit) destroy(file); --- Forgot to add the try catch: --- ubyte[File.sizeof] _file; ref File

Re: Bad file descriptor in File destructor

2017-07-13 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 13 July 2017 at 10:28:30 UTC, unDEFER wrote: On Thursday, 13 July 2017 at 08:53:24 UTC, Moritz Maxeiner wrote: Where does that `File` come from? If it's std.stdio.File, that one is a struct with internal reference counting, so it shouldn't crash in the above. Could you provide a

Re: Bad file descriptor in File destructor

2017-07-13 Thread unDEFER via Digitalmars-d-learn
Seems I have found. I must do: try{ File file; try { file = File(path); } catch (Exception exp) { return; } //Some actions with file } catch (ErrnoException) { return; }

Re: Bad file descriptor in File destructor

2017-07-13 Thread unDEFER via Digitalmars-d-learn
On Thursday, 13 July 2017 at 08:53:24 UTC, Moritz Maxeiner wrote: Where does that `File` come from? If it's std.stdio.File, that one is a struct with internal reference counting, so it shouldn't crash in the above. Could you provide a minimal working (in this case crashing) example? Yes File

Re: 2D game physics, macOS

2017-07-13 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-07-13 02:34, Joel wrote: It doesn't look like there's any thing I can use. I've come across: dbox, dchip, and blaze. Blaze is dsource. dbox is alpha and hasn't been updated for 3 years. dchip [1] hasn't been updated for 2 years and doesn't compile (that's with out using any thing,

Re: Bad file descriptor in File destructor

2017-07-13 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 13 July 2017 at 08:38:52 UTC, unDEFER wrote: Hello! I have the code like this: File file; try { file = File(path); } catch (Exception exp) { return; } ... try { } Where does that `File` come from? If it's std.stdio.File, that one

Re: Bad file descriptor in File destructor

2017-07-13 Thread unDEFER via Digitalmars-d-learn
What the God? I was not ready to post... File file; try { file = File(path); } catch (Exception exp) { return; } try { //Some actions with file } catch (ErrnoException) { return; } catch (ErrnoException) is necessary

Bad file descriptor in File destructor

2017-07-13 Thread unDEFER via Digitalmars-d-learn
Hello! I have the code like this: File file; try { file = File(path); } catch (Exception exp) { return; } ... try { }

Re: Why do array literals default to object.Object[]?

2017-07-13 Thread Moritz Maxeiner via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 05:24:49 UTC, Brandon Buck wrote: On Wednesday, 12 July 2017 at 02:06:41 UTC, Steven Schveighoffer wrote: I'm sure there's a bug filed somewhere on this... Is this bug worthy? I can search for one and comment and/or create one if I can't find one. It's at

Re: Whats the correct way to pass a D array type to a win32 api function wanting a buffer?

2017-07-13 Thread John Chapman via Digitalmars-d-learn
On Thursday, 13 July 2017 at 01:15:46 UTC, FoxyBrown wrote: ENUM_SERVICE_STATUS_PROCESS[5000] services; auto res = SVC.EnumServicesStatusExA(schSCManager, SC_ENUM_TYPE.SC_ENUM_PROCESS_INFO, servicesType, SERVICE_STATE_ALL, cast(ubyte*)services.ptr,

Re: Having a strange issue with std.net.curl.HTTP as a struct dependency

2017-07-13 Thread Ali Çehreli via Digitalmars-d-learn
On 07/13/2017 12:01 AM, Ali Çehreli wrote: On 07/09/2017 05:10 PM, NoBigDeal256 wrote: HTTP http; For what it's worth, defining it as __gshared seems to be a workaround: __gshared HTTP http; I sometimes amuse myself. What use is that? :o) What I must have meant is you can have a

Re: Having a strange issue with std.net.curl.HTTP as a struct dependency

2017-07-13 Thread Ali Çehreli via Digitalmars-d-learn
On 07/09/2017 05:10 PM, NoBigDeal256 wrote: > HTTP http; For what it's worth, defining it as __gshared seems to be a workaround: __gshared HTTP http; Ali

Re: Function with static array as parameter

2017-07-13 Thread Miguel L via Digitalmars-d-learn
Thanks for your help.

Re: Static array with parameter based size?

2017-07-13 Thread Miguel L via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 18:49:23 UTC, Jack Applegame wrote: On Wednesday, 12 July 2017 at 05:45:13 UTC, Miguel L wrote: Also what is it possible in D to write a function that accepts an static array of any size? void foo(size_t N)(ref int[N] arr) { ... } int[10] arr; foo(arr);