On Wednesday, 1 May 2024 at 15:18:03 UTC, Steven Schveighoffer
wrote:
On Wednesday, 1 May 2024 at 01:09:33 UTC, Liam McGillivray
wrote:
This is presumably such a common task that I'm surprised it
isn't easy to find the answer by searching;
Is there a standard library function that removes all
On Wednesday, 1 May 2024 at 01:09:33 UTC, Liam McGillivray wrote:
This is presumably such a common task that I'm surprised it
isn't easy to find the answer by searching;
Is there a standard library function that removes all elements
from a dynamic array that matches an input argument
On Wednesday, 1 May 2024 at 01:09:33 UTC, Liam McGillivray wrote:
I get compiler errors when using it on other array types. I've
tried using it to replace occurrences of a certain object in an
array with [] in order to remove all occurrences, but it's not
allowed.
Can you post a code
On Wednesday, 1 May 2024 at 01:24:55 UTC, Lance Bachmeier wrote:
Does filter do what you need?
https://dlang.org/phobos/std_algorithm_iteration.html#.filter
It seems to do it with the following line:
```
allObjects = allObjects.filter!(element => element !is
this).array;
```
So I've found
On Wednesday, 1 May 2024 at 01:09:33 UTC, Liam McGillivray wrote:
This is presumably such a common task that I'm surprised it
isn't easy to find the answer by searching;
Is there a standard library function that removes all elements
from a dynamic array that matches an input argument
Member, Enum, m);");
}
};
```
Correction: The code shown above actually *does* work properly
without any deprecation warnings. I made a mistake with the enum
being set to the CTFE function I was previously using instead of
this template. This template actually works.
I posted here for visibili
Well, someone on the Discord server has been helping me attempt
this, but while I managed to get a solution that compiles without
errors, I still get the deprecation warning.
Here is what I ended up with:
```
template enumMixin(alias Enum) {
static foreach(m; __traits(allMembers, Enum))
I know that DStep generates CTFE functions to automatically make
aliases for enum members so that the can be used without the enum
name, as is done in C. DStep does it with a CTFE function, though
it should also be possible with a mixin template.
Here is my attempt so far, using a mixin
` that has the necessary members
instead of only accepting `typeB`. But this is only possible
if you are free to modify the definition of `someFunction`.
Is there a way I can replace "`TypeB`" in the function
parameters with another symbol, and then define that symbol to
acc
On Wednesday, 17 April 2024 at 03:13:46 UTC, Liam McGillivray
wrote:
Is there a way I can replace "`TypeB`" in the function
parameters with another symbol, and then define that symbol to
accept `TypeB` as an argument, but also accept `TypeA` which
would get converted to `Ty
`. But this is only possible if
you are free to modify the definition of `someFunction`.
Is there a way I can replace "`TypeB`" in the function parameters
with another symbol, and then define that symbol to accept
`TypeB` as an argument, but also accept `TypeA` which would get
converted to `Ty
On Wednesday, 17 April 2024 at 01:36:59 UTC, Liam McGillivray
wrote:
To better understand what I mean, take the following example,
where I have a function, and two structs.
```
struct typeA {
// Some member variables here
}
struct typeB {
// Some similar member variables here
I have two structs that serve roughly the same purpose, and I
would like one to be accepted when the other is declared as a
function parameter.
To better understand what I mean, take the following example,
where I have a function, and two structs.
```
struct typeA {
// Some member
On 15/04/2024 10:36 AM, Liam McGillivray wrote:
Well, it did work when I tried it (using a string variable, not a
literal of course). It displayed as it is supposed to. But from the
information I can find on the web it looks like strings are sometimes
but not |always| zero-terminated. Not a
used*. That is, does the
function just quickly use the string and never refers to it
again? Given that this is raylib, the source is pretty
readable, so you should be able to figure this out.
I suppose. But if it turns out that the string is used
continuously (as I assume to be the case with `InitWindow`
it is and
when it isn't (for string variables)?
So there are a few things to consider:
1. Is the string *transiently used*. That is, does the function
just quickly use the string and never refers to it again? Given
that this is raylib, the source is pretty readable, so you
should be able
On Friday, 12 April 2024 at 03:57:40 UTC, John Dougan wrote:
Not every day you get to blame a compiler bug.
D is uniquely: hacky, expressive and buggy.
Having more metaprograming then c++ without the raw man power
comes at a cost, in d you should distrust the spec and instead
see what the
. It appears to be deliberate and also afflicts var
declarations. Since 2014.
From my point of view, either it's still a bug and needs to be
written up in a best practices list with all the other long term
stuff you need to work around until it can be fixed (eg. "in
alias and var fun
strings as parameters instead of
`const(char)*`. For the `InitWindow` function shown above, the
overload should be defined like this:
```d
void InitWindow(int width, int height, ref string title) {
InitWindow(width, height, cast(const(char)*)title);
}
```
This is invalid, a string may
On Friday, 12 April 2024 at 03:57:40 UTC, John Dougan wrote:
What is the procedure for bug reporting? I'm looking at the
issues tracker and have no clue how to drive the search to see
if this is already there.
https://issues.dlang.org
While entering the bug title, it does a fuzzy search
);
```
```
bool function(int) nothrow @nogc
bool function(int) nothrow @nogc @safe
```
That surprises me. `nothrow` and `@nogc` go onto the type, but
not `@safe` if put before the declaration? I have no idea why.
All I can think of is that it is a bug.
`pragma(msg,...)` is very useful. Thanks.
My
On Tuesday, 9 April 2024 at 12:45:55 UTC, Richard (Rikki) Andrew
Cattermole wrote:
On 09/04/2024 12:48 PM, Liam McGillivray wrote:
I suppose this was a good new thing to learn, though I'm still
quite far from being able to construct a function from another
function using a template.
I
on the right hand side of the function,
not the left side.
Use the left side for attributes/type qualifiers that go on
the return type.
Just a word of warning, this explanation suggests putting
qualifiers on the left side would affect the return type, this
is not the case.
So in my example, what did
Interesting. Thank you to both of you.
On Wednesday, 10 April 2024 at 17:38:21 UTC, Steven Schveighoffer
wrote:
On Wednesday, 10 April 2024 at 11:34:06 UTC, Richard (Rikki)
Andrew Cattermole wrote:
Place your attributes on the right hand side of the function,
not the left side.
Use the left
terprets it as a constructor call without the explicit constructor call.
But it only works, because it's explicit that a variable is being declared,
and therefore it must be the case that you're constructing it when you use =
to give it a value.
On the other hand, when you're returning a value fr
unc() Nullable? It just wants to give you an int,
right? Making it a function returning an int fixes this.
Andy
Its an example
ing it a function returning an int fixes this.
Andy
that function is being used for both, and hence uses GC
(appending).
Are you sure that string appending was really the problem that
caused the "TypeInfo" build error? I forgot about this, but I
had already had a working CTFE function with string appending
before adding the new one
On Wednesday, 10 April 2024 at 11:34:06 UTC, Richard (Rikki)
Andrew Cattermole wrote:
Place your attributes on the right hand side of the function,
not the left side.
Use the left side for attributes/type qualifiers that go on the
return type.
Just a word of warning, this explanation
Place your attributes on the right hand side of the function, not the
left side.
Use the left side for attributes/type qualifiers that go on the return type.
```d
bool[7] stagesToProcess = false;
bool shouldDoInStages(int index) @nogc nothrow @safe
{
return stagesToProcess[index
On 10/04/2024 2:50 PM, Liam McGillivray wrote:
On Tuesday, 9 April 2024 at 23:50:36 UTC, Richard (Rikki) Andrew
Cattermole wrote:
The string mixin triggers CTFE, if ``EnumPrefixes`` wasn't templated,
that would cause codegen and hence error. If you called it in a
context that wasn't CTFE only,
Below is a example program that illustrates my issue.
When compiled at run.dlang I get:
```
onlineapp.d(18): Error: `@safe` function
`onlineapp.processSafely!(1, 4).processSafely` cannot call
`@system` function pointer `shouldDo`
onlineapp.d(28): Error: template instance
function with string appending.
It's in
[`source/raylib/package.d`](https://github.com/LiamM32/raylib-d/blob/49a8f2a2e4285fc85b9db54ae9a49cafe8b1a5ed/source/raylib/package.d) where `mixin(EnumPrefixes!Key("KeyboardKey", "KEY_"));` appears. The definition of `EnumPref
On 10/04/2024 11:21 AM, Liam McGillivray wrote:
On Sunday, 7 April 2024 at 08:59:55 UTC, Richard (Rikki) Andrew
Cattermole wrote:
Unfortunately runtime and CTFE are the same target in the compiler.
So that function is being used for both, and hence uses GC (appending).
Are you sure
On Sunday, 7 April 2024 at 08:59:55 UTC, Richard (Rikki) Andrew
Cattermole wrote:
Unfortunately runtime and CTFE are the same target in the
compiler.
So that function is being used for both, and hence uses GC
(appending).
Are you sure that string appending was really the problem
On 09/04/2024 12:48 PM, Liam McGillivray wrote:
On Tuesday, 9 April 2024 at 00:02:02 UTC, Richard (Rikki) Andrew
Cattermole wrote:
```d
enum Value = (a, b) {
return a + b;
}(1, 2);
```
This alone should be a CTFE only function.
But if we want template parameters, we'd need to wrap
On Sunday, 7 April 2024 at 06:46:39 UTC, Liam McGillivray wrote:
instantiated from here: `front!char`
Looks like autodecoding, try to comment `canFind`.
On Tuesday, 9 April 2024 at 00:02:02 UTC, Richard (Rikki) Andrew
Cattermole wrote:
```d
enum Value = (a, b) {
return a + b;
}(1, 2);
```
This alone should be a CTFE only function.
But if we want template parameters, we'd need to wrap it with
the template.
```d
template Value(int
; just the function I posted above was a major
achievement for me. I don't understand how I would use the code you gave
in place of the function I have written and posted above.
Let's break it down.
The expression that initializes the ``func`` variable, this is a
closure. The ``a`` and ``b
the enum a value, that'll be CTFE only, no runtime target.
Are you saying that this is a way to guarantee that the code is
compile-time only?
I still understand very little of this code. I'm not experienced
in D metaprogramming; just the function I posted above was a
major achievement for me
On 08/04/2024 10:45 AM, Liam McGillivray wrote:
On Sunday, 7 April 2024 at 08:59:55 UTC, Richard (Rikki) Andrew
Cattermole wrote:
Unfortunately runtime and CTFE are the same target in the compiler.
:-(
Will this ever be changed?
A tad unlikely, it would be a rather large change
On Sunday, 7 April 2024 at 08:59:55 UTC, Richard (Rikki) Andrew
Cattermole wrote:
Unfortunately runtime and CTFE are the same target in the
compiler.
:-(
Will this ever be changed?
```d
template Foo(Args) {
enum Foo = () {
return Args.init;
}();
}
```
Unfortunately runtime and CTFE are the same target in the compiler.
So that function is being used for both, and hence uses GC (appending).
```d
template Foo(Args) {
enum Foo = () {
return Args.init;
}();
}
```
Something like that should work instead.
I'm making a modification to a D binding for a C library. I made
a CTFE function which takes a function declaration with one or
more `const(char)*` or `char*` parameters and makes an overload
that accepts D strings. While this function is only used during
compile time, unfortunately, I have
On Friday, 2 February 2024 at 01:23:11 UTC, Steven Schveighoffer
wrote:
Are you thinking of this?
https://dlang.org/phobos/object.html#.imported
-Steve
Yes! Glad it's now part of D.
Thank you.
On Friday, 2 February 2024 at 00:29:51 UTC, Carl Sturtivant wrote:
Hello,
I seem to recall that there is surprising template to import a
module and get a type from it inside the declaration of the
type of a parameter to a function, so that the module need not
be imported outside
Hello,
I seem to recall that there is surprising template to import a
module and get a type from it inside the declaration of the type
of a parameter to a function, so that the module need not be
imported outside of the function definition. I think there was a
blog article some years ago
On Monday, 29 January 2024 at 19:24:51 UTC, Inkrementator wrote:
On Thursday, 25 January 2024 at 18:44:26 UTC, atzensepp wrote:
However this works:
```d
int delegate (int) td = (x) =>
compose!(f,g,g,f,g,g,f,g,g,f)(x);
```
While not a real function pointer, this might already fit y
On Thursday, 25 January 2024 at 18:44:26 UTC, atzensepp wrote:
However this works:
```d
int delegate (int) td = (x) =>
compose!(f,g,g,f,g,g,f,g,g,f)(x);
```
While not a real function pointer, this might already fit your
needs.
```d
alias td = compose!(f,g);
```
On Thursday, 25 January 2024 at 12:19:47 UTC, Paul Backus wrote:
On Thursday, 25 January 2024 at 08:25:02 UTC, atzensepp wrote:
```d
int function(int) t = compose!(f,g,g,f,g,g,f,g,g,f);
```
This leads to:
```
gdc lambda4.d
lambda4.d:28:25: error: template compose(E)(E a) has no value
int
On Thursday, 25 January 2024 at 08:25:02 UTC, atzensepp wrote:
```d
int function(int) t = compose!(f,g,g,f,g,g,f,g,g,f);
```
This leads to:
```
gdc lambda4.d
lambda4.d:28:25: error: template compose(E)(E a) has no value
int function(int) t = compose!(f,g,g,f,g,g,f,g,g,f);
```
Try using
Looks like the context is currently passed for nested functions,
not for nested classes.
a pointer to composed function.
```d
int main()
{
writeln(compose!(map!(to!(int)), split)("1 2 3").equal([1, 2,
3]));
writeln( compose!(f,g,g,f,g,g,f,g,g,f)(8));
int function(int) t = compose!(f,g,g,f,g,g,f,g,g,f);
writeln(t(3));
// auto cf = curry!f;
// auto cf1 = cf(1);
//
On Wednesday, 24 January 2024 at 21:30:23 UTC, user1234 wrote:
On Wednesday, 24 January 2024 at 21:12:20 UTC, atzensepp wrote:
[...]
what a bummer!
Have you tried
https://dlang.org/phobos/std_functional.html#compose ?
Well this violates the second requirement:
the composition itself
On Wednesday, 24 January 2024 at 21:12:20 UTC, atzensepp wrote:
[...]
what a bummer!
Have you tried
https://dlang.org/phobos/std_functional.html#compose ?
Some progress: compose function needs to know type but templates
help to create for different types.
```d
import std.stdio;
import std.container.array;
// Function composition:
int f(int x) { return x*2;} ;
int g(int x) { return x+2;} ;
double ff(double x) { return x*x;} ;
double gg(double
How is it possible to compose functions?
I came up with following solution that is not satisfactory
for two reasons:
1. the compose function should be argument agnostic
here it is explicitly coded for (int) -> (int)
2. the composition itself requires additional lam
On Thursday, 5 January 2023 at 13:47:24 UTC, Adam D Ruppe wrote:
On Thursday, 5 January 2023 at 13:27:23 UTC, Vijay Nayar wrote:
Why is this error only found when declaring a class in the
unittest?
A unittest is just a special function, it can run code and have
local variables.
classes
On Saturday, 20 January 2024 at 20:58:49 UTC, Richard (Rikki)
Andrew Cattermole wrote:
On 21/01/2024 9:55 AM, atzensepp wrote:
import std.stdio; // Overloads are resolved when the partially
applied function is called // with the remaining arguments.
struct S { static char fun(int i, string s
On 21/01/2024 9:55 AM, atzensepp wrote:
import std.stdio; // Overloads are resolved when the partially applied
function is called // with the remaining arguments. struct S { static
char fun(int i, string s) { return s[i]; } static int fun(int a, int b)
{ return a * b; } } void main() { alias
On Saturday, 20 January 2024 at 17:47:29 UTC, Richard (Rikki)
Andrew Cattermole wrote:
Not really any other way to do it, create context (i.e. struct,
or stack) and have a delegate point to both it and a patch
function.
It'll be how partial is implemented.
https://dlang.org/phobos
On Saturday, 20 January 2024 at 17:45:36 UTC, Christian Köstlin
wrote:
Would
https://dlang.org/library/std/functional/curry.html
help you?
kind regards,
Christian
Hello Christian,
thank for the link. I looks good however in my installation (gdc
8.4.0) it says:
```d
curry.d:1:8: error:
Not really any other way to do it, create context (i.e. struct, or
stack) and have a delegate point to both it and a patch function.
It'll be how partial is implemented.
https://dlang.org/phobos/std_functional.html#.partial
Would
https://dlang.org/library/std/functional/curry.html
help you?
kind regards,
Christian
Hello,
D-Language allows for anonymous functions.
Is there a way of elegant partial function application such as in
other (functional) languages?
A function "doemar" accepts a function with one parameter,
Another function g defined within mail accepts two parameters and
should
On Monday, 15 January 2024 at 23:06:00 UTC, Steven Schveighoffer
wrote:
As a workaround, you can alias the outer function in the struct:
```d
struct S
{
alias foo = S_foo;
}
```
This might be less than ideal, but at least it works.
It does! And it's good enough for me. Thanks a lot
On Monday, 15 January 2024 at 22:23:27 UTC, Bastiaan Veelo wrote:
On Monday, 15 January 2024 at 18:43:43 UTC, user1234 wrote:
The two calls are not equivalent.
so what is passed as alias need to be static too.
Thanks all. I thought a static member function just isn't able
to access
foo(alias len)()
[...]
The trouble is with the `static` here. A context pointer is
necessary in order to have access to the context of main() from
the body of this function; but `static` precludes this
possibility.
T
I dont agree, problem is S_foo that get automagically
monomorphized
On Monday, 15 January 2024 at 18:43:43 UTC, user1234 wrote:
The two calls are not equivalent.
so what is passed as alias need to be static too.
Thanks all. I thought a static member function just isn't able to
access the instance of the struct, but as I understand now it is
static all
On Monday, 15 January 2024 at 18:16:44 UTC, Bastiaan Veelo wrote:
[...]
It seems to me this should just work.
Thanks!
--Bastiaan.
The two calls are not equivalent. To be equivalent you need to
set `S_foo` static too, otherwise `S_Foo` is instanciated in
`main` scope, proof:
```d
import
s len)()
[...]
The trouble is with the `static` here. A context pointer is necessary
in order to have access to the context of main() from the body of this
function; but `static` precludes this possibility.
T
--
It is of the new things that men tire --- of fashions and proposals and
improvements and c
)()
{
writeln(len);
}
void main()
{
const five = 5;
S_foo!five; // Fine
S.foo!five; // Error
}
```
The error is
```
onlineapp.d(7): Error: `static` function
`onlineapp.main.foo!(5).foo` cannot access variable `five` in
frame of function `D main`
onlineapp.d(19):`five` declared here
; // Fine
S.foo!five; // Error
}
```
The error is
```
onlineapp.d(7): Error: `static` function
`onlineapp.main.foo!(5).foo` cannot access variable `five` in
frame of function `D main`
onlineapp.d(19):`five` declared here
onlineapp.d(21): Error: template instance
`onlineapp.main.foo!(5
ure added.
assert(XPtr.Fld1 == 3); // Shows new datastructure holds
original data item.
assert(XPtr.Fld2 == 4); // Shows new datastructure holds
original data item.
}
```
Are identical, except that, in the second demo, one variable name
in the mixin function
was changed to be the sam
On Thursday, 23 November 2023 at 20:13:59 UTC, BoQsc wrote:
Nothing wrong. It would be just a more concise compact way to
do the same.
Also I mostly wanted to know if something like that is already
possible in D language.
It's not a huge loss if it is not possible.
This is possible in Go:
On Thursday, 23 November 2023 at 20:00:31 UTC, H. S. Teoh wrote:
On Thu, Nov 23, 2023 at 07:22:22PM +, BoQsc via
Digitalmars-d-learn wrote:
Is it possible to declare empty pointer variable inside
function calls and pass its address to the function?
These are sometimes required while using
On Thu, Nov 23, 2023 at 07:22:22PM +, BoQsc via Digitalmars-d-learn wrote:
> Is it possible to declare empty pointer variable inside function calls
> and pass its address to the function?
>
> These are sometimes required while using Win32 - Windows Operating
> System API.
>
Is it possible to declare empty pointer variable inside function
calls and pass its address to the function?
These are sometimes required while using Win32 - Windows
Operating System API.
* Empty pointer variables are used by functions to return
information after the function is done.
My
On Saturday, 18 November 2023 at 07:47:19 UTC, BoQsc wrote:
`program("someProgramName").pipe("someOtherProgramName");`
Executes and pipes output to another program.
`program();` - Only executes the program.
Serious answer: have a function handle this, instead of the
semic
chain
this function!");`
A function that executes a program
For me syntactically it is important. One real world
application would be:
`program("someProgramName").pipe("someOtherProgramName");`
Executes and pipes output to another program.
`program();` - Only executes
chain
this function!");`
A function that executes a program
For me syntactically it is important. One real world
application would be:
`program("someProgramName").pipe("someOtherProgramName");`
Executes and pipes output to another program.
`program();` - Only executes t
Let's say we have a chain of functions.
```
a().b().c();
```
I would like to have a behaviour in `a()` that would check if
there is `b()` or `c()` chained to it.
If `a();`is not chained: do a `writeln("You forgot to chain this
function!");`
A function that executes a progr
can't take the address of
a template without instantiating it first. To make your
example work, replace `` with `!int`, like
this:
spawn(!int, biz);
All right. It seems I cannot pass on an object. So I store the
object in a global and access it from the callback function
passed
!int(123);" out of the main
function. Compiler complains about static this. Okay, then the
code outside the main function now looks this way:
class Biz(T) {
private T value;
this(T value) {
this.value = value;
}
}
static void addToBiz(T)(Biz!T biz)
{
// ...
}
or I found this in the Internet:
https://stackoverflow.com/questions/14395018/aliases-to-mutable-thread-local-data-not-allowed
But this change, did not help:
spawn(!int, cast(shared) biz);
Then I moved "Biz!int biz = new Biz!int(123);" out of the main
function. Compiler complains abo
On Wednesday, 8 November 2023 at 16:30:49 UTC, Bienlein wrote:
Hello,
I get the error "`addToBiz(T)(Biz!T biz)` is not an lvalue and
cannot be modified" when compiling the code below. Can't find a
way how to do it right. Am a D newbie and would appreciate some
help.
[...]
static void
Hello,
I get the error "`addToBiz(T)(Biz!T biz)` is not an lvalue and
cannot be modified" when compiling the code below. Can't find a
way how to do it right. Am a D newbie and would appreciate some
help.
Thank you, Bienlein
class Biz(T) {
private T value;
this(T value)
On Friday, 3 November 2023 at 15:11:31 UTC, Bogdan wrote:
Can anyone help me to understand what I am missing?
Your loop is likely dominated by sin() calls, And the rest of the
loop isn't complicated enough to outperform the compiler.
What you could do is use the intrinsics to implement a
On Friday, 3 November 2023 at 15:32:08 UTC, Sergey wrote:
On Friday, 3 November 2023 at 15:11:31 UTC, Bogdan wrote:
Hi everyone,
I was playing around with the intel-intrinsics library, trying
to improve the speed of a simple area function. I could not
see any performance improvements from
On Friday, 3 November 2023 at 15:11:31 UTC, Bogdan wrote:
Hi everyone,
I was playing around with the intel-intrinsics library, trying
to improve the speed of a simple area function. I could not see
any performance improvements from the non-SIMD implementation.
The SIMD version is a little
c.add(2);
c.writeln; // x + 2 +
// with constructor:
c = Calculate("x");
c.add(2);
c.writeln; // x + 2 +
}
```
There is a simple struct like the one above that is not related
to reality. There can be more than 2 function overloading in
it, but in our example there
On Friday, 3 November 2023 at 15:17:43 UTC, Imperatorn wrote:
On Friday, 3 November 2023 at 15:11:31 UTC, Bogdan wrote:
Hi everyone,
I was playing around with the intel-intrinsics library, trying
to improve the speed of a simple area function. I could not
see any performance improvements
On Friday, 3 November 2023 at 15:11:31 UTC, Bogdan wrote:
Hi everyone,
I was playing around with the intel-intrinsics library, trying
to improve the speed of a simple area function. I could not see
any performance improvements from the non-SIMD implementation.
The SIMD version is a little
Hi everyone,
I was playing around with the intel-intrinsics library, trying to
improve the speed of a simple area function. I could not see any
performance improvements from the non-SIMD implementation. The
SIMD version is a little bit slower even with LDC2 and --o3. Can
anyone help me
On Thursday, 2 November 2023 at 11:17:42 UTC, Salih Dincer wrote:
On Wednesday, 1 November 2023 at 20:04:52 UTC, Basile B. wrote:
Yes. D constructors are not named but the current
implementation adds a name that is `__ctor`, so add
```d
alias add = __ctor;
```
to you struct.
Yeah, it
On Wednesday, 1 November 2023 at 20:04:52 UTC, Basile B. wrote:
Yes. D constructors are not named but the current
implementation adds a name that is `__ctor`, so add
```d
alias add = __ctor;
```
to you struct.
Yeah, it works! Thanks...:)
SDB@79
On Tuesday, 31 October 2023 at 20:09:44 UTC, Salih Dincer wrote:
[...]
is it possible to do something like `alias add = this;`?
```d
struct Calculate
{
int memory;
string result;
auto toString() => result;
// alias add = this;
import std.string : format;
c = Calculate("x");
c.add(2);
c.writeln; // x + 2 +
}
```
There is a simple struct like the one above that is not related
to reality. There can be more than 2 function overloading in it,
but in our example there are only 2. Without implementing a
similar function again for each c
On Sunday, 1 October 2023 at 09:24:39 UTC, evilrat wrote:
On Sunday, 1 October 2023 at 08:22:48 UTC, dhs wrote:
Hi,
What's the meaning of the dot in the call to writeln() below?
```d
.writeln("Hello there!");
```
I haven't found this in the spec or anywhere else. This is
used very often
On Sunday, 1 October 2023 at 09:20:32 UTC, Anonymouse wrote:
On Sunday, 1 October 2023 at 08:22:48 UTC, dhs wrote:
Hi,
What's the meaning of the dot in the call to writeln() below?
```d
.writeln("Hello there!");
```
I haven't found this in the spec or anywhere else. This is
used very
1 - 100 of 5654 matches
Mail list logo