Re: Delegates: Print 0..9

2016-12-01 Thread unDEFER via Digitalmars-d-learn
On Thursday, 1 December 2016 at 20:12:15 UTC, Ali Çehreli wrote: First, the scary syntax that produces a lambda from an int: ... Better: ... All methods.. Thank you!

Re: Two part question. Making a dynamic array of delegates, and taking in a delegate with unknown parameters as an argument .

2016-12-01 Thread Payotz via Digitalmars-d-learn
Thank you all for the replies. I'm extremely grateful. I'll look into each and every answer.

Re: Two part question. Making a dynamic array of delegates, and taking in a delegate with unknown parameters as an argument .

2016-12-01 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 1 December 2016 at 23:51:19 UTC, Payotz wrote: The register method will take in delegates as an argument, but those delegates have varied arguments themselves, so I can't really put anything there. I know that it's got something to do with templates so I tried my hand in it and

Re: Two part question. Making a dynamic array of delegates, and taking in a delegate with unknown parameters as an argument .

2016-12-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 1 December 2016 at 23:51:19 UTC, Payotz wrote: So, to give context, I am trying to make an event manager for a game I'm making. I was writing the "register()" method so I ran into a problem. The register method will take in delegates as an argument, but those delegates have

Re: Two part question. Making a dynamic array of delegates, and taking in a delegate with unknown parameters as an argument .

2016-12-01 Thread crimaniak via Digitalmars-d-learn
On Thursday, 1 December 2016 at 23:51:19 UTC, Payotz wrote: So, to give context, I am trying to make an event manager for a game I'm making. I was writing the "register()" method so I ran into a problem. The register method will take in delegates as an argument, but those delegates have

Re: Two part question. Making a dynamic array of delegates, and taking in a delegate with unknown parameters as an argument .

2016-12-01 Thread Ali Çehreli via Digitalmars-d-learn
On 12/01/2016 03:51 PM, Payotz wrote: > So, to give context, I am trying to make an event manager for a game I'm > making. > I was writing the "register()" method so I ran into a problem. > > The register method will take in delegates as an argument, but those > delegates have varied arguments

Re: Two part question. Making a dynamic array of delegates, and taking in a delegate with unknown parameters as an argument .

2016-12-01 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Dec 01, 2016 at 11:51:19PM +, Payotz via Digitalmars-d-learn wrote: > So, to give context, I am trying to make an event manager for a game > I'm making. > I was writing the "register()" method so I ran into a problem. > > The register method will take in delegates as an argument, but

Two part question. Making a dynamic array of delegates, and taking in a delegate with unknown parameters as an argument .

2016-12-01 Thread Payotz via Digitalmars-d-learn
So, to give context, I am trying to make an event manager for a game I'm making. I was writing the "register()" method so I ran into a problem. The register method will take in delegates as an argument, but those delegates have varied arguments themselves, so I can't really put anything

Re: The module 'foo' is already defined in 'libmylib.so'

2016-12-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 1 December 2016 at 22:05:06 UTC, Timothee Cour wrote: I want to update a library with new symbols (ie partial recompilation): libmylib.so : compiled from bar.d and foo.d now update the file foo.d dmd -c -fPIC foo.d -offoo.o clang++ -o libmylib_update.so foo.o -shared

The module 'foo' is already defined in 'libmylib.so'

2016-12-01 Thread Timothee Cour via Digitalmars-d-learn
I want to update a library with new symbols (ie partial recompilation): libmylib.so : compiled from bar.d and foo.d now update the file foo.d dmd -c -fPIC foo.d -offoo.o clang++ -o libmylib_update.so foo.o -shared -Wl,-lmylib When trying to dlopen libmylib_update.so from C++ it fails with:

Re: Delegates: Print 0..9

2016-12-01 Thread Ali Çehreli via Digitalmars-d-learn
On 12/01/2016 11:28 AM, unDEFER wrote: > Hello! > Simple using of delegates: > > === > #!/usr/bin/rdmd > import std.stdio; > > void main() > { > void delegate() functions[]; > > foreach (i; 0..10) > { > void print() > { > writefln("%s", i); >

Re: Delegates: Print 0..9

2016-12-01 Thread unDEFER via Digitalmars-d-learn
Yes, I have found: = #!/usr/bin/rdmd import std.stdio; void main() { void delegate() functions[]; foreach (i; 0..10) { auto get_print(int i) { void print() { writefln("%s", i); }

Re: how to catch D Throwables (or exceptions) from C++?

2016-12-01 Thread Rémy Mouëza via Digitalmars-d-learn
On Thursday, 1 December 2016 at 01:58:13 UTC, Timothee Cour wrote: eg: ``` dlib.d: extern(C) void dfun(){assert(0, "some_msg");} clib.cpp: extern "C" void dfun(); void fun(){ try{ dfun(); } catch(...){ // works but how do i get "some_msg" thrown from D? } } ``` I had the a

Delegates: Print 0..9

2016-12-01 Thread unDEFER via Digitalmars-d-learn
Hello! Simple using of delegates: === #!/usr/bin/rdmd import std.stdio; void main() { void delegate() functions[]; foreach (i; 0..10) { void print() { writefln("%s", i); } functions ~= } foreach (i; 0..10) {

Re: How to serialize a double.

2016-12-01 Thread Jake Pittis via Digitalmars-d-learn
On Thursday, 1 December 2016 at 07:13:45 UTC, Bauss wrote: On Thursday, 1 December 2016 at 00:36:30 UTC, Jake Pittis wrote: [...] You could do something like below which will allow you to serialize any number. import std.stdio : writeln; import std.traits : isNumeric; ubyte[]