Re: Finding source of typeid use

2017-07-07 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 8 July 2017 at 05:36:49 UTC, rikki cattermole wrote: On 08/07/2017 2:35 AM, Nicholas Wilson wrote: On Friday, 7 July 2017 at 08:49:58 UTC, Nicholas Wilson wrote: My library is generating a typeid from somewhere. e.g. typeid(const(Pointer!(cast(AddrSpace)1u, float))) [...] It see

Re: Finding source of typeid use

2017-07-07 Thread rikki cattermole via Digitalmars-d-learn
On 08/07/2017 2:35 AM, Nicholas Wilson wrote: On Friday, 7 July 2017 at 08:49:58 UTC, Nicholas Wilson wrote: My library is generating a typeid from somewhere. e.g. typeid(const(Pointer!(cast(AddrSpace)1u, float))) [...] It seems to be coming from the need to hash the type, goodness knows why

Re: Application settings

2017-07-07 Thread bauss via Digitalmars-d-learn
On Friday, 7 July 2017 at 22:52:22 UTC, FoxyBrown wrote: On Friday, 7 July 2017 at 20:45:36 UTC, Moritz Maxeiner wrote: On Friday, 7 July 2017 at 19:40:35 UTC, FoxyBrown wrote: What's the "best" way to do this? I want something I can simply load at startup in a convenient and easy way then save

Re: Finding source of typeid use

2017-07-07 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 7 July 2017 at 08:49:58 UTC, Nicholas Wilson wrote: My library is generating a typeid from somewhere. e.g. typeid(const(Pointer!(cast(AddrSpace)1u, float))) [...] It seems to be coming from the need to hash the type, goodness knows why, which explains why I only get the const varie

Re: Application settings

2017-07-07 Thread FoxyBrown via Digitalmars-d-learn
On Friday, 7 July 2017 at 20:45:36 UTC, Moritz Maxeiner wrote: On Friday, 7 July 2017 at 19:40:35 UTC, FoxyBrown wrote: What's the "best" way to do this? I want something I can simply load at startup in a convenient and easy way then save when necessary(possibly be efficient at it, but probably

Re: Application settings

2017-07-07 Thread aberba via Digitalmars-d-learn
On Friday, 7 July 2017 at 19:40:35 UTC, FoxyBrown wrote: What's the "best" way to do this? I want something I can simply load at startup in a convenient and easy way then save when necessary(possibly be efficient at it, but probably doesn't matter). Simply json an array and save and load it,

Re: Application settings

2017-07-07 Thread Moritz Maxeiner via Digitalmars-d-learn
On Friday, 7 July 2017 at 19:40:35 UTC, FoxyBrown wrote: What's the "best" way to do this? I want something I can simply load at startup in a convenient and easy way then save when necessary(possibly be efficient at it, but probably doesn't matter). Simply json an array and save and load it,

Application settings

2017-07-07 Thread FoxyBrown via Digitalmars-d-learn
What's the "best" way to do this? I want something I can simply load at startup in a convenient and easy way then save when necessary(possibly be efficient at it, but probably doesn't matter). Simply json an array and save and load it, or is there a better way? Ideally, I'd like to store th

Re: Application settings

2017-07-07 Thread Cym13 via Digitalmars-d-learn
On Friday, 7 July 2017 at 19:40:35 UTC, FoxyBrown wrote: What's the "best" way to do this? I want something I can simply load at startup in a convenient and easy way then save when necessary(possibly be efficient at it, but probably doesn't matter). Simply json an array and save and load it,

Re: Double value is rounded to unexpected value: 2.5 -> 2 instead of 3

