Re: writef, compile-checked format, pointer

2021-08-09 Thread nov via Digitalmars-d-learn
On Monday, 9 August 2021 at 22:30:43 UTC, Ali Çehreli wrote: Error: expression `FormatException("Expected one of %s, %x or %X for pointer type.", i saw this message too, and this is one of reasons of my original question. '%s' bad for pointer in my cases, because result often contains somet

Re: Error when compile with DMD using -m64?

2021-08-09 Thread Marcone via Digitalmars-d-learn
On Monday, 9 August 2021 at 19:58:03 UTC, novice2 wrote: On Monday, 9 August 2021 at 19:53:48 UTC, Marcone wrote: program not run. compilation errors? runtime errors? Solved converting long and int.

Re: writef, compile-checked format, pointer

2021-08-09 Thread Ali Çehreli via Digitalmars-d-learn
On 8/9/21 3:46 PM, Adam D Ruppe wrote: > The compile time checker [...] implementation is really really > slow and pretty bloated in codegen too. > > My personal policy is to never use it. My personal policy is to kindly ask you to fix it! :p Ali

Re: writef, compile-checked format, pointer

2021-08-09 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 9 August 2021 at 22:30:43 UTC, Ali Çehreli wrote: I don't know the reason but I suspect a bug in the compile-time checker that involves .init values for arguments. The compile time checker is pretty bad tbh, it just tries to ctfe execute the given string and sees if it throws. That'

Re: How Add Local modules mymodule.d using DUB?

2021-08-09 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 9 August 2021 at 16:32:13 UTC, Marcone wrote: My main program need import a local module called mymodule.d. How can I add this module using DUB? Thank you. Let’s assume you just created a dub project in `myproject` with `dub init`. Place `mymodule.d` alongside `app.d` in `myproject

Re: writef, compile-checked format, pointer

2021-08-09 Thread Ali Çehreli via Digitalmars-d-learn
On 8/9/21 3:01 PM, Patrick Schluter wrote: > On Monday, 9 August 2021 at 19:38:28 UTC, novice2 wrote: >> format!"fmt"() and writef!"fmt"() templates >> with compile-time checked format string >> not accept %X for pointers, >> >> but format() and writef() accept it >> >> https://run.dlang.io/is/aQ

Re: writef, compile-checked format, pointer

2021-08-09 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 9 August 2021 at 22:01:18 UTC, Patrick Schluter wrote: On Monday, 9 August 2021 at 19:38:28 UTC, novice2 wrote: format!"fmt"() and writef!"fmt"() templates with compile-time checked format string not accept %X for pointers, but format() and writef() accept it https://run.dlang.io/is

Re: writef, compile-checked format, pointer

2021-08-09 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 9 August 2021 at 19:38:28 UTC, novice2 wrote: format!"fmt"() and writef!"fmt"() templates with compile-time checked format string not accept %X for pointers, but format() and writef() accept it https://run.dlang.io/is/aQ05Ux ``` void main() { import std.stdio: writefln; int x

Re: Error when compile with DMD using -m64?

2021-08-09 Thread novice2 via Digitalmars-d-learn
On Monday, 9 August 2021 at 19:53:48 UTC, Marcone wrote: program not run. compilation errors? runtime errors?

Error when compile with DMD using -m64?

2021-08-09 Thread Marcone via Digitalmars-d-learn
When I compile program in Ly Windows x64 using dmd flag -m64 the program not run. How fix it?

writef, compile-checked format, pointer

2021-08-09 Thread novice2 via Digitalmars-d-learn
format!"fmt"() and writef!"fmt"() templates with compile-time checked format string not accept %X for pointers, but format() and writef() accept it https://run.dlang.io/is/aQ05Ux ``` void main() { import std.stdio: writefln; int x; writefln("%X", &x); //ok writefln!"%s"(&x); //

Re: nested templates using Complex! with slices, ... confused, I am!

