On 11/14/22 19:05, Elfstone wrote:
> @safe
> int[] foo()
> {
> int[1024] static_array;
> // return static_array[]; // Error: returning `static_array[]`
> escapes a reference to local variable `static_array`
That is trivial for the compiler to catch.
>
On Tuesday, 15 November 2022 at 04:10:37 UTC, rikki cattermole
wrote:
On 15/11/2022 5:10 PM, Elfstone wrote:
I just checked the DIP list and #1000 is marked superseded.
Any idea what supersedes it?
The implementation.
Cool.
On 15/11/2022 5:10 PM, Elfstone wrote:
I just checked the DIP list and #1000 is marked superseded. Any idea
what supersedes it?
The implementation.
On Tuesday, 15 November 2022 at 03:18:17 UTC, Siarhei Siamashka
wrote:
On Tuesday, 15 November 2022 at 03:05:30 UTC, Elfstone wrote:
So the compiler detects escaping in foo() but not in bar(),
this doesn't look right.
The compiler can detect it with -dip1000 command line option.
Is there a
On Tuesday, 15 November 2022 at 03:05:30 UTC, Elfstone wrote:
So the compiler detects escaping in foo() but not in bar(),
this doesn't look right.
The compiler can detect it with -dip1000 command line option.
Is there a way to tell whether a slice is from a dynamic array
or a static array?
On Tuesday, 15 November 2022 at 02:50:44 UTC, Siarhei Siamashka
wrote:
On Tuesday, 15 November 2022 at 02:26:41 UTC, Elfstone wrote:
By assigning aSlice to arr or a, it seemingly escapes the
scope, I thought there'd be errors, but the code compiles just
fine.
Is it really safe though?
No,
On Tuesday, 15 November 2022 at 02:49:55 UTC, Mike Parker wrote:
It's not the scope that matters here. It's the stack. Memory
allocated in the inner scope uses the function stack, so it's
all valid until the function exits.
And that was just so, so wrong. Of course destructors get called
On Tuesday, 15 November 2022 at 02:26:41 UTC, Elfstone wrote:
By assigning aSlice to arr or a, it seemingly escapes the
scope, I thought there'd be errors, but the code compiles just
fine.
Is it really safe though?
No, it's not safe. You can add `@safe:` line in the beginning of
your
On Tuesday, 15 November 2022 at 02:26:41 UTC, Elfstone wrote:
I failed to find any documentation, except dynamic array slices
will be taken care of by GC, but I assume it's not the case
with static arrays.
A slice is a view on the existing memory owned by the original
array. No allocations
On Monday, 14 November 2022 at 21:05:01 UTC, kdevel wrote:
[...]
the runtimes are
ftw : 98 ms, 470 ÎŒs, and 2 *beeep*
dirEntries: 170 ms, 515 ÎŒs, and 2 *beeep*
(to be continued)
When I examine the process with strace it appears that the ftw
version gets the whole information
On Monday, 14 November 2022 at 21:07:42 UTC, Adam D Ruppe wrote:
On Monday, 14 November 2022 at 21:00:38 UTC, matheus wrote:
void[] getFoo(){
writeln(cast(int[])bar);
auto foo = getFoo();
writeln(foo);
Prints:
[1, 0]
[2, 0, 0, 0, 0, 0, 0, 0]
Looking through godbolt.org the ASM
On Friday, 11 November 2022 at 16:00:12 UTC, Ali Çehreli wrote:
On 11/11/22 05:13, kdevel wrote:
> dmd -O compiled patched (see below!) version applied to
/usr/bin on my
> desktop
> yields:
>
> ftw : 363 ms, 750 ÎŒs, and 5 [*]
> dirEntries: 18 secs, 831 ms, 738 ÎŒs, and 3 [*]
Great. I
On Monday, 14 November 2022 at 21:00:38 UTC, matheus wrote:
void[] getFoo(){
writeln(cast(int[])bar);
auto foo = getFoo();
writeln(foo);
Prints:
[1, 0]
[2, 0, 0, 0, 0, 0, 0, 0]
Looking through godbolt.org the ASM generated with both
So why the array generated from getFoo() is 4
Hi all,
Well my doubt is pretty much the title for the snippet below:
import std.stdio;
void[] getFoo(){
void[] _ = new void[int.sizeof*2];
(cast(int[])_)[0] = 2;
return _;
}
void main() {
void[] bar = new void[int.sizeof*2];
(cast(int[])bar)[0] = 1;
On Monday, 14 November 2022 at 17:08:38 UTC, Gavin Ray wrote:
Just came here to say I hit the same bug, here's my import list:
* https://issues.dlang.org/show_bug.cgi?id=19937
object._d_assert_fail linker error if compiling with
-checkaction=context
*
On Monday, 14 November 2022 at 14:43:50 UTC, Preetpal wrote:
On Monday, 14 November 2022 at 10:44:11 UTC, Imperatorn wrote:
On Tuesday, 13 September 2022 at 19:54:15 UTC, Preetpal wrote:
[...]
Have you set longPathAware in the applications manifest?
Yeah that's how I dealt with the issue.
On Saturday, 28 May 2022 at 23:02:45 UTC, kdevel wrote:
On Friday, 18 March 2022 at 19:42:02 UTC, Anonymouse wrote:
On Thursday, 17 March 2022 at 14:00:45 UTC, kdevel wrote:
If ```import std.regex;``` is commented out or if
```-checkaction=context``` is removed from the cmd line the
unittest
On Monday, 14 November 2022 at 07:57:16 UTC, Kagamin wrote:
This works for me:
```
shared SyncAA!(string,string) saa;
void f()
{
saa=new shared SyncAA!(string,string)("1","2");
saa.keys();
saa["12"]="34";
saa.remove("12");
}
```
The strange error message I got
On Monday, 14 November 2022 at 10:44:11 UTC, Imperatorn wrote:
On Tuesday, 13 September 2022 at 19:54:15 UTC, Preetpal wrote:
In Windows 10, Version 1607 (and later), you can [enable long
paths](https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry)
On Monday, 14 November 2022 at 00:29:40 UTC, Tejas wrote:
He said on Discord he want contiguous data structure, rbtree
allocates too much
OK, I guess this person got their question answered on Discord
and does not need any further assistance.
On Monday, 14 November 2022 at 10:44:11 UTC, Imperatorn wrote:
On Tuesday, 13 September 2022 at 19:54:15 UTC, Preetpal wrote:
In Windows 10, Version 1607 (and later), you can [enable long
paths](https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry)
On Tuesday, 13 September 2022 at 19:54:15 UTC, Preetpal wrote:
In Windows 10, Version 1607 (and later), you can [enable long
paths](https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry) which bypasses the MAX_PATH limitation for local paths (e.g.,
On Sunday, 13 November 2022 at 19:06:40 UTC, 0xEAB wrote:
Why does only the latter sample compile?
The former leads to the following warning:
Are you using the `-preview=dip1000` compiler flag?
I didn't manage to reproduce this in a simple example of my own.
The closest I equivalent I
This works for me:
```
synchronized final class SyncAA(K, V)
{
this(K key, V val) { sharedTable[key]=val; }
V opIndex(K key) { return sharedTable[key]; }
V opIndexAssign(V value, K key) { return sharedTable[key]=value;
}
const(K[]) keys() const { return
24 matches
Mail list logo