Re: Fix template parameter

2022-08-10 Thread Nick Treleaven via Digitalmars-d-learn
On Wednesday, 10 August 2022 at 06:15:39 UTC, Dom Disc wrote: Ok, then I consider this is a bug in Phobos that should be corrected. All instances of ```D foo(T : fixedType)(T x) { } ``` should be replaced by ```D foo(fixedType x) { } ``` Perhaps, but not necessarily. The body of foo could d

Re: Fix template parameter

2022-08-09 Thread Dom Disc via Digitalmars-d-learn
On Tuesday, 9 August 2022 at 22:58:16 UTC, Paul Backus wrote: On Tuesday, 9 August 2022 at 22:36:23 UTC, Dom Disc wrote: On Tuesday, 9 August 2022 at 22:32:23 UTC, Dom Disc wrote: On Tuesday, 9 August 2022 at 21:16:22 UTC, Paul Backus wrote: Yes, this syntax allows anything that implicitly conv

Re: Fix template parameter

2022-08-09 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 9 August 2022 at 22:36:23 UTC, Dom Disc wrote: On Tuesday, 9 August 2022 at 22:32:23 UTC, Dom Disc wrote: On Tuesday, 9 August 2022 at 21:16:22 UTC, Paul Backus wrote: Yes, this syntax allows anything that implicitly converts to `BigInt`; Oh, or do you mean I will get two differen

Re: Fix template parameter

2022-08-09 Thread Dom Disc via Digitalmars-d-learn
On Tuesday, 9 August 2022 at 22:32:23 UTC, Dom Disc wrote: On Tuesday, 9 August 2022 at 21:16:22 UTC, Paul Backus wrote: Yes, this syntax allows anything that implicitly converts to `BigInt`; Oh, or do you mean I will get two different instances of the template, if I call it with two differen

Re: Fix template parameter

2022-08-09 Thread Dom Disc via Digitalmars-d-learn
On Tuesday, 9 August 2022 at 21:16:22 UTC, Paul Backus wrote: Yes, this syntax allows anything that implicitly converts to `BigInt`; for example: ```d import std.bigint; void fun(T : BigInt)(T t) { pragma(msg, "Instantiated with T = `" ~ T.stringof ~ "`"); } struct S { BigInt n; a

Re: Fix template parameter

2022-08-09 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 9 August 2022 at 21:08:52 UTC, Meta wrote: (it may also include anything that is a subtype of BigInt... I've received different answers on what exactly `(T: SomeType)` means in this context). Yes, this syntax allows anything that implicitly converts to `BigInt`; for example: ```

Re: Fix template parameter

2022-08-09 Thread Meta via Digitalmars-d-learn
On Monday, 8 August 2022 at 12:02:02 UTC, Dom Disc wrote: Hello. I found in the documentation functions declared like this: ```D pure @nogc @safe BigInt opAssign(T : BigInt)(T x); ``` This is a template function, even if T is constrained to always be BigInt (it may also include anything that

Re: Fix template parameter

2022-08-09 Thread pascal111 via Digitalmars-d-learn
On Monday, 8 August 2022 at 14:48:27 UTC, Dom Disc wrote: On Monday, 8 August 2022 at 12:46:48 UTC, bauss wrote: On Monday, 8 August 2022 at 12:02:02 UTC, Dom Disc wrote: ```D pure @nogc @safe BigInt opAssign(T : BigInt)(T x); ``` This will only be included in the object file if used. ```D

Re: Fix template parameter

2022-08-08 Thread Dom Disc via Digitalmars-d-learn
On Monday, 8 August 2022 at 12:46:48 UTC, bauss wrote: On Monday, 8 August 2022 at 12:02:02 UTC, Dom Disc wrote: ```D pure @nogc @safe BigInt opAssign(T : BigInt)(T x); ``` This will only be included in the object file if used. ```D pure @nogc @safe BigInt opAssign(BigInt x); ``` This wil

Re: Fix template parameter

2022-08-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/8/22 8:02 AM, Dom Disc wrote: Hello. I found in the documentation functions declared like this: ```D pure @nogc @safe BigInt opAssign(T : BigInt)(T x); ``` What is the difference to declaring it like: ```D pure @nogc @safe BigInt opAssign(BigInt x); ``` To me the first declaration seems

Re: Fix template parameter

2022-08-08 Thread bauss via Digitalmars-d-learn
On Monday, 8 August 2022 at 12:02:02 UTC, Dom Disc wrote: ```D pure @nogc @safe BigInt opAssign(T : BigInt)(T x); ``` This will only be included in the object file if used. What is the difference to declaring it like: ```D pure @nogc @safe BigInt opAssign(BigInt x); ``` This will always

Fix template parameter

2022-08-08 Thread Dom Disc via Digitalmars-d-learn
Hello. I found in the documentation functions declared like this: ```D pure @nogc @safe BigInt opAssign(T : BigInt)(T x); ``` What is the difference to declaring it like: ```D pure @nogc @safe BigInt opAssign(BigInt x); ``` To me the first declaration seems to be unnecessarily bloated, so I a