Re: Is this a bug?

2023-03-15 Thread Elfstone via Digitalmars-d-learn
On Thursday, 16 March 2023 at 04:31:11 UTC, Elfstone wrote: On Thursday, 16 March 2023 at 04:04:51 UTC, Elfstone wrote: On Thursday, 16 March 2023 at 03:44:19 UTC, Elfstone wrote: [...] Correction. With or without comments, mostly it doesn't compile, occasionally it does! I have no idea.

Re: Is this a bug?

2023-03-15 Thread Elfstone via Digitalmars-d-learn
On Thursday, 16 March 2023 at 04:04:51 UTC, Elfstone wrote: On Thursday, 16 March 2023 at 03:44:19 UTC, Elfstone wrote: On Thursday, 16 March 2023 at 03:40:04 UTC, Elfstone wrote: [...] Oops, the above code compiles, because I added comments!!! Now this really doesn't compile: ```D struct

Re: Is this a bug?

2023-03-15 Thread Elfstone via Digitalmars-d-learn
On Thursday, 16 March 2023 at 03:44:19 UTC, Elfstone wrote: On Thursday, 16 March 2023 at 03:40:04 UTC, Elfstone wrote: [...] Oops, the above code compiles, because I added comments!!! Now this really doesn't compile: ```D struct Matrix(S, size_t M, size_t N) { } alias Vec3(S) = Matrix!(S,

Is this a bug?

