Re: Why simple code using Rebindable doesn't compile ?

2016-05-30 Thread chmike via Digitalmars-d-learn
On Monday, 30 May 2016 at 21:32:46 UTC, Alex Parrill wrote: On Monday, 30 May 2016 at 10:09:19 UTC, chmike wrote: Why can't info() return a Rebindable!(immutable(InfoImpl)) ? What do you mean? `info` returns an `immutable(InfoImpl)`, not a `Rebindable!(immutable(InfoImpl))`. Rebindable

Re: Operator overloading through UFCS doesn't work

2016-05-30 Thread pineapple via Digitalmars-d-learn
Here's one more vote for extending UFCS to operator overloading. Elie wrote that it's "a restriction that seems pointless and arbitrary"... which summarizes my own thoughts rather well, too. There are certainly concerning scenarios that can arise from making this change, but the correct way

Re: Why aren't overloaded nested functions allowed?

2016-05-30 Thread pineapple via Digitalmars-d-learn
On Monday, 30 May 2016 at 16:22:26 UTC, Max Samukha wrote: From the spec (https://dlang.org/spec/function.html#nested): "Nested functions cannot be overloaded." Anybody knows what's the rationale? I'm guessing it's related to - Unlike module level declarations, declarations within function

Re: Why do some T.init evaluate to true while others to false?

2016-05-30 Thread Alex Parrill via Digitalmars-d-learn
On Friday, 27 May 2016 at 15:49:16 UTC, ArturG wrote: On Friday, 27 May 2016 at 15:24:18 UTC, Adam D. Ruppe wrote: On Friday, 27 May 2016 at 15:19:50 UTC, ArturG wrote: yes but i have to check for that when some one does Why? This is no different than if they set any of the other four

Re: Why simple code using Rebindable doesn't compile ?

2016-05-30 Thread Alex Parrill via Digitalmars-d-learn
On Monday, 30 May 2016 at 10:09:19 UTC, chmike wrote: This code compile, but array appending doesn't work alias Rebindable!(immutable(InfoImpl)) Info; class InfoImpl { void foo() {} static immutable(InfoImpl) info() { __gshared immutable InfoImpl x = new immutable

Re: D, GTK, Qt, wx,…

2016-05-30 Thread Vadim Lopatin via Digitalmars-d-learn
On Sunday, 29 May 2016 at 11:03:36 UTC, Russel Winder wrote: Is there even a wxD? Or perhaps there is an alternative that fits the bill of being production ready now, and either gives the same UI across all platforms or provides a platform UI with no change of source code, just a

Re: Why do some T.init evaluate to true while others to false?

2016-05-30 Thread ArturG via Digitalmars-d-learn
On Friday, 27 May 2016 at 14:48:59 UTC, Adam D. Ruppe wrote: On Friday, 27 May 2016 at 14:43:47 UTC, ArturG wrote: if(value is typeof(value).init) ... that still requiers a special case for floating points, arrays and optionally empty string literals. Have you tried? That should work

Re: String compare in words?

2016-05-30 Thread Christophe Meessen via Digitalmars-d-learn
I didn't check assembly for '=='. What I have seen is that struct comparison in dmd is implemented as byte per byte compare even if the struct is 64bit long (e.g. Rebindable). I suppose dmd uses this strategy because struct/array may not be 64bit aligned, or they could have different

Why aren't overloaded nested functions allowed?

2016-05-30 Thread Max Samukha via Digitalmars-d-learn
From the spec (https://dlang.org/spec/function.html#nested): "Nested functions cannot be overloaded." Anybody knows what's the rationale?

Re: Operator overloading through UFCS doesn't work

2016-05-30 Thread Marc Schütz via Digitalmars-d-learn
On Sunday, 29 May 2016 at 07:18:10 UTC, Jonathan M Davis wrote: On Friday, May 27, 2016 09:08:20 Marc Schütz via Digitalmars-d-learn wrote: On Thursday, 26 May 2016 at 06:23:17 UTC, Jonathan M Davis wrote: > The difference is that it's impossible to do > 10.opBinary!"+"(15), so if you're

Re: String compare in words?

2016-05-30 Thread Márcio Martins via Digitalmars-d-learn
On Monday, 30 May 2016 at 09:28:29 UTC, ag0aep6g wrote: On 05/29/2016 10:40 PM, qznc wrote: bool string_cmp_opt(immutable(ubyte)[] x, immutable(ubyte)[] y) { Having "string" in the function name may be a bit misleading. This doesn't have any special functionality for

Re: How to hash any type to an integer?

2016-05-30 Thread Gary Willoughby via Digitalmars-d-learn
On Sunday, 29 May 2016 at 16:26:58 UTC, Seb wrote: On Sunday, 29 May 2016 at 11:05:21 UTC, Gary Willoughby wrote: I'm currently implementing a hash map as an exercise and wondered if there is a built-in function I could use to hash keys effectively? What I'm looking for is a function that

Re: Why simple code using Rebindable doesn't compile ?

2016-05-30 Thread chmike via Digitalmars-d-learn
This code compile, but array appending doesn't work alias Rebindable!(immutable(InfoImpl)) Info; class InfoImpl { void foo() {} static immutable(InfoImpl) info() { __gshared immutable InfoImpl x = new immutable InfoImpl; return x; } } void main() {

Re: String compare in words?

2016-05-30 Thread ag0aep6g via Digitalmars-d-learn
On 05/29/2016 10:40 PM, qznc wrote: bool string_cmp_opt(immutable(ubyte)[] x, immutable(ubyte)[] y) { Having "string" in the function name may be a bit misleading. This doesn't have any special functionality for text/characters/Unicode, does it? Should have const parameters, not immutable.

Re: Why simple code using Rebindable doesn't compile ?

2016-05-30 Thread chmike via Digitalmars-d-learn
Oops, the duplicate alias instruction and main are copy past error. It looks like the code was already too complex for me. ;) Here is the code I tested import std.typecons; Rebindable!(immutable TestImpl) Test; class TestImpl { void foo() {} Test test() { __gshared x = new

Why simple code using Rebindable doesn't compile ?

2016-05-30 Thread chmike via Digitalmars-d-learn
Hello, here is a program stripped down to the minimum code that doesn't compile import std.typecons; Rebindable!(immutable TestImpl) Test; Rebindable!(immutable TestImpl) Test; class TestImpl { void foo() {} Test test() { __gshared x = new immutable TestImpl; return

Re: Legal operator overloading

2016-05-30 Thread Mike Parker via Digitalmars-d-learn
On Monday, 30 May 2016 at 05:54:42 UTC, Nicholas Wilson wrote: Is it legal/possible to overload the unary * operator? Also is it legal/possible to individually overload the comparison operators and not return a bool? Yes to unary * (see [1]). No to the rest. Comparisons are always lowered to