Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 4 December 2019 at 01:28:00 UTC, H. S. Teoh wrote: typeof(return) is one of the lesser known cool things about D that make it so cool. Somebody should write an article about it to raise awareness of it. :-D you know i probably will write about that next week. so be sure to

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Dec 04, 2019 at 01:01:04AM +, Adam D. Ruppe via Digitalmars-d-learn wrote: > On Tuesday, 3 December 2019 at 23:44:59 UTC, mipri wrote: > > Option 4: typeof(return) > > typeof(return) is super cool for like option type things too! typeof(return) is one of the lesser known cool things

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 23:44:59 UTC, mipri wrote: Option 4: typeof(return) typeof(return) is super cool for like option type things too!

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread mipri via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 10:13:30 UTC, mipri wrote: Speaking of nice stuff and aliases, suppose you want to return a nice tuple with named elements? Option 1: auto auto option1() { return tuple!(int, "apples", int, "oranges")(1, 2); } Option 2: redundancy Tuple!(int,

Re: druntime 2.087 regression? (was: Old codebase stops compiling at 2.087)

2019-12-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/3/19 12:15 PM, James Blachly wrote: On 11/17/19 7:15 PM, Steven Schveighoffer wrote: On 11/17/19 10:45 AM, James Blachly wrote: /home/james/dmd2.087/dmd2/linux/bin64/../../src/druntime/import/object.d(3453,36): Error: cannot implicitly convert expression aa of type

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Meta via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 22:11:39 UTC, Meta wrote: On Tuesday, 3 December 2019 at 17:45:27 UTC, H. S. Teoh wrote: The thing is, `void` means "no return type" (or "no type" in some contexts), i.e., void == TBottom in that case. Not *quite* correct. void is not a bottom type; it's a unit

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Meta via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 17:45:27 UTC, H. S. Teoh wrote: The thing is, `void` means "no return type" (or "no type" in some contexts), i.e., void == TBottom in that case. Not *quite* correct. void is not a bottom type; it's a unit type, meaning that it's a type with only 1 value (as is

Re: Intersection of two sets

2019-12-03 Thread mipri via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 18:45:18 UTC, Jan Hönig wrote: On Tuesday, 3 December 2019 at 13:55:51 UTC, Alex wrote: This depends on the available accesses on your sets. In terms of ranges: Are your sets InputRanges, ForwardRange, ... ? 2) Are there some build-in function for handling

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Dec 03, 2019 at 09:08:55PM +, Paul Backus via Digitalmars-d-learn wrote: > On Tuesday, 3 December 2019 at 17:45:27 UTC, H. S. Teoh wrote: > > The thing is, `void` means "no return type" (or "no type" in some > > contexts), i.e., void == TBottom in that case. > > This is incorrect.

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 17:45:27 UTC, H. S. Teoh wrote: The thing is, `void` means "no return type" (or "no type" in some contexts), i.e., void == TBottom in that case. This is incorrect. `void` as a return type is a unit type; that is, a type with exactly one value. A function with a

Re: Intersection of two sets

2019-12-03 Thread Jan Hönig via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 13:55:51 UTC, Alex wrote: This depends on the available accesses on your sets. In terms of ranges: Are your sets InputRanges, ForwardRange, ... ? 2) Are there some build-in function for handling such sets? This is maybe what you are looking for:

Re: Floating-Point arithmetic in dlang - Difference to other languages

2019-12-03 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Dec 03, 2019 at 09:22:49AM +, Jan Hönig via Digitalmars-d-learn wrote: > Today i have stumbled on Hacker News into: https://0.30004.com/ > > I am learning D, that's why i have to ask. > > Why does > > writefln("%.17f", .1+.2); > > not evaluate into:

Re: Intersection of two sets

2019-12-03 Thread Jan Hönig via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 15:14:03 UTC, ikod wrote: Never tried, but depending of the nature of your "something" you can try bit sets. There are efficient algorithms for large bit arrays (see "roaring" for example). "roaring" is massive overkill for my case, but thanks for suggesting

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Dec 03, 2019 at 03:19:02AM -0700, Jonathan M Davis via Digitalmars-d-learn wrote: > On Tuesday, December 3, 2019 3:03:22 AM MST Basile B. via Digitalmars-d- > learn wrote: [...] > > [...] maybe we should be able to name the type of null. I think this > > relates to TBottom too a bit. > >

