May 23, 2021

On Saturday, 15 May 2021 at 14:31:08 UTC, Alain De Vos wrote:

>

Which parts in dlang don't you use and why ?

Auto return types i find dangerous to use.

I found auto and ref(yes just ref) return types very useful for bypassing the type system, eg.:

///function requires lvalue and the return value can be of any type while still being the same data.
ref mutateSomething(A)(ref A something) {
    static if (isArray!A){/*...*/} else {/*...*/}
    return something;
}

Other than that, i've found tuples limited in usage compared to just using a struct or static arrays.(the main problem is the inability to use runtime indexing even if the types match.)

The rest, i don't use from lack of interest or awareness it even exists.

May 23, 2021

On Sunday, 23 May 2021 at 14:13:36 UTC, Alain De Vos wrote:

>

This one compiles without any problem.
Maybe someone can enlighten us on the status of scope(d)-variables and dip-1000.
It is not fully clear for me.

import std.stdio;
void main() @trusted
{
int *q=null;
    {
	int a;
	q=&a;
    }
*q=5;
}

You might find this helpful:

https://dlang.org/blog/2016/09/28/how-to-write-trusted-code-in-d/

1 2 3
Next ›   Last »