Re: Get the return type of the function

2016-02-03 Thread xtreak via Digitalmars-d-learn
On Thursday, 4 February 2016 at 05:50:05 UTC, tsbockman wrote: On Thursday, 4 February 2016 at 02:06:00 UTC, xtreak wrote: On Wednesday, 3 February 2016 at 23:57:12 UTC, Ivan Kazmenko wrote: [...] Thanks for the reply. But the issue was about knowing the type of lambda in map. Most people wo

std.socket question

2016-02-03 Thread sanjayss via Digitalmars-d-learn
Are the functions lastSocketError() and wouldHaveBlocked() from std.socket thread-safe? i.e. can they be reliably used to see the status of the last socket call when sockets are being read/written in multiple threads?

How do you check if object o has base type B?

2016-02-03 Thread Enjoys Math via Digitalmars-d-learn
Consider: class C { } class B : C { } class A : B { } class D : C { } C[] objList; how do we test if objLis[k] is of base type "B"? Ie for [new A(), new B(), new D(), new C()] would give output [true, true, false, false]. ? Thank you! :D

Re: How do you check if object o has base type B?

2016-02-03 Thread Rikki Cattermole via Digitalmars-d-learn
T[] list; foreach(v; list) { if (SpecialT v2 = cast(SpecialT)v) { writeln(v2); } else { writeln("err"); } } That should work.

Re: Get the return type of the function

2016-02-03 Thread Meta via Digitalmars-d-learn
On Thursday, 4 February 2016 at 02:06:00 UTC, xtreak wrote: Thanks for the reply. But the issue was about knowing the type of lambda in map. Yes, I was just making sure that I knew why ReturnType!lambda was failing, which is that it is a template and does not have a return type until it is in

Re: Get the return type of the function

2016-02-03 Thread tsbockman via Digitalmars-d-learn
On Thursday, 4 February 2016 at 02:06:00 UTC, xtreak wrote: On Wednesday, 3 February 2016 at 23:57:12 UTC, Ivan Kazmenko wrote: Seems reasonable: `(int a) => a * a` has return type `int` but just `(a) => a * a` does not yet know the type of `a`, and so can not tell the return type. Thanks for

Re: Get the return type of the function

2016-02-03 Thread xtreak via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 23:57:12 UTC, Ivan Kazmenko wrote: On Wednesday, 3 February 2016 at 22:09:37 UTC, sigod wrote: On Wednesday, 3 February 2016 at 19:21:06 UTC, Meta wrote: Ah, I see. I'd like to test something; can you please change `(a) => a * a` to `(int a) => a * a` and post

Re: Get the return type of the function

2016-02-03 Thread xtreak via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 19:21:06 UTC, Meta wrote: On Wednesday, 3 February 2016 at 18:40:27 UTC, xtreak wrote: Thanks. I was trying to get the return type of lambdas. I was trying the following and got an error. I was using dpaste with dmd 2.070 writeln(ReturnType!(a =(a *a))) Error

Re: print function

2016-02-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, February 04, 2016 00:23:07 ixid via Digitalmars-d-learn wrote: > It would be nice to have a simple writeln that adds spaces > automatically like Python's 'print' in std.stdio, perhaps called > print. If that's what you're looking for, I expect that most of us would think that it's jus

Re: print function

2016-02-03 Thread ixid via Digitalmars-d-learn
On Thursday, 4 February 2016 at 00:30:03 UTC, cym13 wrote: On Thursday, 4 February 2016 at 00:23:07 UTC, ixid wrote: It would be nice to have a simple writeln that adds spaces automatically like Python's 'print' in std.stdio, perhaps called print. Sounds way too redundant to me. Normally yo

Re: print function

2016-02-03 Thread cym13 via Digitalmars-d-learn
On Thursday, 4 February 2016 at 00:23:07 UTC, ixid wrote: It would be nice to have a simple writeln that adds spaces automatically like Python's 'print' in std.stdio, perhaps called print. Sounds way too redundant to me.

Re: How do you get a hexstring from a base10 string -or- from a number?

