Re: Dealing with raw types as attributes

2018-11-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 2 November 2018 at 04:18:47 UTC, Neia Neutuladh wrote: On Fri, 02 Nov 2018 04:01:00 +, Nicholas Wilson wrote: By noting that all (interesting for the purpose of UDA's i.e. not void) types have a .init or you could do static if (is(typeof(uda) == Foo) || is(uda == Foo))

Re: Dealing with raw types as attributes

2018-11-01 Thread Neia Neutuladh via Digitalmars-d-learn
On Fri, 02 Nov 2018 04:01:00 +, Nicholas Wilson wrote: > By noting that all (interesting for the purpose of UDA's i.e. not void) > types have a .init > > or you could do > > static if (is(typeof(uda) == Foo) || is(uda == Foo)) Which, again, only tests for presence, when I want to check for

Re: Dealing with raw types as attributes

2018-11-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 2 November 2018 at 03:13:19 UTC, Neia Neutuladh wrote: On Fri, 02 Nov 2018 00:36:18 +, Nicholas Wilson wrote: What do you do to handle this? @Foo() int bar; instead of @Foo int bar; Right. And if you're offering a library with UDAs for other people to use? I mean I

Re: Dealing with raw types as attributes

2018-11-01 Thread Neia Neutuladh via Digitalmars-d-learn
On Fri, 02 Nov 2018 00:36:18 +, Nicholas Wilson wrote: >> What do you do to handle this? > > @Foo() int bar; > > instead of > > @Foo int bar; Right. And if you're offering a library with UDAs for other people to use?

Re: Removing the precision from double

2018-11-01 Thread Neia Neutuladh via Digitalmars-d-learn
On Thu, 01 Nov 2018 23:59:26 +, kerdemdemir wrote: > I am doing trading and super scared of suprices like mathematical errors > during the multiplications(or division 1/tickSize) since market will > reject my orders even if there is a small mistake. > > Is this safe? Or is there a better way

Re: Dealing with raw types as attributes

2018-11-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 1 November 2018 at 16:14:45 UTC, Neia Neutuladh wrote: The spec says that a user-defined attribute must be an expression, but DMD accepts a wide range of things as UDAs: Indeed UDA are odd beasts: https://issues.dlang.org/show_bug.cgi?id=19127 What do you do to handle this?

Re: Removing the precision from double

2018-11-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 1 November 2018 at 23:59:26 UTC, kerdemdemir wrote: I have two numbers First The price = 0.0016123 Second Maximum allowed precision = 0.0001(it can be only 0.001, 0.0001, 0.1, ..., 0.01 bunch of zeros and than a one that is it) Anything more precise than

Re: Removing the precision from double

2018-11-01 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Nov 01, 2018 at 11:59:26PM +, kerdemdemir via Digitalmars-d-learn wrote: > I have two numbers > > First The price = 0.0016123 > Second Maximum allowed precision = 0.0001(it can be only 0.001, > 0.0001, 0.1, ..., 0.01 bunch of zeros and than a one that > is it)

Removing the precision from double

2018-11-01 Thread kerdemdemir via Digitalmars-d-learn
I have two numbers First The price = 0.0016123 Second Maximum allowed precision = 0.0001(it can be only 0.001, 0.0001, 0.1, ..., 0.01 bunch of zeros and than a one that is it) Anything more precise than the allow precision should truncated. So in this case 0.0016123

Re: Dealing with raw types as attributes

2018-11-01 Thread Stanislav Blinov via Digitalmars-d-learn
On Thursday, 1 November 2018 at 20:33:10 UTC, Neia Neutuladh wrote: On Thu, 01 Nov 2018 20:01:51 +, Stanislav Blinov wrote: Check if an UDA is a type?.. As in, not just `is(uda == Foo)`, but simply `is(uda)`: Which works, but generally makes things more complex in code that's already

Re: Dealing with raw types as attributes

2018-11-01 Thread Neia Neutuladh via Digitalmars-d-learn
On Thu, 01 Nov 2018 20:01:51 +, Stanislav Blinov wrote: > Check if an UDA is a type?.. As in, not just `is(uda == Foo)`, > but simply `is(uda)`: Which works, but generally makes things more complex in code that's already pretty deeply nested. It's also something I have to worry about every

Re: Dealing with raw types as attributes

2018-11-01 Thread Neia Neutuladh via Digitalmars-d-learn
On Thu, 01 Nov 2018 11:35:27 -0700, Ali Çehreli wrote: > On 11/01/2018 09:14 AM, Neia Neutuladh wrote: >> The spec says that a user-defined attribute must be an expression, but >> DMD accepts a wide range of things as UDAs: >> >>struct Foo { string name = "unknown"; } >>@Foo int bar; >>

Re: Dealing with raw types as attributes

2018-11-01 Thread Stanislav Blinov via Digitalmars-d-learn
On Thursday, 1 November 2018 at 16:14:45 UTC, Neia Neutuladh wrote: The spec says that a user-defined attribute must be an expression, but DMD accepts a wide range of things as UDAs: struct Foo { string name = "unknown"; } @Foo int bar; `bar` has the *type* Foo as an attribute. It's not

Re: Dealing with raw types as attributes

2018-11-01 Thread Ali Çehreli via Digitalmars-d-learn
On 11/01/2018 09:14 AM, Neia Neutuladh wrote: The spec says that a user-defined attribute must be an expression, but DMD accepts a wide range of things as UDAs: struct Foo { string name = "unknown"; } @Foo int bar; `bar` has the *type* Foo as an attribute. It's not an *instance* of Foo.

Dealing with raw types as attributes

2018-11-01 Thread Neia Neutuladh via Digitalmars-d-learn
The spec says that a user-defined attribute must be an expression, but DMD accepts a wide range of things as UDAs: struct Foo { string name = "unknown"; } @Foo int bar; `bar` has the *type* Foo as an attribute. It's not an *instance* of Foo. So if I try to look at the UDAs: static

Re: Small or big dub packages

2018-11-01 Thread Guillaume Piolat via Digitalmars-d-learn
On Monday, 29 October 2018 at 11:31:55 UTC, Igor wrote: The way I see it the advantage of smaller packages is that users can pick and choose and and only have the code they really need in their project, but the con could become managing a lot of dependencies. Also I am not sure how compile

Re: Profiling with DUB?

2018-11-01 Thread Guillaume Piolat via Digitalmars-d-learn
On Monday, 29 October 2018 at 10:14:23 UTC, Dukc wrote: I'm trying to profile my program, built like: dub build --build=profile When I run the program, where is the performance profile file supposed to appear? I can find nothing new in the program/project root directory. This happens

Re: CT BitArray

2018-11-01 Thread Bastiaan Veelo via Digitalmars-d-learn
On Thursday, 1 November 2018 at 00:01:04 UTC, Stefan Koch wrote: Tell me which version are you using and I'll make it for you. By the way this is a really generous offer, thanks for being like that!

Re: CT BitArray

2018-11-01 Thread Bastiaan Veelo via Digitalmars-d-learn
On Thursday, 1 November 2018 at 00:01:04 UTC, Stefan Koch wrote: On Wednesday, 31 October 2018 at 23:14:08 UTC, Bastiaan Veelo wrote: Currently, BitArray is not usable at compile time, so you cannot do ``` enum e = BitArray([1, 1, 1, 0]); ``` This gives

Re: Where do I learn to use GtkD

2018-11-01 Thread Russel Winder via Digitalmars-d-learn
On Thu, 2018-11-01 at 03:46 +, helxi via Digitalmars-d-learn wrote: […] > > Why is that, if I may ask? Is it the licensing concerns? > As with any programming language or framework, the biggest driver of opinion tends to be the personal prejudices of those who shout loudest and longest. --