2017-07-07 Thread ag0aep6g via Digitalmars-d-learn
On 07/07/2017 08:29 PM, alex_ca wrote: I'm having trouble understanding why in some cases a double value will be rounded up and other times down, for the same code. Here's a snippet with code I tried to debug: int getNumberOfStitchesForRowLength(double rowLength) { writeln("input ",

Re: Double value is rounded to unexpected value: 2.5 -> 2 instead of 3

2017-07-07 Thread Ali Çehreli via Digitalmars-d-learn
On 07/07/2017 11:29 AM, alex_ca wrote: > input 2.5 10 10 > stitches: 2.5 -> 2 > I expect: 3 That's because what is printed as 2.5 is actually a little less than that. (Try printing with a format string like "%.20f".) The common way of dealing with this issue is to add 0.5 before the conversi

Double value is rounded to unexpected value: 2.5 -> 2 instead of 3

2017-07-07 Thread alex_ca via Digitalmars-d-learn
Hi, I'm having trouble understanding why in some cases a double value will be rounded up and other times down, for the same code. Here's a snippet with code I tried to debug: int getNumberOfStitchesForRowLength(double rowLength) { writeln("input ", rowLength, " ", currentGauge.stitch_

Re: Address of a lambda

2017-07-07 Thread Ali Çehreli via Digitalmars-d-learn
On 07/07/2017 10:52 AM, Ali Çehreli wrote: > a solution with the addition of the > keyword 'delegate': As ag0aep6g explained, the 'delegate' keyword was not necessary there. A case where it's needed is when defining a variable. The following code compiles if 'delegate' keyword is present: voi

Re: Address of a lambda

2017-07-07 Thread ag0aep6g via Digitalmars-d-learn
On 07/07/2017 07:33 PM, FoxyBrown wrote: In gtk, we routinly have to use delegates for callbacks. But the methods that accept these delegates want the address of the delegate, I don't think that's true. As far as I can tell, this is the signature of addOnDelete [1]: gulong addOnDelete(b

Re: Address of a lambda

2017-07-07 Thread FoxyBrown via Digitalmars-d-learn
On Friday, 7 July 2017 at 17:52:25 UTC, Ali Çehreli wrote: On 07/07/2017 10:33 AM, FoxyBrown wrote: > [...] the methods > [...] I'm not a user but I don't think it's right. According to the following, it takes a delegate: [...] Thanks, I guess one doesn't need to pass the address(I copied t

Re: Address of a lambda

2017-07-07 Thread Ali Çehreli via Digitalmars-d-learn
On 07/07/2017 10:33 AM, FoxyBrown wrote: > In gtk, we routinly have to use delegates for callbacks. But the methods > that accept these delegates want the address of the delegate, I'm not a user but I don't think it's right. According to the following, it takes a delegate: https://github.com/

Re: Address of a lambda

2017-07-07 Thread NoIdeaForaGoodPseudo via Digitalmars-d-learn
On Friday, 7 July 2017 at 17:33:33 UTC, FoxyBrown wrote: In gtk, we routinly have to use delegates for callbacks. But the methods that accept these delegates want the address of the delegate, this prevents us from being able to pass a lambda in directly, but there really is not reason why we sh

Address of a lambda

2017-07-07 Thread FoxyBrown via Digitalmars-d-learn
In gtk, we routinly have to use delegates for callbacks. But the methods that accept these delegates want the address of the delegate, this prevents us from being able to pass a lambda in directly, but there really is not reason why we shouldn't be able to do this? Fine: void main() { bool wi

Re: "shared" woes: shared instances of anonymous classes

2017-07-07 Thread Moritz Maxeiner via Digitalmars-d-learn
On Friday, 7 July 2017 at 09:14:56 UTC, Arafel wrote: [...] Is there any way to create a shared instance of an anonymous class? [...] If somebody knows how this works / is supposed to work, I'd be thankful! [1]: https://dpaste.dzfl.pl/ce2ba93111a0 Yes, but it's round about: you have to in

Re: "shared" woes: shared instances of anonymous classes

2017-07-07 Thread Arafel via Digitalmars-d-learn
Well, in both snippets there and extra closing parenthesis... they are obviously a typo, blame copy and pasting and not cleaning up afterwards :) On 07/07/2017 11:14 AM, Arafel wrote: Hi! I'm trying to wrap my mind around "shared", and I think I have managed to more or less grasp it. However

Re: Need simple sound

2017-07-07 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Thursday, 6 July 2017 at 20:36:08 UTC, FoxyBrown wrote: Heres a better version that automatically generates a class wrapping the portaudio.dll. Need portaudio.di(possibly renamed to portaudio.d and imported). Still same problem as original though. While you are at it. Please also write com

Re: Which editor to use for editing DDOCs?

2017-07-07 Thread biocyberman via Digitalmars-d-learn
On Tuesday, 23 May 2017 at 10:10:24 UTC, Russel Winder wrote: On Tue, 2017-05-23 at 07:40 +, biocyberman via Digitalmars-d-learn wrote: […] Adding DDOC support for D Mode require some more work obviously. I will see if I can make some changes to that. For the time being, I would like to

"shared" woes: shared instances of anonymous classes

2017-07-07 Thread Arafel via Digitalmars-d-learn
Hi! I'm trying to wrap my mind around "shared", and I think I have managed to more or less grasp it. However I'm having a problem, and it seems it's just a missing feature (or rather combination of features) in the language (or I haven't found the right keyword combination). Is there any way

Finding source of typeid use

2017-07-07 Thread Nicholas Wilson via Digitalmars-d-learn
My library is generating a typeid from somewhere. e.g. typeid(const(Pointer!(cast(AddrSpace)1u, float))) but I have never declared a const of that type nor have I used typeid explicitly in my program. Where is this coming from? The program is just: enum AddrSpace { Global, Shared } st