2021-08-09 Thread james.p.leblanc via Digitalmars-d-learn
On Monday, 9 August 2021 at 18:44:34 UTC, Paul Backus wrote: On Monday, 9 August 2021 at 18:35:56 UTC, james.p.leblanc wrote: ```d T[] foo_temp(Complex!T[])(T x, T y){ auto r = [x, x]; auto i = [y, y]; auto z = [ Complex!T(x, y), Complex!T(x,y) ]; return z; } ``` void main(){ auto yd

Re: nested templates using Complex! with slices, ... confused, I am!

2021-08-09 Thread Paul Backus via Digitalmars-d-learn
On Monday, 9 August 2021 at 18:35:56 UTC, james.p.leblanc wrote: ```d T[] foo_temp(Complex!T[])(T x, T y){ auto r = [x, x]; auto i = [y, y]; auto z = [ Complex!T(x, y), Complex!T(x,y) ]; return z; } ``` void main(){ auto yd = foo_double(1.1, 2.2); writeln(yd); ... } But, no ... I a

Re: nested templates using Complex! with slices, ... confused, I am!

2021-08-09 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Aug 09, 2021 at 06:35:56PM +, james.p.leblanc via Digitalmars-d-learn wrote: [...] > > **T[] foo_temp(Complex!T[])(T x, T y){ > > auto r = [x, x]; > > auto i = [y, y]; > > auto z = [ Complex!T(x, y), Complex!T(x,y) ]; > > return z; > > }** Your syntax is wrong; the declaration

nested templates using Complex! with slices, ... confused, I am!

2021-08-09 Thread james.p.leblanc via Digitalmars-d-learn
Suppose "foo_double" should return a complex double slice, with double input args. Similarly "foo_float" should return a float slice, with float input args. I thought it should be easy to parameterize with a template taking a SINGLE argument, either a"double" or "float" as follows: import s

Re: How Add Local modules mymodule.d using DUB?

2021-08-09 Thread Marcone via Digitalmars-d-learn
On Monday, 9 August 2021 at 16:37:10 UTC, Steven Schveighoffer wrote: On 8/9/21 12:32 PM, Marcone wrote: My main program need import a local module called mymodule.d. How can I add this module using DUB? Thank you. You mean how to add a local project (that isn't on code.dlang.org)? `dub add

Re: How Add Local modules mymodule.d using DUB?

2021-08-09 Thread Marcone via Digitalmars-d-learn
On Monday, 9 August 2021 at 16:37:10 UTC, Steven Schveighoffer wrote: On 8/9/21 12:32 PM, Marcone wrote: My main program need import a local module called mymodule.d. How can I add this module using DUB? Thank you. You mean how to add a local project (that isn't on code.dlang.org)? `dub add

Re: How Add Local modules mymodule.d using DUB?

2021-08-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/9/21 12:32 PM, Marcone wrote: My main program need import a local module called mymodule.d. How can I add this module using DUB? Thank you. You mean how to add a local project (that isn't on code.dlang.org)? `dub add-local .` inside the project directory. I don't think you can add a file

How Add Local modules mymodule.d using DUB?

2021-08-09 Thread Marcone via Digitalmars-d-learn
My main program need import a local module called mymodule.d. How can I add this module using DUB? Thank you.

Re: How to divide by space keeping words with spaces inside quotes?

2021-08-09 Thread Marcone via Digitalmars-d-learn
Thank you very much! With your helps I created this function that works fine: // Function splitcommas() string[] splitcommas(string text) nothrow { try { return text.splitter!(Yes.keepSeparators)(regex("[^\\s\"']+|\"([^\"]*)\"|'([^']*)'")).array.map!(x => x.replace("\"", "

Re: input range with non copyable element

2021-08-09 Thread vit via Digitalmars-d-learn
On Monday, 9 August 2021 at 02:47:40 UTC, Mathias LANG wrote: On Sunday, 8 August 2021 at 18:36:02 UTC, vit wrote: Hello, is there reason why elements of input range must be copyable? By design, not that I can think of. But it is assumed all over the place, unfortunately. You can make your `f

How elegantly "funnel" all operator overloads or interest through a struct?

2021-08-09 Thread james.p.leblanc via Digitalmars-d-learn
I have a struct where I use a number of "invariant(){enforce( blah, blah ...);}" statements in the struct body to enforce certain conditions on a struct member. Since these "invariants" are only called when struct member functions are exercised, must I overload each individual operatio