Re: Strange casting error when using lamdas

2019-12-03 Thread Robert M. Münch via Digitalmars-d-learn
On 2019-12-03 16:34:43 +, Robert M. Münch said: I have very strange casting error I don't understand: alias typeof(windows_message_streams[WM_MOUSEMOVE].filter!(win => (win.wParam & MK_LBUTTON))) WM_MOUSEMOVE_LBUTTON_TYPE; WM_MOUSEMOVE_LBUTTON_TYPE WM_MOUSEMOVE_LBUTTON_STREAM;

Re: druntime 2.087 regression? (was: Old codebase stops compiling at 2.087)

2019-12-03 Thread James Blachly via Digitalmars-d-learn
On 11/17/19 7:15 PM, Steven Schveighoffer wrote: On 11/17/19 10:45 AM, James Blachly wrote: /home/james/dmd2.087/dmd2/linux/bin64/../../src/druntime/import/object.d(3453,36): Error: cannot implicitly convert expression aa of type shared(GSeqAllele[string]) to const(shared(GSeqAllele)[string])

Strange casting error when using lamdas

2019-12-03 Thread Robert M. Münch via Digitalmars-d-learn
I have very strange casting error I don't understand: alias typeof(windows_message_streams[WM_MOUSEMOVE].filter!(win => (win.wParam & MK_LBUTTON))) WM_MOUSEMOVE_LBUTTON_TYPE; WM_MOUSEMOVE_LBUTTON_TYPE WM_MOUSEMOVE_LBUTTON_STREAM; pragma(msg,typeof(WM_MOUSEMOVE_LBUTTON_STREAM));

Re: Intersection of two sets

2019-12-03 Thread ikod via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 13:43:26 UTC, Jan Hönig wrote: It seems i don't google the right keywords. What i want to do: I have two sets. (I didn't find how to do sets, so i have two associative boolean arrays `bool[]`). And i want to join them, via an intersection. I know how to code

Re: Intersection of two sets

2019-12-03 Thread Alex via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 13:43:26 UTC, Jan Hönig wrote: It seems i don't google the right keywords. What i want to do: I have two sets. (I didn't find how to do sets, so i have two associative boolean arrays `bool[]`). And i want to join them, via an intersection. I know how to code

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, December 3, 2019 3:23:20 AM MST Basile B. via Digitalmars-d- learn wrote: > On Tuesday, 3 December 2019 at 10:19:02 UTC, Jonathan M Davis > > wrote: > > On Tuesday, December 3, 2019 3:03:22 AM MST Basile B. via > > > > Digitalmars-d- learn wrote: > >> [...] > > > > There isn't much

Intersection of two sets

2019-12-03 Thread Jan Hönig via Digitalmars-d-learn
It seems i don't google the right keywords. What i want to do: I have two sets. (I didn't find how to do sets, so i have two associative boolean arrays `bool[]`). And i want to join them, via an intersection. I know how to code this. Loop over one AA, if the key is also in the other one,

Re: Floating-Point arithmetic in dlang - Difference to other languages

2019-12-03 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 09:22:49 UTC, Jan Hönig wrote: Today i have stumbled on Hacker News into: https://0.30004.com/ I am learning D, that's why i have to ask. Why does writefln("%.17f", .1+.2); not evaluate into: 0.30004, like C++ but rather to:

Re: Floating-Point arithmetic in dlang - Difference to other languages

2019-12-03 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 09:52:18 UTC, mipri wrote: Most other languages give you the double result for very reasonable historical reasons Not only historical, it is also for numerical reasons. You can get very unpredictable results if you do compares and compiletime evalution is

Re: Floating-Point arithmetic in dlang - Difference to other languages

