Re: mutable pointers as associative array keys

2023-04-11 Thread John Colvin via Digitalmars-d-learn
On Monday, 10 April 2023 at 20:31:43 UTC, Steven Schveighoffer 
wrote:

On 4/10/23 4:25 PM, Steven Schveighoffer wrote:
It's also completely useless. Having const keys does nothing 
to guarantee unchanging keys. Another half-assed attempt to be 
encode correct semantics but fails completely in its goal.


In case you wonder how old this is:

https://issues.dlang.org/show_bug.cgi?id=11477
https://issues.dlang.org/show_bug.cgi?id=12491#c2

-Steve


Oh dear.


Re: mutable pointers as associative array keys

2023-04-10 Thread Steven Schveighoffer via Digitalmars-d-learn

On 4/10/23 4:25 PM, Steven Schveighoffer wrote:
It's also completely useless. Having const keys does nothing to 
guarantee unchanging keys. Another half-assed attempt to be encode 
correct semantics but fails completely in its goal.


In case you wonder how old this is:

https://issues.dlang.org/show_bug.cgi?id=11477
https://issues.dlang.org/show_bug.cgi?id=12491#c2

-Steve


Re: mutable pointers as associative array keys

2023-04-10 Thread Steven Schveighoffer via Digitalmars-d-learn

On 4/10/23 2:14 PM, John Colvin wrote:

It seems that it isn't possible, am I missing something?

alias Q = int[int*];
pragma(msg, Q); // int[const(int)*]


Yep, it's been that way forever. Only with pointers and arrays. It's 
fine with mutable classes and structs (even if they contain pointers).



Also, is this documented somewhere?


No.

It's also completely useless. Having const keys does nothing to 
guarantee unchanging keys. Another half-assed attempt to be encode 
correct semantics but fails completely in its goal.


-Steve


Re: mutable pointers as associative array keys

2023-04-10 Thread JG via Digitalmars-d-learn

On Monday, 10 April 2023 at 18:14:56 UTC, John Colvin wrote:

It seems that it isn't possible, am I missing something?

alias Q = int[int*];
pragma(msg, Q); // int[const(int)*]

Also, is this documented somewhere?


It seems to be so (which is strange) and I can't image it is by 
design since you

can do this:

```d
static struct Pointer(T) { T* val; }
int[Pointer!int] f;
pragma(msg,typeof(f));
int* val = new int;
*val = 5;
f[Pointer!int(val)] = 12;
*val = 6;
f[Pointer!int(val)].writeln;  //12
```



mutable pointers as associative array keys

2023-04-10 Thread John Colvin via Digitalmars-d-learn

It seems that it isn't possible, am I missing something?

alias Q = int[int*];
pragma(msg, Q); // int[const(int)*]

Also, is this documented somewhere?