Re: make dub use my version of dmd

2020-04-17 Thread WebFreak001 via Digitalmars-d-learn
On Thursday, 16 April 2020 at 19:56:44 UTC, Adam D. Ruppe wrote: For future reference, newer dubs (v 1.17 + i think) allow --compiler=dmd-version for example. You need to put the exe in your PATH and rename it yourself, but it recognizes *dmd-* (or *ldc2-* or *gdc-*) all the same so you can s

Re: mir: How to change iterator?

2020-04-17 Thread WebFreak001 via Digitalmars-d-learn
On Tuesday, 14 April 2020 at 20:24:05 UTC, jmh530 wrote: In the code below, I multiply some slice by 5 and then check whether it equals another slice. This fails for mir's approxEqual because the two are not the same types (yes, I know that isClose in std.math works). I was trying to convert th

Re: mir: How to change iterator?

2020-04-17 Thread WebFreak001 via Digitalmars-d-learn
On Friday, 17 April 2020 at 08:40:36 UTC, WebFreak001 wrote: On Tuesday, 14 April 2020 at 20:24:05 UTC, jmh530 wrote: [...] Use std.algorithm:equal for range compare with approxEqual for your comparator: assert(equal!approxEqual(y, [2.5, 2.5].sliced(2))); simplified: assert(equal!approxE

Re: Checked!({short, ushort, byte, ubyte}, Throw): compilation fails

2020-04-17 Thread kdevel via Digitalmars-d-learn
On Friday, 17 April 2020 at 04:29:06 UTC, Meta wrote: Unlike C/C++, char is not a numeric type in D; It's a UTF-8 code point: Thanks, it's a code /unit/. main reads now: void main () { bar!ubyte; bar!byte; bar!ushort; bar!short; bar!uint; bar!int; bar!ulong; bar!long; }

Re: __init unresolved external when using C library structs converted with dstep

2020-04-17 Thread Robert M. Münch via Digitalmars-d-learn
On 2020-04-16 18:33:51 +, Basile B. said: On Tuesday, 14 April 2020 at 17:51:58 UTC, Robert M. Münch wrote: I use a C libary and created D imports with dstep. It translates the C structs to D structs. When I now use them, everything compiles fine but I get an unresolved external error:

Re: __init unresolved external when using C library structs converted with dstep

2020-04-17 Thread Dominikus Dittes Scherkl via Digitalmars-d-learn
On Friday, 17 April 2020 at 08:59:41 UTC, Robert M. Münch wrote: How would that look like? myStruct ms = void; // ??? Exactly.

Re: __init unresolved external when using C library structs converted with dstep

2020-04-17 Thread Robert M. Münch via Digitalmars-d-learn
On 2020-04-17 09:06:44 +, Dominikus Dittes Scherkl said: On Friday, 17 April 2020 at 08:59:41 UTC, Robert M. Münch wrote: How would that look like? myStruct ms = void; // ??? Exactly. Cool... never saw this / thought about it... will remember it, hopefully. -- Robert M. Münch http://w

Re: make dub use my version of dmd

2020-04-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/17/20 4:37 AM, WebFreak001 wrote: On Thursday, 16 April 2020 at 19:56:44 UTC, Adam D. Ruppe wrote: For future reference, newer dubs (v 1.17 + i think) allow --compiler=dmd-version for example. You need to put the exe in your PATH and rename it yourself, but it recognizes *dmd-* (or *ldc2

Re: Checked!({short, ushort, byte, ubyte}, Throw): compilation fails

2020-04-17 Thread Simen Kjærås via Digitalmars-d-learn
On Friday, 17 April 2020 at 08:59:19 UTC, kdevel wrote: On Friday, 17 April 2020 at 04:29:06 UTC, Meta wrote: Unlike C/C++, char is not a numeric type in D; It's a UTF-8 code point: Thanks, it's a code /unit/. main reads now: void main () { bar!ubyte; bar!byte; bar!ushort; bar!sho

Re: Extracting user defined attributes on function parameters

2020-04-17 Thread Jean-Louis Leroy via Digitalmars-d-learn
Alas the presence of parameter UDAs breaks std.traits.ParameterDefaults: import std.traits; struct attr; void f(@attr int); pragma(msg, ParameterDefaults!f.stringof); Error: dmd -c bug.d bug.d(4): Error: undefined identifier `attr`, did you mean variable `ptr`? /home/jll/dlang/dmd-2.090.1/

Re: Extracting user defined attributes on function parameters

2020-04-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 17 April 2020 at 16:40:15 UTC, Jean-Louis Leroy wrote: Alas the presence of parameter UDAs breaks std.traits.ParameterDefaults: import std.traits; struct attr; void f(@attr int); This part seems fine... pragma(msg, ParameterDefaults!f.stringof); It is this, specifically, that

Integration tests

2020-04-17 Thread Russel Winder via Digitalmars-d-learn
Hi, Thinking of trying to do the next project in D rather than Rust, but… Rust has built in unit testing on a module basis. D has this so no problem. Rust allows for integration tests in the tests directory of a project. These are automatically build and run along with all unit tests as part of

Re: Extracting user defined attributes on function parameters

2020-04-17 Thread Simen Kjærås via Digitalmars-d-learn
On Friday, 17 April 2020 at 16:54:42 UTC, Adam D. Ruppe wrote: This part seems fine... pragma(msg, ParameterDefaults!f.stringof); It is this, specifically, that causes the problem. Replace it with: void main() { import std.stdio; writeln(ParameterDefaults!f.stringof); } an

Re: Extracting user defined attributes on function parameters

2020-04-17 Thread Jean-Louis Leroy via Digitalmars-d-learn
On Friday, 17 April 2020 at 16:54:42 UTC, Adam D. Ruppe wrote: void main() { import std.stdio; writeln(ParameterDefaults!f.stringof); } and it is fine. Well, can't do. I need this purely at compile time, and cross-module. That's for supporting UDAs and default parameter value

Re: Extracting user defined attributes on function parameters

2020-04-17 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Apr 17, 2020 at 05:33:23PM +, Simen Kjærås via Digitalmars-d-learn wrote: > On Friday, 17 April 2020 at 16:54:42 UTC, Adam D. Ruppe wrote: [...] > > So pragma(msg) is doing something really weird, the bug doesn't > > appear to be in Phobos per se, I think it is the compiler doing the >

Re: Extracting user defined attributes on function parameters

2020-04-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 17 April 2020 at 17:31:32 UTC, Jean-Louis Leroy wrote: Well, can't do. I need this purely at compile time, and cross-module. And the CTFE engine gets weird with it too dmd will have to fix this. But default parameters might not be possible in general at CT anyway... it is act

Re: Integration tests

2020-04-17 Thread Jon Degenhardt via Digitalmars-d-learn
On Friday, 17 April 2020 at 16:56:57 UTC, Russel Winder wrote: Hi, Thinking of trying to do the next project in D rather than Rust, but… Rust has built in unit testing on a module basis. D has this so no problem. Rust allows for integration tests in the tests directory of a project. These

Re: Extracting user defined attributes on function parameters

2020-04-17 Thread Jean-Louis Leroy via Digitalmars-d-learn
On Friday, 17 April 2020 at 17:48:06 UTC, Adam D. Ruppe wrote: On Friday, 17 April 2020 at 17:31:32 UTC, Jean-Louis Leroy wrote: Well, can't do. I need this purely at compile time, and cross-module. And the CTFE engine gets weird with it too dmd will have to fix this. But default parame

Re: Extracting user defined attributes on function parameters

2020-04-17 Thread Jean-Louis Leroy via Digitalmars-d-learn
On Friday, 17 April 2020 at 18:05:39 UTC, Jean-Louis Leroy wrote: Interesting example, but all hope is not lost. `a` could (should?) be passed as an alias in __parameters. Okay I take this back...

Re: Extracting user defined attributes on function parameters

2020-04-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 17 April 2020 at 18:05:39 UTC, Jean-Louis Leroy wrote: Interesting example, but all hope is not lost. `a` could (should?) be passed as an alias in __parameters. Well, __parameters itself actually kinda works. The compiler knows it is an expression and can stringify it or evaluate it

Re: Checked!({short, ushort, byte, ubyte}, Throw): compilation fails

2020-04-17 Thread kdevel via Digitalmars-d-learn
On Friday, 17 April 2020 at 12:59:20 UTC, Simen Kjærås wrote: [Deleted text makes sense] And assigning from an int to a short may discard data, so it's statically disallowed by Checked. This is a deliberate design choice, and the appropriate way to handle it is with a cast: unittest { im

Working with cmd

2020-04-17 Thread Quantium via Digitalmars-d-learn
Are there any libs which can be used to access cmd commands?

Re: Working with cmd

2020-04-17 Thread novice2 via Digitalmars-d-learn
On Friday, 17 April 2020 at 21:38:23 UTC, Quantium wrote: Are there any libs which can be used to access cmd commands? std.process https://dlang.org/phobos/std_process.html#.execute