On Friday, 14 January 2022 at 17:48:41 UTC, kyle wrote:
```d
void main()
{
import std.stdio;
Broke foo = Broke(10);
Broke bar = Broke(20);
writeln(foo + 15); //prints 25 as expected
writeln(foo + bar); //prints 20
}
```
I guess what you want to do is something like this:
On Friday, 14 January 2022 at 18:04:35 UTC, kyle wrote:
Thanks Adam. We need a repository of articles about stuff that
doesn't do what people expect.
I put this as a tip of the week in my late post:
http://dpldocs.info/this-week-in-d/Blog.Posted_2022_01_10.html#tip-of-the-week
My blog
On Friday, 14 January 2022 at 17:56:48 UTC, Adam D Ruppe wrote:
On Friday, 14 January 2022 at 17:48:41 UTC, kyle wrote:
[...]
alias works in term of compile-time names, not values. This
means the `this` value, being run time, gets discarded.
[...]
Thanks Adam. We need a repository of
On Friday, 14 January 2022 at 17:48:41 UTC, kyle wrote:
I'm trying to use ```alias``` in an operator overload to reduce
typing, but what gets aliased is not what I expect.
alias works in term of compile-time names, not values. This means
the `this` value, being run time, gets discarded.
I'm trying to use ```alias``` in an operator overload to reduce
typing, but what gets aliased is not what I expect. Tested in DMD
v2.098.1-dirty on Windows plus whatever versions of DMD, GDC, and
LDC I have installed on Linux. Thanks.
```
struct Broke
{
double num;
import std.traits
lias` to give a name to something that
does not already have one.
But wait, you might ask, if that's true, how can you alias a
lambda? It's an anonymous function; by definition, it doesn't
have a name!
alias increment = (int x) => x + 1;
The thing is...lambdas actually do have names.
On 9/28/20 6:46 PM, Ruby The Roobster wrote:
I thought alias could work like this with classes:
That would work with template parameters:
alias A = Foo!(3, "hello");
alias test = MyClass(3,"H",9.1); //Assume the constructor parameters for
MyClass are (int,string,double).
Can anybody fix
I thought alias could work like this with classes:
alias test = MyClass(3,"H",9.1); //Assume the constructor
parameters for MyClass are (int,string,double).
Can anybody fix this code?