2019-12-03 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 09:22:49 UTC, Jan Hönig wrote: not evaluate into: 0.30004, like C++ but rather to: 0.2 You get the same in C++ with: #include int main() { printf("%.17f",double(0.1L + 0.2L)); }

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 10:19:02 UTC, Jonathan M Davis wrote: On Tuesday, December 3, 2019 3:03:22 AM MST Basile B. via Digitalmars-d- learn wrote: [...] There isn't much point in giving the type of null an explicit name given that it doesn't come up very often, and typeof(null) is

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, December 3, 2019 3:03:22 AM MST Basile B. via Digitalmars-d- learn wrote: > On Tuesday, 3 December 2019 at 09:58:36 UTC, Jonathan M Davis > > wrote: > > On Tuesday, December 3, 2019 12:12:18 AM MST Basile B. via > > > > Digitalmars-d- learn wrote: > >> I wish something like this was

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread mipri via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 10:02:47 UTC, Andrea Fontana wrote: On Tuesday, 3 December 2019 at 09:48:39 UTC, Basile B. wrote: You see what surprises me here is that we cannot express the special type that is `TypeNull` and that can only have one value (`null`) so instead we have to use

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 10:06:22 UTC, Mike Parker wrote: On Tuesday, 3 December 2019 at 10:03:22 UTC, Basile B. wrote: That's interesting details of D developement. Since you reply to the first message I think you have not followed but in the last reply I told that maybe we should be

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 10:03:22 UTC, Basile B. wrote: That's interesting details of D developement. Since you reply to the first message I think you have not followed but in the last reply I told that maybe we should be able to name the type of null. I think this relates to TBottom

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Andrea Fontana via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 09:48:39 UTC, Basile B. wrote: You see what surprises me here is that we cannot express the special type that is `TypeNull` and that can only have one value (`null`) so instead we have to use `auto` or `typeof(null)`. You can still create an alias anyway :)

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 09:58:36 UTC, Jonathan M Davis wrote: On Tuesday, December 3, 2019 12:12:18 AM MST Basile B. via Digitalmars-d- learn wrote: I wish something like this was possible, until I change the return type of `alwaysReturnNull` from `void*` to `auto`. --- class A {}

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, December 3, 2019 12:12:18 AM MST Basile B. via Digitalmars-d- learn wrote: > I wish something like this was possible, until I change the > return type of `alwaysReturnNull` from `void*` to `auto`. > > > --- > class A {} > class B {} > > auto alwaysReturnNull() // void*, don't compile >

Blog Post #92: Window Stats - Size and Maximize

2019-12-03 Thread Ron Tarrant via Digitalmars-d-learn
Today, we carry on looking at Window stats and how we can prepare to preserve them. You'll find it here: https://gtkdcoding.com/2019/12/03/0092-window-stats-ii-size.html

Re: Floating-Point arithmetic in dlang - Difference to other languages

2019-12-03 Thread mipri via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 09:22:49 UTC, Jan Hönig wrote: Today i have stumbled on Hacker News into: https://0.30004.com/ I am learning D, that's why i have to ask. Why does writefln("%.17f", .1+.2); not evaluate into: 0.30004, like C++ but rather to:

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 09:44:20 UTC, Basile B. wrote: On Tuesday, 3 December 2019 at 08:47:45 UTC, Andrea Fontana wrote: On Tuesday, 3 December 2019 at 07:24:31 UTC, Basile B. wrote: A testA() { return alwaysReturnNull(); // Tnull can be implictly converted to A

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 08:47:45 UTC, Andrea Fontana wrote: On Tuesday, 3 December 2019 at 07:24:31 UTC, Basile B. wrote: A testA() { return alwaysReturnNull(); // Tnull can be implictly converted to A } still nice tho. Why not [1]? [1] typeof(null)

Floating-Point arithmetic in dlang - Difference to other languages

2019-12-03 Thread Jan Hönig via Digitalmars-d-learn
Today i have stumbled on Hacker News into: https://0.30004.com/ I am learning D, that's why i have to ask. Why does writefln("%.17f", .1+.2); not evaluate into: 0.30004, like C++ but rather to: 0.2 Many other languages evaluate to

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Andrea Fontana via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 07:24:31 UTC, Basile B. wrote: A testA() { return alwaysReturnNull(); // Tnull can be implictly converted to A } still nice tho. Why not [1]? [1] typeof(null) alwaysReturnNull() { ... } Andrea