Re: Annotating SortedRange.empty const: Best way to auto-deduce annotations?

2020-09-02 Thread SimonN via Digitalmars-d-learn
On Wednesday, 2 September 2020 at 21:40:59 UTC, Steven Schveighoffer wrote: What they can do is template the `this` parameter. Then if the underlying range supports calling that way, it will work, otherwise it won't. using `template this` should be compatible with the existing code I would th

Re: Annotating SortedRange.empty const: Best way to auto-deduce annotations?

2020-09-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/2/20 5:23 PM, SimonN wrote: Hi, About this issue in Phobos: https://issues.dlang.org/show_bug.cgi?id=21216 SortedRange.empty should be const, .front should be inout Just adding const/inout to SortedRange's methods won't be enough; if we add const/inout here, then many other Phobos ranges

Annotating SortedRange.empty const: Best way to auto-deduce annotations?

2020-09-02 Thread SimonN via Digitalmars-d-learn
Hi, About this issue in Phobos: https://issues.dlang.org/show_bug.cgi?id=21216 SortedRange.empty should be const, .front should be inout Just adding const/inout to SortedRange's methods won't be enough; if we add const/inout here, then many other Phobos ranges need to become const/inout-correc

Re: Bug in import(...) on Windows?

2020-09-02 Thread Andrey Zherikov via Digitalmars-d-learn
On Wednesday, 2 September 2020 at 20:55:34 UTC, Andrey Zherikov wrote: I think the issue is here: https://github.com/dlang/dmd/blob/master/src/dmd/root/filename.d#L736-L748 Yes, issue is there. This change (removal of "c == '\\' || ") fixes it: diff --git a/src/dmd/root/filename.d b/src/dmd/

Re: Bug in import(...) on Windows?

2020-09-02 Thread Andrey Zherikov via Digitalmars-d-learn
On Wednesday, 2 September 2020 at 19:13:47 UTC, Adam D. Ruppe wrote: On Wednesday, 2 September 2020 at 18:40:55 UTC, Andrey Zherikov wrote: If I provide -Jfoo to dmd, doesn't it mean my consent to use the contents of directory foo? Yeah, but dmd has been inconsistent on platforms about if it

Re: Bug in import(...) on Windows?

2020-09-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/2/20 4:48 PM, Andrey Zherikov wrote: On Wednesday, 2 September 2020 at 20:23:15 UTC, Steven Schveighoffer wrote: What I'm wondering is if it needs to be ./file instead of .\file. Can you hard code that and see if it works? This actually works:     pragma(msg, import("file"));     pragma

Re: Bug in import(...) on Windows?

2020-09-02 Thread Andrey Zherikov via Digitalmars-d-learn
On Wednesday, 2 September 2020 at 20:23:15 UTC, Steven Schveighoffer wrote: What I'm wondering is if it needs to be ./file instead of .\file. Can you hard code that and see if it works? This actually works: pragma(msg, import("file")); pragma(msg, buildPath(".", "file")); pragma(msg

Re: Bug in import(...) on Windows?