2023-03-15 Thread Elfstone via Digitalmars-d-learn
```D struct Matrix(S, size_t M, size_t N) { } alias Vec3(S) = Matrix!(S, 3, 1); void main() { import std.stdio; writeln(is(Vec3!float == Matrix!(S, 3, 1), S)); // `alias` `S` is defined here writeln(is(Matrix!(float, 3, 1) == Matrix!(S, 3, 1), S)); // Error: declaration `S` is

Re: Is this a bug?

2023-03-15 Thread Elfstone via Digitalmars-d-learn
On Thursday, 16 March 2023 at 03:40:04 UTC, Elfstone wrote: ```D struct Matrix(S, size_t M, size_t N) { } alias Vec3(S) = Matrix!(S, 3, 1); void main() { import std.stdio; writeln(is(Vec3!float == Matrix!(S, 3, 1), S)); // `alias` `S` is defined here writeln(is(Matrix!(float, 3,

Re: Better way to compromise on the lack of template alias resolution stuff?

2023-03-15 Thread Elfstone via Digitalmars-d-learn
On Wednesday, 15 March 2023 at 19:22:32 UTC, Paul Backus wrote: On Tuesday, 14 March 2023 at 10:19:24 UTC, Elfstone wrote: [...] Currently the best workaround for this is to define `Vector` as a `struct` with `alias this` instead of as an `alias`: ```d struct Matrix(S, size_t M, size_t N)

Re: Better way to compromise on the lack of template alias resolution stuff?

2023-03-15 Thread Elfstone via Digitalmars-d-learn
On Tuesday, 14 March 2023 at 17:57:38 UTC, ionkare wrote: On Tuesday, 14 March 2023 at 10:19:24 UTC, Elfstone wrote: ```D struct Matrix(S, size_t M, size_t N) { } alias Vector(S, size_t N) = Matrix!(S, N, 1); enum isVector(V) = is(V == Vector!(S, N), S, size_t N); // it doesn't work enum

Better way to compromise on the lack of template alias resolution stuff?

2023-03-14 Thread Elfstone via Digitalmars-d-learn
```D struct Matrix(S, size_t M, size_t N) { } alias Vector(S, size_t N) = Matrix!(S, N, 1); enum isVector(V) = is(V == Vector!(S, N), S, size_t N); // it doesn't work enum isVectorCorrect(V) = is(V == Matrix!(U, N, 1), U, size_t N); // the "correct" way and how much I like to REPEAT myself!

Re: Linking phobos64.lib errors

2023-03-01 Thread Elfstone via Digitalmars-d-learn
On Wednesday, 1 March 2023 at 07:15:36 UTC, Elfstone wrote: https://forum.dlang.org/post/edwmddiqcsnwpliyo...@forum.dlang.org On Wednesday, 3 September 2014 at 09:13:52 UTC, Szymon Gatner wrote: On Wednesday, 3 September 2014 at 08:47:35 UTC, Rikki Cattermole wrote: [...] Hey, for some

Linking phobos64.lib errors

2023-02-28 Thread Elfstone via Digitalmars-d-learn
https://forum.dlang.org/post/edwmddiqcsnwpliyo...@forum.dlang.org On Wednesday, 3 September 2014 at 09:13:52 UTC, Szymon Gatner wrote: On Wednesday, 3 September 2014 at 08:47:35 UTC, Rikki Cattermole wrote: On 3/09/2014 7:22 p.m., Szymon Gatner wrote: [...] My gut feeling looking at that,

Re: Template alias parameter: error: need 'this' for ...

2023-02-24 Thread Elfstone via Digitalmars-d-learn
On Friday, 24 February 2023 at 15:28:18 UTC, Steven Schveighoffer wrote: On 2/24/23 7:00 AM, Elfstone wrote: Seems like the same bug is still there after ten years. `static` should not affect module-level functions, but also, this code should work without `static`. Reported, not sure if

Template alias parameter: error: need 'this' for ...

2023-02-24 Thread Elfstone via Digitalmars-d-learn
https://forum.dlang.org/post/imnannjdgtjnlzevh...@forum.dlang.org On Saturday, 24 August 2013 at 11:47:43 UTC, Matej Nanut wrote: On Friday, 23 August 2013 at 22:54:33 UTC, Jonathan M Davis wrote: Because without static it's a member variable, which means that you have to have a constructed

Re: Template + alias + basic type depends on another parameter = broken?

2023-02-23 Thread Elfstone via Digitalmars-d-learn
On Wednesday, 22 February 2023 at 20:20:46 UTC, Dark Hole wrote: I'm trying to rewrite really old D code. There was fragment like that: ```d template Foo(T, T[] Array) { // ... } // ... Bar[] arr; Foo!(Bar, arr); ``` This gives error `can't read arr in compile time`. Small changes: ```d

Re: How to get only the field name from an alias?

2023-02-22 Thread Elfstone via Digitalmars-d-learn
On Tuesday, 21 February 2023 at 12:32:51 UTC, Adam D Ruppe wrote: On Tuesday, 21 February 2023 at 02:41:34 UTC, Elfstone wrote: apparently F.stringof You almost never want to use .stringof, instead try __traits(identifier, F) and see what it gives you. Alternatively, loop over

Re: How to get only the field name from an alias?

2023-02-20 Thread Elfstone via Digitalmars-d-learn
On Tuesday, 21 February 2023 at 03:13:38 UTC, ryuukk_ wrote: I'm not sure what the solution is for your specific question, but there is some alternative way you could do: (no longer need function on your struct) [...] This is super neat, but the order of the fields will have to be frozen,

How to get only the field name from an alias?

2023-02-20 Thread Elfstone via Digitalmars-d-learn
I'm experimenting on a serializer design. The idea includes a shorthand for processing a field and its attributes with an alias. But I'm not sure whether I can gather enough information from it, such as the name of the field. apparently F.stringof stands for "this.\" in this context. So how

Re: ImportC "no include path set"

2023-02-08 Thread Elfstone via Digitalmars-d-learn
On Wednesday, 8 February 2023 at 14:08:47 UTC, bachmeier wrote: On Wednesday, 8 February 2023 at 06:49:06 UTC, Elfstone wrote: I believe all three versions (2017,2019,2022) of my VS are up to date, and I have working C/C++ projects on them. But you encouraged me to give a few more tries, and I

Re: ImportC "no include path set"

2023-02-07 Thread Elfstone via Digitalmars-d-learn
On Wednesday, 8 February 2023 at 04:14:21 UTC, ryuukk_ wrote: On Tuesday, 7 February 2023 at 14:01:00 UTC, Elfstone wrote: On Tuesday, 7 February 2023 at 13:10:44 UTC, ryuukk_ wrote: On Tuesday, 7 February 2023 at 06:25:59 UTC, Elfstone wrote: On Monday, 6 February 2023 at 14:35:53 UTC,

Re: ImportC "no include path set"

2023-02-07 Thread Elfstone via Digitalmars-d-learn
On Tuesday, 7 February 2023 at 13:10:44 UTC, ryuukk_ wrote: On Tuesday, 7 February 2023 at 06:25:59 UTC, Elfstone wrote: On Monday, 6 February 2023 at 14:35:53 UTC, bachmeier wrote: [...] Thanks, it worked, but I still get the link error. I wasn't expecting to configure include paths and

Re: ImportC "no include path set"

2023-02-06 Thread Elfstone via Digitalmars-d-learn
On Monday, 6 February 2023 at 14:35:53 UTC, bachmeier wrote: On Monday, 6 February 2023 at 06:55:02 UTC, Elfstone wrote: So how am I supposed to set the include path? https://dlang.org/spec/importc.html#preprocessor The -Ppreprocessorflag switch passes preprocessorflag to the preprocessor.

ImportC "no include path set"

2023-02-05 Thread Elfstone via Digitalmars-d-learn
I'm trying out ImportC, but I can't get even the "Quick Example" running. > dmd -v .\source\foobar.c predefs DigitalMars LittleEndian D_Version2 all Windows Win32 CRuntime_Microsoft CppRuntime_Microsoft D_InlineAsm D_InlineAsm_X86 X86 assert D_PreConditions D_PostConditions

Re: Actual lifetime of static array slices?

2022-11-14 Thread Elfstone via Digitalmars-d-learn
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.

Re: Actual lifetime of static array slices?

2022-11-14 Thread Elfstone via Digitalmars-d-learn
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

Re: Actual lifetime of static array slices?

2022-11-14 Thread Elfstone via Digitalmars-d-learn
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,

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-03 Thread Elfstone via Digitalmars-d-learn
On Monday, 2 May 2022 at 16:29:05 UTC, Loara wrote: On Sunday, 1 May 2022 at 03:57:12 UTC, Elfstone wrote: [...] Template deduction for aliased function parameter is a very tricky argument and it's not so simple to handle in certain cases. Consider for example this code: ```d template

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-01 Thread Elfstone via Digitalmars-d-learn
On Sunday, 1 May 2022 at 14:14:59 UTC, Mike Parker wrote: On Sunday, 1 May 2022 at 12:39:08 UTC, Elfstone wrote: Great, I'm using the constraint, until it's fixed. Will it be fixed though? The DIP that Tejas linked is from 2020!!! The DIP was postponed. I can contact the author to see if he

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-01 Thread Elfstone via Digitalmars-d-learn
On Sunday, 1 May 2022 at 11:37:28 UTC, JG wrote: On Sunday, 1 May 2022 at 11:34:49 UTC, JG wrote: [...] The static assert isn't needed. ```d enum isVector(V) = is(V==MatrixImpl!(S,1,N),S,size_t N); @nogc auto dot1(V)(in V lhs, in V rhs) if(isVector!V) { static

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-01 Thread Elfstone via Digitalmars-d-learn
On Sunday, 1 May 2022 at 06:42:26 UTC, Tejas wrote: On Sunday, 1 May 2022 at 03:57:12 UTC, Elfstone wrote: module test; struct MatrixImpl(S, size_t M, size_t N) { } [...] AFAICT, I'm afraid you'll have to stick to `dot2`  This DIP I believe does what you want but... It

Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-04-30 Thread Elfstone via Digitalmars-d-learn
module test; struct MatrixImpl(S, size_t M, size_t N) { } template Vector(S, size_t N) { alias Vector = MatrixImpl!(S, 1, N); } @nogc S dot1(S, size_t N)(in Vector!(S, N) lhs, in Vector!(S, N) rhs) { return 0; } @nogc S

Re: Is @live attribute working yet?

2022-04-24 Thread elfstone via Digitalmars-d-learn
On Sunday, 24 April 2022 at 11:36:29 UTC, Paolo Invernizzi wrote: On Sunday, 24 April 2022 at 09:31:40 UTC, elfstone wrote: [...] You need to use the flag `-preview=dip1021` test.d(8,30): Error: variable `test.test.p` assigning to Owner without disposing of owned value Weird, it's

Re: Is @live attribute working yet?

2022-04-24 Thread elfstone via Digitalmars-d-learn
On Sunday, 24 April 2022 at 11:07:43 UTC, Tejas wrote: On Sunday, 24 April 2022 at 09:31:40 UTC, elfstone wrote: Dub(DMD 2.099.1) builds and runs the following code without a warning. import std.stdio; import core.stdc.stdlib; @live void test() { int* p =

Is @live attribute working yet?

2022-04-24 Thread elfstone via Digitalmars-d-learn
Dub(DMD 2.099.1) builds and runs the following code without a warning. import std.stdio; import core.stdc.stdlib; @live void test() { int* p = cast(int*) malloc(32); p = cast(int*) malloc(32); free(p); } void main() { test();

Re: Do I have to pass parameters with ref explicitly?

2022-04-17 Thread Elfstone via Digitalmars-d-learn
Thanks Ali. That's a lot of information. I'm learning D by rewriting my hobbyist project. I guess I can worry about optimization later. On Sunday, 17 April 2022 at 08:45:11 UTC, Ali Çehreli wrote: - Somewhat related, unlike C++, D does not allow binding rvalues to 'const ref'. (This point is

Re: Do I have to pass parameters with ref explicitly?

2022-04-16 Thread Elfstone via Digitalmars-d-learn
On Sunday, 17 April 2022 at 04:00:19 UTC, max haughton wrote: On Sunday, 17 April 2022 at 03:00:28 UTC, Elfstone wrote: I'm reading some d-sources, and it looks like they pass big structs by value. Such as: Matrix4x4f opBinary(string op)(Matrix4x4f rhs) { ... } I came from a C++

Do I have to pass parameters with ref explicitly?

2022-04-16 Thread Elfstone via Digitalmars-d-learn
I'm reading some d-sources, and it looks like they pass big structs by value. Such as: Matrix4x4f opBinary(string op)(Matrix4x4f rhs) { ... } I came from a C++ background, and I would have written: Matrix4x4f opBinary(string op)(const ref Matrix4x4f rhs) { ... } I haven't found

Re: Template name undefined when import from "library" target.

2022-04-16 Thread Elfstone via Digitalmars-d-learn
On Saturday, 16 April 2022 at 11:45:38 UTC, Elfstone wrote: I'm building my first program with dub. It appears I can import and use a struct from a "library". But the template struct is undefined unless I change the target type to "sourceLibrary". The sources are like this: What am I

Template name undefined when import from "library" target.

2022-04-16 Thread Elfstone via Digitalmars-d-learn
I'm building my first program with dub. It appears I can import and use a struct from a "library". But the template struct is undefined unless I change the target type to "sourceLibrary". The sources are like this: // library // shapes.d module core.shapes;