Re: Compilation error while adding two shorts

2014-06-24 Thread Ali Çehreli via Digitalmars-d-learn
On 06/23/2014 10:03 PM, David Zaragoza wrote: Hello I'm trying to compile the following program: module main; int main(string[] argv){ short asd = 1; short qwe = asd + asd; return 0; } And the compiler gives this error: C:\Daviddmd simple simple.d(5): Error: cannot

Re: Why does this work?

2014-06-24 Thread bearophile via Digitalmars-d-learn
h_zet: Problem solved, Thank you so much! I don't think it's solved. There are probably bugs worth reporting here. Bye, bearophile

new and GC.malloc fail, core.stdc.malloc works

2014-06-24 Thread John Colvin via Digitalmars-d-learn
I'm getting OutOfMemoryErrors on some machines when calling GC.malloc (or new) for anything large (more than about 1GB), where core.stdc.malloc works fine. Anyone ever come accross this before? I suspect it's related to some system memory monitor/management as it's only happening to me on

Re: Unexpected OPTLINK Termination while building ddb and gtkd

2014-06-24 Thread Orfeo via Digitalmars-d-learn
If I compile with rdmd ``` $ dub build --rdmd ``` it works

Re: Why does this work?

2014-06-24 Thread bearophile via Digitalmars-d-learn
I don't think it's solved. There are probably bugs worth reporting here. I have not found them, sorry for the noise. Bye, bearophile

Re: new and GC.malloc fail, core.stdc.malloc works

2014-06-24 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 24 June 2014 at 10:06:10 UTC, John Colvin wrote: I'm getting OutOfMemoryErrors on some machines when calling GC.malloc (or new) for anything large (more than about 1GB), where core.stdc.malloc works fine. Anyone ever come accross this before? I suspect it's related to some system

Re: new and GC.malloc fail, core.stdc.malloc works

2014-06-24 Thread bearophile via Digitalmars-d-learn
John Colvin: I'm getting OutOfMemoryErrors on some machines when calling GC.malloc (or new) for anything large (more than about 1GB), where core.stdc.malloc works fine. I think that when you go in territories where most people have not done much coding in D, like allocating than 1 GB in one

implib and system dlls, oh my

2014-06-24 Thread Jason King via Digitalmars-d-learn
On Tuesday, 24 June 2014 at 04:37:56 UTC, Rikki Cattermole wrote: On 24/06/2014 1:13 p.m., Jason King wrote: This is me trying to link with Juno and getting tantalizingly close to success. DMD home is d:\d so binaries are d:\d\dmd2\windows\bin (on path) Juno is in

Re: implib and system dlls, oh my

