Re: Issue with small floating point numbers

2021-05-12 Thread Zardoz via Digitalmars-d-learn
On Thursday, 13 May 2021 at 03:03:37 UTC, Tim wrote: Hello all, I have this piece of code ```D /** Rotate a 2D array (Vector) by phi radians Params: vec = 2D Vector to rotate phi = Degree with which to rotate the Vector in radians Returns: Rotated 2D array (Vector) Example: */

Re: Understanding RefCounted

2021-05-12 Thread JG via Digitalmars-d-learn
On Thursday, 13 May 2021 at 00:53:50 UTC, Steven Schveighoffer wrote: On 5/12/21 1:16 PM, JG wrote: [...] Ah, ok. So reference counting provides a single thing you can point at and pass around without worrying about memory cleanup. But only as long as you refer to it strictly through a

Re: Issue with small floating point numbers

2021-05-12 Thread JG via Digitalmars-d-learn
On Thursday, 13 May 2021 at 03:48:49 UTC, Tim wrote: On Thursday, 13 May 2021 at 03:46:28 UTC, Alain De Vos wrote: Not is is not wrong it is wright. Because you use not pi but an approximation of pi the result is not zero but an approximation of zero. Oh, of course. Jesus that sucks big

Re: Issue with small floating point numbers

2021-05-12 Thread Alain De Vos via Digitalmars-d-learn
I would calculate the squared distance to the point (-10,0) and check it is small enough for practical use. ``` double squared_distance=(p.x+10) * (p.x+10)+p.y * p.y assert (squared_distance < 1e-10); ```

Re: Issue with small floating point numbers

2021-05-12 Thread Tim via Digitalmars-d-learn
On Thursday, 13 May 2021 at 03:46:28 UTC, Alain De Vos wrote: Not is is not wrong it is wright. Because you use not pi but an approximation of pi the result is not zero but an approximation of zero. Oh, of course. Jesus that sucks big time. Any idea on how to use assert with an approximate

Re: Issue with small floating point numbers

2021-05-12 Thread Alain De Vos via Digitalmars-d-learn
Not is is not wrong it is wright. Because you use not pi but an approximation of pi the result is not zero but an approximation of zero.

Issue with small floating point numbers

2021-05-12 Thread Tim via Digitalmars-d-learn
Hello all, I have this piece of code ```D /** Rotate a 2D array (Vector) by phi radians Params: vec = 2D Vector to rotate phi = Degree with which to rotate the Vector in radians Returns: Rotated 2D array (Vector) Example: */ pragma(inline, true) Point2 rotate2D(in Point2 vec, in

Re: cannot I override and mark it as private?

2021-05-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/12/21 5:55 PM, Basile B. wrote: On Wednesday, 12 May 2021 at 19:35:31 UTC, Jack wrote: I'd to change the visibility of a method overrided from public to private but it doesn't work tho to protected it does. Why is that? ... Why is that? why must I leave it accessible somehow (even if it's

Re: Understanding RefCounted

2021-05-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/12/21 1:16 PM, JG wrote: On Wednesday, 12 May 2021 at 13:38:10 UTC, Steven Schveighoffer wrote: On 5/12/21 3:28 AM, JG wrote: Reading the documentation on RefCounted I get the impression that the following can lead to memory errors. Could someone explain exactly how that could happen? I

Re: cannot I override and mark it as private?

2021-05-12 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 12 May 2021 at 19:35:31 UTC, Jack wrote: I'd to change the visibility of a method overrided from public to private but it doesn't work tho to protected it does. Why is that? ... Why is that? why must I leave it accessible somehow (even if it's protected) to all derived class of

Re: How to use dub with our own package

2021-05-12 Thread Christian Köstlin via Digitalmars-d-learn
On 2021-05-12 21:22, Vinod K Chandran wrote: On Wednesday, 12 May 2021 at 18:26:39 UTC, Christian Köstlin wrote: Are you really interested in doing winglib as a separate dub package? If not you could just do a `dub init yourappname` which gives you the basic skeleton. something like: . ├──

Re: cannot I override and mark it as private?

2021-05-12 Thread Imperatorn via Digitalmars-d-learn
On Wednesday, 12 May 2021 at 19:35:31 UTC, Jack wrote: I'd to change the visibility of a method overrided from public to private but it doesn't work tho to protected it does. Why is that? give: ```d class A { void f() { } } ``` this is ok: ```d class B : A { protected override void

Re: Near-simplest route to learn D

2021-05-12 Thread Ali Çehreli via Digitalmars-d-learn
On 5/12/21 12:37 PM, Berni44 wrote: > Even if it is a few years old, I would still use the book from Ali. Most > is still valid and maybe, the online version is even updated Yes, the online version is more up-to-date than the print version. (By the way, the more-up-to-date online PDF is what

cannot I override and mark it as private?

2021-05-12 Thread Jack via Digitalmars-d-learn
I'd to change the visibility of a method overrided from public to private but it doesn't work tho to protected it does. Why is that? give: ```d class A { void f() { } } ``` this is ok: ```d class B : A { protected override void f() { } } ``` this is not: ```d class B : A {

Re: Near-simplest route to learn D

2021-05-12 Thread Berni44 via Digitalmars-d-learn
On Wednesday, 12 May 2021 at 18:37:55 UTC, NonNull wrote: Some documents/books seem to be out of date. If an intuitive person competent in several other programming languages and in abstract reasoning wanted to take the fastest route to learn pretty much the whole of D as it stands now, having

Re: How to use dub with our own package

2021-05-12 Thread Vinod K Chandran via Digitalmars-d-learn
On Wednesday, 12 May 2021 at 15:03:14 UTC, Imperatorn wrote: Check out add-local Thanks. Let me check. :)

Re: How to use dub with our own package

2021-05-12 Thread Vinod K Chandran via Digitalmars-d-learn
On Wednesday, 12 May 2021 at 17:23:16 UTC, JG wrote: Have a look at [link](https://forum.dlang.org/post/jyxdcotuqhcdfqwwh...@forum.dlang.org). Thanks for the link. :)

Re: How to use dub with our own package

2021-05-12 Thread Vinod K Chandran via Digitalmars-d-learn
On Wednesday, 12 May 2021 at 18:26:39 UTC, Christian Köstlin wrote: Are you really interested in doing winglib as a separate dub package? If not you could just do a `dub init yourappname` which gives you the basic skeleton. something like: . ├── dub.sdl └── source └── app.d then you

Near-simplest route to learn D

2021-05-12 Thread NonNull via Digitalmars-d-learn
Hello, Some documents/books seem to be out of date. If an intuitive person competent in several other programming languages and in abstract reasoning wanted to take the fastest route to learn pretty much the whole of D as it stands now, having already learned and used a core of the

Re: How to use dub with our own package

2021-05-12 Thread Christian Köstlin via Digitalmars-d-learn
On 2021-05-12 15:37, Vinod K Chandran wrote: Hi all, I am creating a hobby project related with win api gui functions. i would like to work with dub. But How do I use dub in my project. 1. All my gui library modules are located in a folder named "winglib". 2. And that folder also conatains a d

Re: How to use dub with our own package

2021-05-12 Thread JG via Digitalmars-d-learn
On Wednesday, 12 May 2021 at 13:37:26 UTC, Vinod K Chandran wrote: Hi all, I am creating a hobby project related with win api gui functions. i would like to work with dub. But How do I use dub in my project. 1. All my gui library modules are located in a folder named "winglib". 2. And that

Re: Understanding RefCounted

2021-05-12 Thread JG via Digitalmars-d-learn
On Wednesday, 12 May 2021 at 13:38:10 UTC, Steven Schveighoffer wrote: On 5/12/21 3:28 AM, JG wrote: Reading the documentation on RefCounted I get the impression that the following can lead to memory errors. Could someone explain exactly how that could happen? I suppose that problem would be

Re: How to use dub with our own package

2021-05-12 Thread Imperatorn via Digitalmars-d-learn
On Wednesday, 12 May 2021 at 13:37:26 UTC, Vinod K Chandran wrote: Hi all, I am creating a hobby project related with win api gui functions. i would like to work with dub. But How do I use dub in my project. 1. All my gui library modules are located in a folder named "winglib". 2. And that

Re: Improved diagnostics for mismatched template constraints

2021-05-12 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 12 May 2021 at 12:54:24 UTC, Per Nordlöw wrote: I'm certain I've seen dmd be able to diagnose which sub-expression of `isDumb` and `isInputRange` that evaluated to false. Did I just dream this or is there a way? If there is a way does this improvement still reside in a dmd PR?

How to use dub with our own package

2021-05-12 Thread Vinod K Chandran via Digitalmars-d-learn
Hi all, I am creating a hobby project related with win api gui functions. i would like to work with dub. But How do I use dub in my project. 1. All my gui library modules are located in a folder named "winglib". 2. And that folder also conatains a d file called "package.d" 3. "package.d"

Re: Understanding RefCounted

2021-05-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/12/21 3:28 AM, JG wrote: Reading the documentation on RefCounted I get the impression that the following can lead to memory errors. Could someone explain exactly how that could happen? I suppose that problem would be the call something to do with front? ``` private struct

Improved diagnostics for mismatched template constraints

2021-05-12 Thread Per Nordlöw via Digitalmars-d-learn
Given ```d import std.range.primitives : isInputRange; enum isDumb(Args...) = (Args.length == 2 && Args.length == 3); void f(Args...)(Args args) if (isDumb!(Args)) { } void g(Arg)(Arg arg) if (isInputRange!(Arg)) { } @safe pure unittest { f(2, 3); g(2); } ``` `dmd` diagnoses the

Re: question on map

2021-05-12 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 12 May 2021 at 09:52:52 UTC, Alain De Vos wrote: As oppposed to what i expect code below prints nothing nothing on the screen. What is wrong and how to fix it ? ``` import std.stdio; import std.range:iota; import std.algorithm:map; bool mywriteln(int x){ writeln(x);

Re: question on map

2021-05-12 Thread visitor via Digitalmars-d-learn
On Wednesday, 12 May 2021 at 09:52:52 UTC, Alain De Vos wrote: As oppposed to what i expect code below prints nothing nothing on the screen. What is wrong and how to fix it ? ``` import std.stdio; import std.range:iota; import std.algorithm:map; bool mywriteln(int x){ writeln(x);

Re: question on map

2021-05-12 Thread Berni44 via Digitalmars-d-learn
On Wednesday, 12 May 2021 at 09:52:52 UTC, Alain De Vos wrote: As oppposed to what i expect code below prints nothing nothing on the screen. What is wrong and how to fix it ? ``` import std.stdio; import std.range:iota; import std.algorithm:map; bool mywriteln(int x){ writeln(x);

question on map

2021-05-12 Thread Alain De Vos via Digitalmars-d-learn
As oppposed to what i expect code below prints nothing nothing on the screen. What is wrong and how to fix it ? ``` import std.stdio; import std.range:iota; import std.algorithm:map; bool mywriteln(int x){ writeln(x); return true; } void main(){ 5.iota.map!mywriteln; }

Understanding RefCounted

2021-05-12 Thread JG via Digitalmars-d-learn
Reading the documentation on RefCounted I get the impression that the following can lead to memory errors. Could someone explain exactly how that could happen? I suppose that problem would be the call something to do with front? ``` private struct RefCountedRangeReturnType(R) { import

Re: moveToGC

2021-05-12 Thread JG via Digitalmars-d-learn
On Monday, 10 May 2021 at 11:11:06 UTC, Mike Parker wrote: On Monday, 10 May 2021 at 10:56:35 UTC, JG wrote: The following compiles with dmd but not with ldc on run.dlang.io. Am I doing something wrong? Please provide the error message(s) when asking questions like this. In this case: ```