2016-02-03 Thread anonymous via Digitalmars-d-learn
On 04.02.2016 00:45, Enjoys Math wrote: On Wednesday, 3 February 2016 at 23:43:45 UTC, Enjoys Math wrote: body { // is currently: return to!string(this.toHash()); } and is returning a base10 string, so how would I return a hex string so I can compare numbers displayed to the debugger addresse

print function

2016-02-03 Thread ixid via Digitalmars-d-learn
It would be nice to have a simple writeln that adds spaces automatically like Python's 'print' in std.stdio, perhaps called print.

Re: How do you get a hexstring from a base10 string -or- from a number?

2016-02-03 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Feb 03, 2016 at 11:45:15PM +, Enjoys Math via Digitalmars-d-learn wrote: > On Wednesday, 3 February 2016 at 23:43:45 UTC, Enjoys Math wrote: > >I am making a method called: > > > >@property string debugIDString() { > >in { > > assert(super.toHash() == this.toHash()); > >} body { > > >

Re: Capturing a variable by value?

2016-02-03 Thread Ali Çehreli via Digitalmars-d-learn
On 02/03/2016 10:09 AM, ZombineDev wrote: > I think these two links, more or less, answer my question: > http://stackoverflow.com/questions/29759419/closures-in-loops-capturing-by-reference > > https://issues.dlang.org/show_bug.cgi?id=2043 I find it more readable to give a name like makeClos

Re: Get the return type of the function

2016-02-03 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 22:09:37 UTC, sigod wrote: On Wednesday, 3 February 2016 at 19:21:06 UTC, Meta wrote: Ah, I see. I'd like to test something; can you please change `(a) => a * a` to `(int a) => a * a` and post the results? This works. http://dpaste.dzfl.pl/92c254ef6cf6 Seem

Re: How do you get a hexstring from a base10 string -or- from a number?

2016-02-03 Thread Enjoys Math via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 23:45:15 UTC, Enjoys Math wrote: On Wednesday, 3 February 2016 at 23:43:45 UTC, Enjoys Math wrote: I am making a method called: @property string debugIDString() { in { assert(super.toHash() == this.toHash()); } body { } body { // is currently: return to!s

Re: inner functions calling each other - how to do this with inner struct?

2016-02-03 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 15:09:35 UTC, Adam D. Ruppe wrote: Read my post here: http://stackoverflow.com/questions/34398408/struct-declaration-order/34398642#34398642 then see if you can use the same reasoning on your problem. This indeed works without any other tricks such as compile-

Re: How do you get a hexstring from a base10 string -or- from a number?

2016-02-03 Thread Enjoys Math via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 23:43:45 UTC, Enjoys Math wrote: I am making a method called: @property string debugIDString() { in { assert(super.toHash() == this.toHash()); } body { } body { // is currently: return to!string(this.toHash()); } and is returning a base10 string, so how w

How do you get a hexstring from a base10 string -or- from a number?

2016-02-03 Thread Enjoys Math via Digitalmars-d-learn
I am making a method called: @property string debugIDString() { in { assert(super.toHash() == this.toHash()); } body { }

Re: Counting time difference.

2016-02-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, February 03, 2016 22:27:07 holo via Digitalmars-d-learn wrote: > When i start same program on server in different timezone > difference is much higher (more than hour). Why it is happening? > Timezones shouldnt have influence on such equation. You're probably getting problems due to

Re: Why this code can't take advantage from CTFE?

2016-02-03 Thread Timon Gehr via Digitalmars-d-learn
On 02/03/2016 11:39 PM, Andrea Fontana wrote: On Wednesday, 3 February 2016 at 17:49:39 UTC, Marc Schütz wrote: On Wednesday, 3 February 2016 at 16:07:59 UTC, Messenger wrote: What is a good way to try to force it? Using enum? Then optionally copying the value once to avoid the "manifest consta

Re: Counting time difference.

2016-02-03 Thread sigod via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 22:27:07 UTC, holo wrote: When i start same program on server in different timezone difference is much higher (more than hour). Why it is happening? Timezones shouldnt have influence on such equation. Try using `Clock.currTime(UTC())`. And make sure all instanc

Re: Why this code can't take advantage from CTFE?

2016-02-03 Thread Andrea Fontana via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 17:49:39 UTC, Marc Schütz wrote: On Wednesday, 3 February 2016 at 16:07:59 UTC, Messenger wrote: What is a good way to try to force it? Using enum? Then optionally copying the value once to avoid the "manifest constant" copy/paste behaviour, where applicable?

Counting time difference.

2016-02-03 Thread holo via Digitalmars-d-learn
Hello I'm trying to count time difference to count time for how long instance is running. Here is how am i doing it: import std.stdio, sigv4, kxml.xml, awsxml; import std.datetime; import std.string; void main() { SigV4 req = new SigV4; IfResult result = req.go; AwsXml instance

Re: Get the return type of the function

2016-02-03 Thread sigod via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 19:21:06 UTC, Meta wrote: On Wednesday, 3 February 2016 at 18:40:27 UTC, xtreak wrote: Thanks. I was trying to get the return type of lambdas. I was trying the following and got an error. I was using dpaste with dmd 2.070 writeln(ReturnType!(a =(a *a))) Error

Re: Detecting exception unwinding

2016-02-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, February 03, 2016 11:47:35 Ola Fosheim Grøstad via Digitalmars-d-learn wrote: > On Wednesday, 3 February 2016 at 11:41:28 UTC, Jonathan M Davis > wrote: > > AFAIK, there is no way to detect whether an exception is in > > flight or not aside from the cases where scope(failure) or > >

Re: Call D from TCL

2016-02-03 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 14:19:32 UTC, Vasileios Anagnostopoulos wrote: Thank you very much. I investigate Tcl_CmdProc more closely. On Wed, Feb 3, 2016 at 3:50 PM, Gary Willoughby via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: On Wednesday, 3 February 2016 at 1

Re: Capturing a variable by value?

2016-02-03 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 18:09:52 UTC, ZombineDev wrote: I think these two links, more or less, answer my question: http://stackoverflow.com/questions/29759419/closures-in-loops-capturing-by-reference https://issues.dlang.org/show_bug.cgi?id=2043 Another approach: import std.range, std

Re: Get the return type of the function

2016-02-03 Thread Meta via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 18:40:27 UTC, xtreak wrote: Thanks. I was trying to get the return type of lambdas. I was trying the following and got an error. I was using dpaste with dmd 2.070 writeln(ReturnType!(a =(a *a))) Error: template instance f662.main.ReturnType!((a) => a * a) doe

Re: Get the return type of the function

2016-02-03 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Feb 03, 2016 at 06:40:27PM +, xtreak via Digitalmars-d-learn wrote: [...] > Thanks. I was trying to get the return type of lambdas. I was trying > the following and got an error. I was using dpaste with dmd 2.070 > > writeln(ReturnType!(a =(a *a))) > > Error: template instance f662.ma

Re: Get the return type of the function

2016-02-03 Thread xtreak via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 17:40:23 UTC, Meta wrote: On Wednesday, 3 February 2016 at 17:12:03 UTC, xtreak wrote: I was reporting a patch for the regression by removing the code that was causing the error. The bug was that map was not accepting multiple lambdas. It was suggested to check

Re: Capturing a variable by value?

2016-02-03 Thread ZombineDev via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 18:03:24 UTC, ZombineDev wrote: C++11 allows you to capture a local variable explicitly by value. What is the simplest way to make code below print "0 1 .. 9", like the C++ version does? D version: ``` import std.stdio; void main() { alias F = void deleg

Capturing a variable by value?

2016-02-03 Thread ZombineDev via Digitalmars-d-learn
C++11 allows you to capture a local variable explicitly by value. What is the simplest way to make code below print "0 1 .. 9", like the C++ version does? D version: ``` import std.stdio; void main() { alias F = void delegate(); F[] arr; foreach (i; 0 .. 10)

Re: Why this code can't take advantage from CTFE?

2016-02-03 Thread Marc Schütz via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 16:07:59 UTC, Messenger wrote: What is a good way to try to force it? Using enum? Then optionally copying the value once to avoid the "manifest constant" copy/paste behaviour, where applicable? template forceCTFE(alias expr) { alias forceCTFE = expr; } aut

Re: Get the return type of the function

2016-02-03 Thread Meta via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 17:12:03 UTC, xtreak wrote: I was reporting a patch for the regression by removing the code that was causing the error. The bug was that map was not accepting multiple lambdas. It was suggested to check for void functions and lambdas. I couldn't find a function

Re: Why this code can't take advantage from CTFE?

2016-02-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/3/16 12:16 PM, Andrea Fontana wrote: On Wednesday, 3 February 2016 at 16:24:19 UTC, Adam D. Ruppe wrote: On Wednesday, 3 February 2016 at 16:07:59 UTC, Messenger wrote: What is a good way to try to force it? Using enum? Then optionally copying the value once to avoid the "manifest constant

Re: Why this code can't take advantage from CTFE?

2016-02-03 Thread Messenger via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 17:16:30 UTC, Andrea Fontana wrote: But if I want a normal var, not static or enum? There's no way to force it? Just make a mutable copy of it, I think.

Re: Why this code can't take advantage from CTFE?

2016-02-03 Thread Andrea Fontana via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 16:24:19 UTC, Adam D. Ruppe wrote: On Wednesday, 3 February 2016 at 16:07:59 UTC, Messenger wrote: What is a good way to try to force it? Using enum? Then optionally copying the value once to avoid the "manifest constant" copy/paste behaviour, where applicable?

Get the return type of the function

2016-02-03 Thread xtreak via Digitalmars-d-learn
I was reporting a patch for the regression by removing the code that was causing the error. The bug was that map was not accepting multiple lambdas. It was suggested to check for void functions and lambdas. I couldn't find a function to check for return type in the std.traits. I tried the expli

Re: Why this code can't take advantage from CTFE?

2016-02-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 16:07:59 UTC, Messenger wrote: What is a good way to try to force it? Using enum? Then optionally copying the value once to avoid the "manifest constant" copy/paste behaviour, where applicable? Yes, or static local variables are ctfe initialized too.

Re: Why this code can't take advantage from CTFE?

2016-02-03 Thread Messenger via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 15:59:43 UTC, Adam D. Ruppe wrote: You never asked for CTFE. CTFE only happens when it *has* to - when you write code that specifically asks for or requires it. What is a good way to try to force it? Using enum? Then optionally copying the value once to avoid

Re: Why this code can't take advantage from CTFE?

2016-02-03 Thread anonymous via Digitalmars-d-learn
On 03.02.2016 16:34, Andrea Fontana wrote: void main() { enum first = very_very_long_function(10); writeln("First is ", first); auto second = very_very_long_function(12); writeln("Second is ", second); auto third = first; third += 1;

Re: Why this code can't take advantage from CTFE?

2016-02-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 15:34:51 UTC, Andrea Fontana wrote: enum first = very_very_long_function(10); auto second = very_very_long_function(12); Why second init doesn't work with CTFE? You never asked for CTFE. CTFE only happens when it *has* to - when you write code

Re: Cannot get Derelict to work

2016-02-03 Thread Whirlpool via Digitalmars-d-learn
Thank you so much ! Thanks to your instructions, it is working for me now with Visual Studio and I can run the first example of GLFW's documentation :) I'll try on Fedora at a later time

Why this code can't take advantage from CTFE?

2016-02-03 Thread Andrea Fontana via Digitalmars-d-learn
This code: import std.stdio; int very_very_long_function(in int k) { if (!__ctfe) writeln("Can't use ctfe!"); return k/2; } void main() { enum first = very_very_long_function(10); writeln("First is ", first); auto second = very_very_long_function(12);

Re: inner functions calling each other - how to do this with inner struct?

2016-02-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 14:01:24 UTC, Ivan Kazmenko wrote: 1. What works. Read my post here: http://stackoverflow.com/questions/34398408/struct-declaration-order/34398642#34398642 then see if you can use the same reasoning on your problem.

Re: DMD OSX / Segfault 11

2016-02-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/3/16 8:17 AM, Robert M. Münch wrote: On 2016-02-02 18:59:35 +, Steven Schveighoffer said: If this is valid D, I'm not sure what it means :) There was one type, the rest I stripped totally away as IMO it's not relevant for the actual problem. Very relevant: what are you declaring?

Re: Cannot get Derelict to work

2016-02-03 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 13:04:54 UTC, Mike Parker wrote: - First I tried to create a VisualD project on Windows, and to manually compile derelict-util and derelict-glfw3: FYI, this thread motivated me to revisit the manual compilation instructions in the Derelict docs [1]. I've outli

Re: Call D from TCL

2016-02-03 Thread Vasileios Anagnostopoulos via Digitalmars-d-learn
Thank you very much. I investigate Tcl_CmdProc more closely. On Wed, Feb 3, 2016 at 3:50 PM, Gary Willoughby via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On Wednesday, 3 February 2016 at 12:20:42 UTC, Vasileios Anagnostopoulos > wrote: > >> Is there any example,framewor

inner functions calling each other - how to do this with inner struct?

2016-02-03 Thread Ivan Kazmenko via Digitalmars-d-learn
Hi, 1. What works. Inside a function (outerFun), I've got inner functions fun1 and fun2 which have to recursively call each other. Just writing them one after the other does not work. I've managed to find a trick to make it work though, which is to add empty compile-time parameters to fun1

Re: Call D from TCL

2016-02-03 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 12:20:42 UTC, Vasileios Anagnostopoulos wrote: Is there any example,framework or tutorial on how to call D from Tcl (write new commands in D for Tcl)? I am on Windows 10 x86_64. thank you. I've created a wrapper around Tcl/Tk to create GUI's here: https://gi

Re: DMD OSX / Segfault 11

2016-02-03 Thread anonymous via Digitalmars-d-learn
On 03.02.2016 14:16, Robert M. Münch wrote: Well, it should of course be: BaseOperator: Value { } Still missing "class". I know I'm being pedantic, but if you're being sloppy here, how do I know that you're not being sloppy where it matters? Casting between class types that have an inherit

Re: DMD OSX / Segfault 11

2016-02-03 Thread Robert M. Münch via Digitalmars-d-learn
On 2016-02-02 18:59:35 +, Steven Schveighoffer said: If this is valid D, I'm not sure what it means :) There was one type, the rest I stripped totally away as IMO it's not relevant for the actual problem. -- Robert M. Münch http://www.saphirion.com smarter | better | faster

Re: DMD OSX / Segfault 11

2016-02-03 Thread Robert M. Münch via Digitalmars-d-learn
On 2016-02-02 19:03:04 +, anonymous said: This isn't valid D code at all, which makes it unnecessarily hard to understand what you mean. Well, it should of course be: BaseOperator: Value { } A Value* is a pointer to a class reference. Unless you're doing something really funky with the

Re: Cannot get Derelict to work

2016-02-03 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 13:07:51 UTC, Mike Parker wrote: On Wednesday, 3 February 2016 at 13:04:54 UTC, Mike Parker wrote: latest release. Unfortunately, they do not provide a binary distribution, so you will have to build the DLL from source or find somewhere that makes it availabl

Re: Cannot get Derelict to work

2016-02-03 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 13:04:54 UTC, Mike Parker wrote: latest release. Unfortunately, they do not provide a binary distribution, so you will have to build the DLL from source or find somewhere that makes it available prebuilt DLLs available for you. Actually, they do provide preb

Re: Cannot get Derelict to work

2016-02-03 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 12:18:17 UTC, Whirlpool wrote: Hi, I'd like to use Derelict, more specifically the GLFW package, but so far I have been unable to make it work. (I posted in the IDE section but didn't get a reply (link below), and since the Derelict forum seems not to exist anym

Re: Detecting exception unwinding

2016-02-03 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 12:44:39 UTC, Jacob Carlborg wrote: * Worst case scenario, override "_d_throwc" [2] For the trace handler and overriding "_d_throwc" you would just use the default implementation plus store a boolean (or counter) in a TLS variable indicating an exception has be

Re: Call D from TCL

2016-02-03 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 12:20:42 UTC, Vasileios Anagnostopoulos wrote: Is there any example,framework or tutorial on how to call D from Tcl (write new commands in D for Tcl)? I am on Windows 10 x86_64. thank you. I'm not sure about the specifics but if it can be done in C you can j

Re: Detecting exception unwinding

2016-02-03 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-02-03 12:09, Ola Fosheim Grøstad wrote: Is there some reliable way to detect that a destructor is called because of exception unwinding? I basically want to change behaviour within a destructor based on whether the destructor is called as a result of a regular or an exceptional situation

Re: std.typecons.Proxy requires a nothrow destructor and toHash?

2016-02-03 Thread Saurabh Das via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 12:10:01 UTC, Marc Schütz wrote: On Wednesday, 3 February 2016 at 10:16:56 UTC, Saurabh Das wrote: [...] It used to work in 2.066.1; bisecting points to this PR: https://github.com/D-Programming-Language/phobos/pull/3043 When bisecting between 2.066 and 2.067,

Call D from TCL

2016-02-03 Thread Vasileios Anagnostopoulos via Digitalmars-d-learn
Is there any example,framework or tutorial on how to call D from Tcl (write new commands in D for Tcl)? I am on Windows 10 x86_64. thank you. -- Dr. Vasileios Anagnostopoulos (MSc,PhD) Researcher/Developer ICCS/NTUA 9 Heroon Polytechneiou Str., Zografou 15773 Athens,Greece T (+30) 2107723404 M

Cannot get Derelict to work

2016-02-03 Thread Whirlpool via Digitalmars-d-learn
Hi, I'd like to use Derelict, more specifically the GLFW package, but so far I have been unable to make it work. (I posted in the IDE section but didn't get a reply (link below), and since the Derelict forum seems not to exist anymore, I post here. I hope it is OK to do so) Things I tried :

Re: std.typecons.Proxy requires a nothrow destructor and toHash?

2016-02-03 Thread Marc Schütz via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 10:16:56 UTC, Saurabh Das wrote: Why doesn't this work? Is it a requirement that a proxied struct must have a nothrow destructor and toHash? It used to work in 2.066.1; bisecting points to this PR: https://github.com/D-Programming-Language/phobos/pull/3043 When

Re: Detecting exception unwinding

2016-02-03 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 11:41:28 UTC, Jonathan M Davis wrote: AFAIK, there is no way to detect whether an exception is in flight or not aside from the cases where scope(failure) or catch would catch the exception, and from what I recall of the last time that someone asked this question

Re: Detecting exception unwinding

2016-02-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, February 03, 2016 11:09:00 Ola Fosheim Grøstad via Digitalmars-d-learn wrote: > Is there some reliable way to detect that a destructor is called > because of exception unwinding? > > I basically want to change behaviour within a destructor based on > whether the destructor is called

Detecting exception unwinding

2016-02-03 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
Is there some reliable way to detect that a destructor is called because of exception unwinding? I basically want to change behaviour within a destructor based on whether the destructor is called as a result of a regular or an exceptional situation. E.g. commit changes to a database on regul

Re: How would you implement this in D? (signals & slots)

2016-02-03 Thread Vadim Lopatin via Digitalmars-d-learn
On Monday, 1 February 2016 at 21:40:45 UTC, Enjoys Math wrote: module signals_and_slots; How do you implement this template called like: void onColorChange(in Color) { // do something with color } auto slots = Slots!(void delegate(in Color), Color); slots.connect(&onColorChange); auto color =

std.typecons.Proxy requires a nothrow destructor and toHash?

2016-02-03 Thread Saurabh Das via Digitalmars-d-learn
struct A { import std.stdio; File f; } struct B { A a; import std.typecons; mixin Proxy!a; } rdmd proxytest.d: /Library/D/dmd/src/phobos/std/typecons.d(5055): Error: 'proxytest.A.~this' is not nothrow /Library/D/dmd/src/phobos/std/typecons.d(5050): Error: function 'proxyt

Re: Binding to C - Arrays and Access Violation

2016-02-03 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 04:19:37 UTC, jmh530 wrote: A few extra questions: 1) In other parts of the code I'm using extern(System), but that doesn't work for these. Why is extern(C) used for function pointers?, extern(C) is only used with function pointers when it's needed. It depe

Re: const and immutable member variables in classes

2016-02-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 06:11:07 UTC, H. S. Teoh wrote: I still can't come up with a compelling use case that would justify using a const/immutable class member, that couldn't be done by some other means, though. Especially since we're talking about classes, we already have all the tra