2020-09-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/2/20 1:47 PM, Adam D. Ruppe wrote: On Wednesday, 2 September 2020 at 17:39:04 UTC, Andrey Zherikov wrote: Is this a bug in dmd? I think it is an old bug filed (I can't find it though) about inconsistent platform behavior but it is allowed by spec for the compiler to reject any path comp

Re: Bug in import(...) on Windows?

2020-09-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 2 September 2020 at 18:40:55 UTC, Andrey Zherikov wrote: If I provide -Jfoo to dmd, doesn't it mean my consent to use the contents of directory foo? Yeah, but dmd has been inconsistent on platforms about if it allows subdirectories. Right now I think it just strips all slashes o

Re: Bug in import(...) on Windows?

2020-09-02 Thread Andrey Zherikov via Digitalmars-d-learn
On Wednesday, 2 September 2020 at 17:47:47 UTC, Adam D. Ruppe wrote: On Wednesday, 2 September 2020 at 17:39:04 UTC, Andrey Zherikov wrote: Is this a bug in dmd? I think it is an old bug filed (I can't find it though) about inconsistent platform behavior but it is allowed by spec for the com

Re: How to create compile-time container?

2020-09-02 Thread Andrey Zherikov via Digitalmars-d-learn
On Wednesday, 2 September 2020 at 17:40:55 UTC, Andrey Zherikov wrote: On Wednesday, 2 September 2020 at 14:38:30 UTC, Steven Schveighoffer wrote: Here is what I would do instead: Thanks, I'll try it. This actually works! Thanks a lot!

Re: Bug in import(...) on Windows?

2020-09-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 2 September 2020 at 17:39:04 UTC, Andrey Zherikov wrote: Is this a bug in dmd? I think it is an old bug filed (I can't find it though) about inconsistent platform behavior but it is allowed by spec for the compiler to reject any path components. import("") is supposed to just

Re: How to create compile-time container?

2020-09-02 Thread Andrey Zherikov via Digitalmars-d-learn
On Wednesday, 2 September 2020 at 14:38:30 UTC, Steven Schveighoffer wrote: Here is what I would do instead: Thanks, I'll try it.

Re: Bug in import(...) on Windows?

2020-09-02 Thread Andrey Zherikov via Digitalmars-d-learn
Adding some verbosity: pragma(msg, import("file")); pragma(msg, buildPath(".", "file")); pragma(msg, import(buildPath(".", "file"))); Result on Ubuntu: === hello ./file hello === Result on Windows: === hello .\file parser.d(47): Error: file ".\\file" cannot be found o

Bug in import(...) on Windows?

2020-09-02 Thread Andrey Zherikov via Digitalmars-d-learn
My code (test.d): === void main() { import std.path: buildPath; pragma(msg, import("file")); pragma(msg, import(buildPath(".", "file"))); } === Content of file "file" is one line with "hello" text. Running command: dmd -J. -run test.d Result on Ubuntu: === hello hello

Re: How to create compile-time container?

2020-09-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/2/20 5:56 AM, Andrey Zherikov wrote: == Everything works well until I have included scripts in subdirectories: ├── dir1 │   ├── dir2 │   │   └── script │   └── script └── script Content: == script msg hello include dir1/script == dir1/script msg hello fro

Re: I think Associative Array should throw Exception

2020-09-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/1/20 10:46 PM, James Blachly wrote: On 9/1/20 2:55 PM, Steven Schveighoffer wrote: On 9/1/20 2:20 PM, Jesse Phillips wrote: Using RangeError is nice as it allows code to use array index inside `nothrow.` This is the big sticking point -- code that is nothrow would no longer be able to

Re: BetterC + WASM Update

2020-09-02 Thread Seb via Digitalmars-d-learn
On Tuesday, 1 September 2020 at 20:39:58 UTC, Mike Brown wrote: Hi All, Thank you for your replies. My tests have been via compiler explorer. https://godbolt.org/z/4f9nKj I have done this without -BetterC, as the dynamic array fails. I guess that uses GC? Is there an alternative that works

Re: How to create compile-time container?

2020-09-02 Thread Andrey Zherikov via Digitalmars-d-learn
On Tuesday, 1 September 2020 at 19:38:29 UTC, Steven Schveighoffer wrote: On 9/1/20 3:09 PM, Andrey Zherikov wrote: Unfortunately this won't work if there is a function 'bar' in different module that calls 'foo': You should post a full example you expect to work or not work, then we can discu

Re: How to use libmir --> mir-algorithm, numir, mir-random?

2020-09-02 Thread 9il via Digitalmars-d-learn
On Wednesday, 2 September 2020 at 07:01:48 UTC, Shaleen Chhabra wrote: Hi, The libmir libraries can be found here: https://github.com/libmir I wish to use mir-algorithm and numir so that i can directly use .npy format from python and perform the required analysis. I checked out latest comm

Re: How to use libmir --> mir-algorithm, numir, mir-random?

2020-09-02 Thread WebFreak001 via Digitalmars-d-learn
On Wednesday, 2 September 2020 at 07:01:48 UTC, Shaleen Chhabra wrote: Hi, The libmir libraries can be found here: https://github.com/libmir I wish to use mir-algorithm and numir so that i can directly use .npy format from python and perform the required analysis. I checked out latest comm

How to use libmir --> mir-algorithm, numir, mir-random?

2020-09-02 Thread Shaleen Chhabra via Digitalmars-d-learn
Hi, The libmir libraries can be found here: https://github.com/libmir I wish to use mir-algorithm and numir so that i can directly use .npy format from python and perform the required analysis. I checked out latest commits of each of the libraries mentioned --> mir-algorithm, mir-random and