On Sat, May 26, 2012 at 09:53:07PM +0200, Andrej Mitrovic wrote:
> I don't understand this:
>
> import std.stdio;
>
> struct Symbol { string val; }
>
> void main()
> {
> int[string] hash1;
> hash1["1".idup] = 1;
> hash1["1".idup] = 2;
> writeln(hash1); // writes "["1":2]"
>
>
On 05/27/2012 04:22 AM, Andrej Mitrovic wrote:
On 5/27/12, Ali Çehreli wrote:
On 05/26/2012 05:13 PM, Ali Çehreli wrote:
> once you define toHash(), you
> must also define opCmp() and opEquals() that are all consistent with
> each other.
Correction: opEquals() is only for potential o
On 5/27/12, Ali Çehreli wrote:
> On 05/26/2012 05:13 PM, Ali Çehreli wrote:
>
> > once you define toHash(), you
> > must also define opCmp() and opEquals() that are all consistent with
> > each other.
>
> Correction: opEquals() is only for potential optimizations. What is
> needed alongside toH
On 05/26/2012 05:13 PM, Ali Çehreli wrote:
> once you define toHash(), you
> must also define opCmp() and opEquals() that are all consistent with
> each other.
Correction: opEquals() is only for potential optimizations. What is
needed alongside toHash() is just opCmp(), and the reason is to be
On 05/26/2012 12:53 PM, Andrej Mitrovic wrote:
I don't understand this:
import std.stdio;
struct Symbol { string val; }
void main()
{
int[string] hash1;
hash1["1".idup] = 1;
hash1["1".idup] = 2;
writeln(hash1); // writes "["1":2]"
int[Symbol] hash2;
Symbol sym1
On 5/27/12, Era Scarecrow wrote:
> Problem goes
> away when not idup-ing, but likely that is the compiler saving
> space and assigning the same pointer address (which makes sense).
Yes, the .idup was done on purpose here for demonstration.
On Saturday, 26 May 2012 at 22:02:10 UTC, Jonathan M Davis wrote:
Now, that aside, the results with hash2 definitely look like a
bug to me. It's probably just the result of one more of the
many issues with the current AA implementation.
This is what I'm guessing too. I've made toHashes in my
On Sunday, May 27, 2012 00:08:01 Andrej Mitrovic wrote:
> On 5/27/12, Jonathan M Davis wrote:
> > Why can't you have a toHash in your struct?
>
> I mean it doesn't seem to make any difference:
Yeah. I don't know what the deal is. There's definitely at least one bug here,
if not several.
> impo
On 5/27/12, Jonathan M Davis wrote:
> Why can't you have a toHash in your struct?
I mean it doesn't seem to make any difference:
import std.stdio;
struct Foo
{
string x;
size_t toHash() { return 1; }
}
void main()
{
int[Foo] hash;
Foo foo1 = Foo("a".idup);
Foo foo2 = Foo("a
On Saturday, May 26, 2012 21:53:07 Andrej Mitrovic wrote:
> I don't understand this:
>
> import std.stdio;
>
> struct Symbol { string val; }
>
> void main()
> {
> int[string] hash1;
> hash1["1".idup] = 1;
> hash1["1".idup] = 2;
> writeln(hash1); // writes "["1":2]"
>
> int[
I don't understand this:
import std.stdio;
struct Symbol { string val; }
void main()
{
int[string] hash1;
hash1["1".idup] = 1;
hash1["1".idup] = 2;
writeln(hash1); // writes "["1":2]"
int[Symbol] hash2;
Symbol sym1 = Symbol("1".idup);
Symbol sym2 = Symbol("1".idup);
11 matches
Mail list logo