Re: The lifetime of reduce's internal seed

2014-04-26 Thread Ali Çehreli via Digitalmars-d-learn
On 04/22/2014 11:45 AM, monarch_dodra wrote: Reduce returns the seed. It's actually doing something more like this: int[1] foo() { int[1] sum sum = sum[]; //The lambda operates, and the //result is assigned back to the seed. return sum; //Returns the

Another bug in function overloading?

2014-04-26 Thread Domain via Digitalmars-d-learn
module test; public interface I { void foo(); void foo(int); } public abstract class A : I { public void bar() { foo(); } public void foo(int i) { } } public class C : A { public void foo() { } public void bar2() { foo(1);

Writing to stdin of a process

2014-04-26 Thread Craig Dillabaugh via Digitalmars-d-learn
I want to be able to write to the stdin stream of an external process using std.process. I have the following small test app. myecho.d -- import std.stdio; void main(string[] args) { foreach (line; stdin.byLine()) {

Re: The lifetime of reduce's internal seed

2014-04-26 Thread monarch_dodra via Digitalmars-d-learn
On Saturday, 26 April 2014 at 06:24:26 UTC, Ali Çehreli wrote: On 04/22/2014 11:45 AM, monarch_dodra wrote: Reduce returns the seed. It's actually doing something more like this: int[1] foo() { int[1] sum sum = sum[]; //The lambda operates, and the //result is

Re: AES encryption with openssl bindings

2014-04-26 Thread hane via Digitalmars-d-learn
AES_set_decrypt_key is needed before AES_decrypt. AES_set_decrypt_key(chunk.ptr, 128, wctx);

Re: Another bug in function overloading?

2014-04-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Sat, 26 Apr 2014 06:55:38 + Domain via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: module test; public interface I { void foo(); void foo(int); } public abstract class A : I { public void bar() { foo(); } public

Re: Writing to stdin of a process

2014-04-26 Thread yazd via Digitalmars-d-learn
On Saturday, 26 April 2014 at 08:45:59 UTC, Craig Dillabaugh wrote: I want to be able to write to the stdin stream of an external process using std.process. I have the following small test app. myecho.d -- import std.stdio;

Re: Writing to stdin of a process

2014-04-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 26 April 2014 at 08:45:59 UTC, Craig Dillabaugh wrote: Can anyone tell me what I am dong wrong. In this case, I'd close the pipe when you're done. pipes.stdin().writeln(Hello world); pipes.stdin.close; myecho loops on stdin until it receives everything; until the pipe

Re: Another bug in function overloading?

2014-04-26 Thread Andrej Mitrovic via Digitalmars-d-learn
On 4/26/14, Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: No. That's expected. I wonder whether a better diagnostic could help. But then again, maybe the hiding would be intentional and the diagnostic would be spurious/invalid. Not sure..

Re: Writing to stdin of a process

2014-04-26 Thread Craig Dillabaugh via Digitalmars-d-learn
On Saturday, 26 April 2014 at 13:30:41 UTC, Adam D. Ruppe wrote: On Saturday, 26 April 2014 at 08:45:59 UTC, Craig Dillabaugh wrote: Can anyone tell me what I am dong wrong. In this case, I'd close the pipe when you're done. pipes.stdin().writeln(Hello world); pipes.stdin.close;

Re: AES encryption with openssl bindings

2014-04-26 Thread Kagamin via Digitalmars-d-learn
On Friday, 25 April 2014 at 19:06:33 UTC, brad clawsie wrote: My code compiles and fails silently. How do you want it to fail? C code doesn't throw exceptions.

Creating Libraries Callable from C

2014-04-26 Thread TJB via Digitalmars-d-learn
Is it possible to write a library that is callable from C without the enduser even knowing it was written in D? That is, can a C programmer use the library as though it were written in C straightforwardly? Or for that matter, by an enduser programming in Python or Lua where the library is

DMD Deimos || GDC Deimos?

2014-04-26 Thread Entry via Digitalmars-d-learn
I'd like to use GLFW from Deimos, but I couldn't get it to work (DMD said it cannot use libglfw.a) and I've read somewhere that only GDC can use these DLLs directly (with a D header, but that's still better than hooking the methods). So do I need GDC for that or not? And would you actually

Re: Creating Libraries Callable from C

2014-04-26 Thread Rémy Mouëza via Digitalmars-d-learn
It is possible to write a D library useable from C. However, we may not be able to hide the fact that the library has been written in D. You must first export some D function you want to use from C, using extern (C) declaration. Then declare them in your C program or headers. You will also

Static constructors inconsistency

2014-04-26 Thread spec via Digitalmars-d-learn
Hello, i'am experiencing some non consistent behavior with static constructors. I wonder if this is some bug or i just don't know enough of D (most probably!).. Code example bellow: //-- module main; import std.stdio; class B { static this()

Re: Static constructors inconsistency

2014-04-26 Thread spec via Digitalmars-d-learn
Btw, i only tested this using v2.065.0 of DMD. Cheers,

Re: DMD Deimos || GDC Deimos?

2014-04-26 Thread Mike Wey via Digitalmars-d-learn
On 04/26/2014 08:18 PM, Entry wrote: I'd like to use GLFW from Deimos, but I couldn't get it to work (DMD said it cannot use libglfw.a) and I've read somewhere that only GDC can use these DLLs directly (with a D header, but that's still better than hooking the methods). So do I need GDC for that

Re: Problem with code coverage. No .lst files?

2014-04-26 Thread Jeremy DeHaan via Digitalmars-d-learn
On Friday, 25 April 2014 at 08:20:37 UTC, Jeremy DeHaan wrote: On Friday, 25 April 2014 at 04:23:45 UTC, Ali Çehreli wrote: On 04/24/2014 08:32 PM, Jeremy DeHaan wrote: added the -cov switch to my unit test build Then you must execute the program. :) Ali I did, but still nothing. I even

storing pointers in Variants

2014-04-26 Thread Matt via Digitalmars-d-learn
I am trying to create a class that can do the following: --- int sample = 42; // myObj is an instance of the class I'm writing myObj.attach (othername, sample); myObj.set (othername, 69); writeln (myObj.get (othername), \t, sample); // should produce '69 69' --- Currently, my class

Re: Problem with code coverage. No .lst files?

2014-04-26 Thread Ali Çehreli via Digitalmars-d-learn
On 04/26/2014 01:11 PM, Jeremy DeHaan wrote: If you compile with -cov AND use -of where the output file is in a different directory than where the build is taking place(eg, buld happens in C:/DProject/, and the command line has -ofC:/DProject/Unittest/Unittest.exe), no .lst files are

Re: storing pointers in Variants

2014-04-26 Thread Ali Çehreli via Digitalmars-d-learn
On 04/26/2014 04:08 PM, Matt wrote: I am trying to create a class that can do the following: --- int sample = 42; // myObj is an instance of the class I'm writing myObj.attach (othername, sample); myObj.set (othername, 69); writeln (myObj.get (othername), \t, sample); // should produce '69

Can I circumvent nothrow?

2014-04-26 Thread Damian Day via Digitalmars-d-learn
So I have this procedure: extern (C) void signal_proc(int sn) @system nothrow Which can call this: shutdown_system() @system nothrow Problem I have is inside shutdown_system() I have code that can't possibly be @nothrow because their are a lot of subsystems to shutdown. What I've done for

Re: DMD Deimos || GDC Deimos?

2014-04-26 Thread Mike Parker via Digitalmars-d-learn
On 4/27/2014 3:18 AM, Entry wrote: I'd like to use GLFW from Deimos, but I couldn't get it to work (DMD said it cannot use libglfw.a) and I've read somewhere that only GDC can use these DLLs directly (with a D header, but that's still better than hooking the methods). So do I need GDC for that

Re: Can I circumvent nothrow?

2014-04-26 Thread Ali Çehreli via Digitalmars-d-learn
On 04/26/2014 06:39 PM, Damian Day wrote: Problem I have is inside shutdown_system() I have code that can't possibly be @nothrow because their are a lot of subsystems to shutdown. You can wrap the contents of shutdown_system() with a try-catch block and swallow all exceptions that way. Ali

Re: Can I circumvent nothrow?

2014-04-26 Thread Damian Day via Digitalmars-d-learn
On Sunday, 27 April 2014 at 01:53:15 UTC, Ali Çehreli wrote: On 04/26/2014 06:39 PM, Damian Day wrote: Problem I have is inside shutdown_system() I have code that can't possibly be @nothrow because their are a lot of subsystems to shutdown. You can wrap the contents of shutdown_system() with

Re: Static constructors inconsistency

2014-04-26 Thread Ali Çehreli via Digitalmars-d-learn
On 04/26/2014 12:10 PM, spec wrote: Hello, i'am experiencing some non consistent behavior with static constructors. I wonder if this is some bug or i just don't know enough of D (most probably!).. Code example bellow: //-- module main; import

Re: Creating Libraries Callable from C

2014-04-26 Thread Ali Çehreli via Digitalmars-d-learn
On 04/26/2014 11:27 AM, Rémy Mouëza wrote: You will also have to declare 2 function for initializing and terminating D's runtime: char rt_init(long long); char rt_term(long long); call rt_init(0) before using your D functions (this will initialize D runtime - the D GC amongst

Re: Problem with code coverage. No .lst files?

2014-04-26 Thread Jeremy DeHaan via Digitalmars-d-learn
On Sunday, 27 April 2014 at 00:37:39 UTC, Ali Çehreli wrote: So, under Linux, if I start the program as test/wont then the .lst gets generated in the current directory. Ali Just tried that in Windows, and the same thing happened. Weird! I'll be sure to file a bug report. Thanks for the

Re: Creating Libraries Callable from C

2014-04-26 Thread ketmar via Digitalmars-d-learn
On Sunday, 27 April 2014 at 02:15:59 UTC, Ali Çehreli wrote: And if those functions are called from the library's own initialization and deinitialization functions, the C program need not know anything about the D runtime dependence: void mylib_init() { rt_init(0); // ... other