On Friday, 29 September 2023 at 14:31:54 UTC, BoQsc wrote:
After being very happy about associative arrays of D Language,
I encountered that they are not `@nogc`friendly. Unsure if I
should wait for D language to support it, or do I need to
rethink everything.
You can work with AA's inside @n
After being very happy about associative arrays of D Language, I
encountered that they are not `@nogc`friendly. Unsure if I should
wait for D language to support it, or do I need to rethink
everything.
Error
```
onlineapp.d(20): Error: assigning an associative array element in
`@nogc` functio
Out of scope access to a variable using stored pointer address,
demonstration.
```
import std;
void outofcontext()
{
writeln("Hello D ", associative);
foreach (pointeraddress, information; associative)
{
writeln(*cast(string*)pointeraddress);
}
}
static string[void* ]
Bonus: Store hexadecimal literals in associative array of
pointer addresses.
```
import std;
void main()
{
string[void *] associative;
// Store Hexadecimal as pointer address in associative array
associative[cast(void *)0x7FFCD332CD60] = "someinformation";
// Store Hexadec
For some reason I thought this was something I wanted to achieve
and share.
```
import std;
void main()
{
string variable;
void * pointeraddress = &variable;
string[void *] associative;
associative[pointeraddress] = "someinformation";
writeln("Hello D ", pointeraddress);