2014-06-24 Thread Rikki Cattermole via Digitalmars-d-learn
On 25/06/2014 12:34 a.m., Jason King wrote: On Tuesday, 24 June 2014 at 04:37:56 UTC, Rikki Cattermole wrote: On 24/06/2014 1:13 p.m., Jason King wrote: This is me trying to link with Juno and getting tantalizingly close to success. DMD home is d:\d so binaries are d:\d\dmd2\windows\bin (on

Re: implib and system dlls, oh my

2014-06-24 Thread Jason King via Digitalmars-d-learn
I don't know enough about implib to explain it. But another method that I believe should work is to use linker definition files. It'll allow optlink to work. Just add it to dmd, actually I believe it needs to be passed to Optlink (so -L it). Another fix, might be to use 64bit, but shouldn't

Re: Why does this work?

2014-06-24 Thread Meta via Digitalmars-d-learn
On Tuesday, 24 June 2014 at 10:11:05 UTC, bearophile wrote: I don't think it's solved. There are probably bugs worth reporting here. I have not found them, sorry for the noise. Bye, bearophile This looks really bad. I thought we weren't going to allow variable templates, just enums and

popcnt instruction

2014-06-24 Thread Archibald via Digitalmars-d-learn
Hello, I need to use the popcnt processor instruction in a performance critical section. Is there a way to do this in D?

Re: popcnt instruction

2014-06-24 Thread Justin Whear via Digitalmars-d-learn
On Tue, 24 Jun 2014 16:34:42 +, Archibald wrote: Hello, I need to use the popcnt processor instruction in a performance critical section. Is there a way to do this in D? D's inline assembler is described here: http://dlang.org/iasm.html

Re: popcnt instruction

2014-06-24 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 24 June 2014 at 17:05:24 UTC, Justin Whear wrote: On Tue, 24 Jun 2014 16:34:42 +, Archibald wrote: Hello, I need to use the popcnt processor instruction in a performance critical section. Is there a way to do this in D? D's inline assembler is described here:

Converting from C const(dchar*) to dstring

2014-06-24 Thread Danyal Zia via Digitalmars-d-learn
Hi, I like to print the strings from a C function that returns const(dchar*), but I can't make the conversion to dstring. I can convert vice versa by: dstring text = Hello; const(dchar)* str = toUTFz!(const(dchar)*)(text); // passing it to C function prints Hello However, I don't have the

Re: Converting from C const(dchar*) to dstring

2014-06-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tue, 24 Jun 2014 13:37:41 -0400, Danyal Zia catofdan...@yahoo.com wrote: Hi, I like to print the strings from a C function that returns const(dchar*), but I can't make the conversion to dstring. I can convert vice versa by: dstring text = Hello; const(dchar)* str =

How to free memory of an associative array

2014-06-24 Thread Mark Isaacson via Digitalmars-d-learn
How can I free the memory used by an associative array? I need to be able to reuse the same array, but set it to an empty state and free up the memory it used previously. I do not believe that setting the associative array to null is sufficient to free the memory, as it is possible that someone

Re: Converting from C const(dchar*) to dstring

2014-06-24 Thread Danyal Zia via Digitalmars-d-learn
On Tuesday, 24 June 2014 at 17:59:41 UTC, Steven Schveighoffer wrote: const(dchar *)x = ...; // assuming 0 terminated dstring text = x[0..x.strlen].idup; -Steve const(dchar)* x = Hello\0; dstring text = x[0..x.strlen].idup; writeln(text); Error: no property 'strlen' for type 'const(dchar)*'

Re: Converting from C const(dchar*) to dstring

2014-06-24 Thread Chris Cain via Digitalmars-d-learn
On Tuesday, 24 June 2014 at 17:59:41 UTC, Steven Schveighoffer wrote: // assuming 0 terminated dstring text = x[0..x.strlen].idup; strlen is only defined for char, not dchar: https://github.com/D-Programming-Language/druntime/blob/master/src/core/stdc/string.d#L44

Re: Converting from C const(dchar*) to dstring

2014-06-24 Thread Chris Cain via Digitalmars-d-learn
On Tuesday, 24 June 2014 at 18:17:07 UTC, Danyal Zia wrote: On Tuesday, 24 June 2014 at 17:59:41 UTC, Steven Schveighoffer wrote: const(dchar *)x = ...; // assuming 0 terminated dstring text = x[0..x.strlen].idup; -Steve const(dchar)* x = Hello\0; dstring text = x[0..x.strlen].idup;

Re: Converting from C const(dchar*) to dstring

2014-06-24 Thread Justin Whear via Digitalmars-d-learn
On Tue, 24 Jun 2014 18:17:06 +, Danyal Zia wrote: On Tuesday, 24 June 2014 at 17:59:41 UTC, Steven Schveighoffer wrote: const(dchar *)x = ...; // assuming 0 terminated dstring text = x[0..x.strlen].idup; -Steve const(dchar)* x = Hello\0; dstring text = x[0..x.strlen].idup;

Re: Converting from C const(dchar*) to dstring

2014-06-24 Thread Danyal Zia via Digitalmars-d-learn
On Tuesday, 24 June 2014 at 18:34:31 UTC, Chris Cain wrote: You can do what he said, but you'll have to write your own strlen function: something like: size_t strlen(in dchar* s) pure @system nothrow { size_t pos = 0; dchar term = '\0'; while(s[pos] != term)

Re: Another rambling musing by a Dynamic Programmer - map!

2014-06-24 Thread Jacob Carlborg via Digitalmars-d-learn
On 2014-06-24 04:34, John Carter wrote: So in Ruby and R and Scheme and... I have happily used map / collect for years and years. Lovely thing. So I did the dumb obvious of string[] stringList = map!...; And D barfed, wrong type, some evil voldemort thing again. So.. auto

Re: Converting from C const(dchar*) to dstring

2014-06-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tue, 24 Jun 2014 14:28:58 -0400, Chris Cain zsh...@gmail.com wrote: On Tuesday, 24 June 2014 at 17:59:41 UTC, Steven Schveighoffer wrote: // assuming 0 terminated dstring text = x[0..x.strlen].idup; strlen is only defined for char, not dchar:

Re: How to free memory of an associative array

2014-06-24 Thread Jonathan M Davis via Digitalmars-d-learn
Sent: Tuesday, June 24, 2014 at 11:12 AM From: Mark Isaacson via Digitalmars-d-learn digitalmars-d-learn@puremagic.com To: digitalmars-d-learn@puremagic.com Subject: How to free memory of an associative array How can I free the memory used by an associative array? I need to be able to

Re: Trying to reproduce Node.js async waterfall pattern.. (Meta-programming)

2014-06-24 Thread Philippe Sigaud via Digitalmars-d-learn
Yes, the final callback is always called, but if an error is passed to the callback by any of the main steps in the sequence ladder, it will immediately jump to the final callback and not execute further steps. OK. What do you mean? The compiler does deduce the type of Funcs. If you look

Re: popcnt instruction

2014-06-24 Thread Archibald via Digitalmars-d-learn
On Tuesday, 24 June 2014 at 17:27:09 UTC, Rene Zwanenburg wrote: On Tuesday, 24 June 2014 at 17:05:24 UTC, Justin Whear wrote: On Tue, 24 Jun 2014 16:34:42 +, Archibald wrote: Hello, I need to use the popcnt processor instruction in a performance critical section. Is there a way to do

Re: popcnt instruction

2014-06-24 Thread Justin Whear via Digitalmars-d-learn
On Tue, 24 Jun 2014 19:44:52 +, Archibald wrote: Thanks for the answers. Unfortunately it seems like popcnt isn't supported by D's inline assembler. What if I import it as an external C function, will I get optimal performance? DMD 2.065 seems to support it. What compiler are you using

Re: popcnt instruction

2014-06-24 Thread Justin Whear via Digitalmars-d-learn
Also, see: http://forum.dlang.org/thread/alirjgygnwpifkijx...@forum.dlang.org

Re: Another rambling musing by a Dynamic Programmer - map!

2014-06-24 Thread Ary Borenszweig via Digitalmars-d-learn
On 6/24/14, 4:13 PM, Jacob Carlborg wrote: On 2014-06-24 04:34, John Carter wrote: So in Ruby and R and Scheme and... I have happily used map / collect for years and years. Lovely thing. So I did the dumb obvious of string[] stringList = map!...; And D barfed, wrong type, some evil

Re: popcnt instruction

2014-06-24 Thread Archibald via Digitalmars-d-learn
On Tuesday, 24 June 2014 at 19:56:29 UTC, Justin Whear wrote: Also, see: http://forum.dlang.org/thread/alirjgygnwpifkijx...@forum.dlang.org its not documented on the inline assembler page. That's why I thought it wasn't supported, it's not in the list of supported opcodes. Thanks for the

Re: mixin(__MODULE__) fails if module name is module

2014-06-24 Thread sigod via Digitalmars-d-learn
I opened new issue: https://issues.dlang.org/show_bug.cgi?id=12986

Re: std.algorithm.map - function by reference

2014-06-24 Thread Justin Whear via Digitalmars-d-learn
On Tue, 24 Jun 2014 21:46:15 +, kuba wrote: Hi there, I was wondering if std.algorithm.map can take functions with parameters passed by reference? The main point here is to avoid unnecessary copies by perhaps I'm using the wrong tool for the job. No, `map` is a _projection_ function

Re: std.algorithm.map - function by reference

2014-06-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 24 June 2014 at 21:46:16 UTC, kuba wrote: The main point here is to avoid unnecessary copies You should make sure this actually matters - passing doubles by ref for example is probably slower than just passing a regular double.

Re: Compilation error while adding two shorts

2014-06-24 Thread David Zaragoza via Digitalmars-d-learn
Interesting info, I've never seen this behavior in C since the conversion is implicit as [2] notes. A simple cast resolves the problem in D: module main; int main(string[] argv){ short asd = 1; short qwe = cast(short)(asd + asd); return 0; } Thanks for your answer :)

Re: Equivalent of C++ std::function

2014-06-24 Thread Mike Parker via Digitalmars-d-learn
On 6/25/2014 10:10 AM, Yuushi wrote: I was wondering if D had something akin to std::function in C++. Say I have some functions in an associative array, for example: auto mapping = ['!' : (string a) = toUpper!string(a), '^' : (string a) = capitalize!string(a)]; What I want to do is

Is their a way for a Child process to modify its Parent's environment?

2014-06-24 Thread WhatMeWorry via Digitalmars-d-learn
I open a command line window, and run the following 6 line program void main() { string envPath = environment[PATH]; writeln(PATH is: , envPath); envPath ~= r;F:\dmd2\windows\bin; environment[PATH] = envPath; envPath = environment[PATH]; writeln(PATH is: , envPath); } It

Re: Equivalent of C++ std::function

2014-06-24 Thread Yuushi via Digitalmars-d-learn
On Wednesday, 25 June 2014 at 01:47:13 UTC, Mike Parker wrote: On 6/25/2014 10:45 AM, Mike Parker wrote: On 6/25/2014 10:10 AM, Yuushi wrote: I was wondering if D had something akin to std::function in C++. Say I have some functions in an associative array, for example: auto mapping

Re: Equivalent of C++ std::function

2014-06-24 Thread Olivier Pisano via Digitalmars-d-learn
On Wednesday, 25 June 2014 at 03:33:15 UTC, Yuushi wrote: Thanks a ton - I guess I need to do a fair bit more reading about alias. In this case, alias acts as typedef in C++. What is important here is the function pointers/delegates syntax.