On 08.12.21 03:05, Andrey Zherikov wrote:
On Tuesday, 7 December 2021 at 18:50:04 UTC, Ali Çehreli wrote:
I don't know whether the workaround works with your program but that
delegate is the equivalent of the following struct (the struct should
be faster because there is no dynamic context
On Wednesday, 8 December 2021 at 07:55:55 UTC, Timon Gehr wrote:
On 08.12.21 03:05, Andrey Zherikov wrote:
On Tuesday, 7 December 2021 at 18:50:04 UTC, Ali Çehreli wrote:
I don't know whether the workaround works with your program
but that delegate is the equivalent of the following struct
On Wednesday, 8 December 2021 at 17:44:47 UTC, Adam D Ruppe wrote:
On Wednesday, 8 December 2021 at 17:19:32 UTC, Ben Jones wrote:
Gotcha, thanks. I tried using `S.field` before and that didn't
work, `__traits(child)` was the key.
Since I reuse the field a few times I tried to alias the
On Wednesday, 8 December 2021 at 18:07:32 UTC, Ben Jones wrote:
Since I reuse the field a few times I tried to alias the result:
`alias theProp = __traits(child, s, field);`
yeah won't work since the alias again drops the `this`, this is
the same thing as the template param.
You could make
On Wednesday, 8 December 2021 at 18:23:25 UTC, Adam D Ruppe wrote:
On Wednesday, 8 December 2021 at 18:07:32 UTC, Ben Jones wrote:
I went with the mixin approach, which seems to work fine except
that I couldn't declare the mixin inside a function, so the
definition is pretty far away from
On Wednesday, 8 December 2021 at 11:23:45 UTC, BoQsc wrote:
The string example to loop/iterate:
foreach(ch; a) {
}
does the individual chars of the string you can also
foreach(dchar ch; a) {
}
to decode the utf 8
On Wednesday, 8 December 2021 at 11:35:39 UTC, Biotronic wrote:
On Wednesday, 8 December 2021 at 11:23:45 UTC, BoQsc wrote:
Let's say I want to skip characters and build a new string.
The string example to loop/iterate:
```
import std.stdio;
void main()
{
string a="abc;def;ab";
}
```
Let's say I want to skip characters and build a new string.
The string example to loop/iterate:
```
import std.stdio;
void main()
{
string a="abc;def;ab";
}
```
The character I want to skip: `;`
Expected result:
```
abcdefab
```
On Wednesday, 8 December 2021 at 08:07:59 UTC, Petar Kirov
[ZombineDev] wrote:
```d
interface ICallable
{
void opCall() const;
}
alias Action = void delegate();
struct A
{
Action[] dg;
}
```
At this point why not just call a spade a spade and store an
array of ICallables directly?
On Wednesday, 8 December 2021 at 12:49:39 UTC, Adam D Ruppe wrote:
On Wednesday, 8 December 2021 at 11:23:45 UTC, BoQsc wrote:
The string example to loop/iterate:
foreach(ch; a) {
}
does the individual chars of the string you can also
foreach(dchar ch; a) {
}
to decode the utf 8
Thanks
On Wednesday, 8 December 2021 at 11:23:45 UTC, BoQsc wrote:
Let's say I want to skip characters and build a new string.
The string example to loop/iterate:
```
import std.stdio;
void main()
{
string a="abc;def;ab";
}
```
The character I want to skip: `;`
Expected result:
```
abcdefab
On Wednesday, 8 December 2021 at 14:16:16 UTC, bauss wrote:
On Wednesday, 8 December 2021 at 11:23:45 UTC, BoQsc wrote:
Let's say I want to skip characters and build a new string.
The string example to loop/iterate:
```
import std.stdio;
void main()
{
string a="abc;def;ab";
}
```
The
On Wednesday, 8 December 2021 at 11:23:45 UTC, BoQsc wrote:
Let's say I want to skip characters and build a new string.
The string example to loop/iterate:
```
import std.stdio;
void main()
{
string a="abc;def;ab";
}
```
The character I want to skip: `;`
Expected result:
```
abcdefab
On 12/8/21 9:07 AM, Petar Kirov [ZombineDev] wrote:
On Wednesday, 8 December 2021 at 07:55:55 UTC, Timon Gehr wrote:
On 08.12.21 03:05, Andrey Zherikov wrote:
On Tuesday, 7 December 2021 at 18:50:04 UTC, Ali Çehreli wrote:
I don't know whether the workaround works with your program but that
On Wed, Dec 08, 2021 at 05:19:32PM +, Ben Jones via Digitalmars-d-learn
wrote:
> I'm trying to use a property member of a struct as a template alias
> parameter and I don't really understand how to fix the error message
> I'm seeing (I also tried the simpler case of a plain struct member,
>
On Wednesday, 8 December 2021 at 17:29:19 UTC, H. S. Teoh wrote:
On Wed, Dec 08, 2021 at 05:19:32PM +, Ben Jones via
Digitalmars-d-learn wrote:
I'm trying to use a property member of a struct as a template
alias parameter and I don't really understand how to fix the
error message I'm
I'm trying to use a property member of a struct as a template
alias parameter and I don't really understand how to fix the
error message I'm seeing (I also tried the simpler case of a
plain struct member, and that didn't work either). Is what I'm
trying to do possible? It seems like maybe
On Wednesday, 8 December 2021 at 17:19:32 UTC, Ben Jones wrote:
I considered just having a `ref int` parameter, but I didn't
think that would work if I was actually calling a property
function, rather than just modifying a struct member.
I also tried to use a template mixin, but couldn't
On Wed, Dec 08, 2021 at 05:21:49PM +, Ben Jones via Digitalmars-d-learn
wrote:
[...]
> I considered just having a `ref int` parameter, but I didn't think
> that would work if I was actually calling a property function, rather
> than just modifying a struct member.
[...]
Why not pass the
On Wednesday, 8 December 2021 at 17:19:32 UTC, Ben Jones wrote:
It seems like maybe I'd have to pass s as a runtime parameter
to get it to work?
yes, you do. the alias param passes the abstract idea of the
variable instead of the variable:
void main(){
S s;
func!(s.a)();
See, you
On Wednesday, 8 December 2021 at 22:35:35 UTC, Stanislav Blinov
wrote:
You're passing a literal. Try passing a runtime value (e.g. a
command line argument). Also, -O2 -release :) Uless, of course,
your goal is to look at debug code.
but this will change nothing.
the compilation cost of
On Wednesday, 8 December 2021 at 17:05:49 UTC, Timon Gehr wrote:
On 12/8/21 9:07 AM, Petar Kirov [ZombineDev] wrote:
[...]
Nice, so the error message is lying.
Closure support deserves way more love in the compiler. I'm quite
surprised that that hack worked, given that various very similar
Hi all,
Is this not a contradiction? : and 3.1415 aren't string:
```d
void foo(string...)(string args) {
foreach(ref str; args) {
str.writeln('\t', typeof(str).stringof);
}
}
foo("Pi", "number", ':', 3.1415); /*
Pi string
number string
: char
3,1415 double
On Wednesday, 8 December 2021 at 23:47:07 UTC, Adam Ruppe wrote:
On Wednesday, 8 December 2021 at 23:43:48 UTC, Salih Dincer
wrote:
I think you meant to say
void foo(string[] args...) {}
Not exactly...
```d
alias str = immutable(char)[];
void foo(str...)(str args) {
foreach(ref a; args)
On Wednesday, 8 December 2021 at 12:17:42 UTC, Stanislav Blinov
wrote:
On Wednesday, 8 December 2021 at 08:07:59 UTC, Petar Kirov
[ZombineDev] wrote:
```d
interface ICallable
{
void opCall() const;
}
alias Action = void delegate();
struct A
{
Action[] dg;
}
```
At this point why
On Wednesday, 8 December 2021 at 14:27:22 UTC, BoQsc wrote:
On Wednesday, 8 December 2021 at 14:16:16 UTC, bauss wrote:
On Wednesday, 8 December 2021 at 11:23:45 UTC, BoQsc wrote:
Let's say I want to skip characters and build a new string.
The string example to loop/iterate:
```
import
On Wednesday, 8 December 2021 at 22:18:23 UTC, forkit wrote:
It's also worth noting the differences in compiler output, as
well as the time taken to compile, these two approaches:
(1)
string str = "abc;def;ab".filter!(c => c != ';').to!string;
(2)
string str = "abc;def;ab".replace(";", "");
On Wednesday, 8 December 2021 at 22:55:02 UTC, forkit wrote:
On Wednesday, 8 December 2021 at 22:35:35 UTC, Stanislav Blinov
wrote:
You're passing a literal. Try passing a runtime value (e.g. a
command line argument). Also, -O2 -release :) Uless, of
course, your goal is to look at debug
On Wednesday, 8 December 2021 at 23:43:48 UTC, Salih Dincer wrote:
Is this not a contradiction? : and 3.1415 aren't string:
```d
void foo(string...)(string args) {
`string...` there is a user-defined identifier representing a mix
of types.
string isn't special, yo can declare your own
On Wednesday, 8 December 2021 at 11:23:45 UTC, BoQsc wrote:
Let's say I want to skip characters and build a new string.
The string example to loop/iterate:
```
import std.stdio;
void main()
{
string a="abc;def;ab";
}
```
The character I want to skip: `;`
Expected result:
```
abcdefab
On Wednesday, 8 December 2021 at 17:05:49 UTC, Timon Gehr wrote:
```d
import std.stdio, std.traits, core.lifetime;
auto partiallyApply(alias fun,C...)(C context){
return class(move(context)){
C context;
this(C context) { foreach(i,ref c;this.context)
c=move(context[i]); }
On Monday, 6 December 2021 at 20:31:47 UTC, Jan wrote:
So am I missing something, or did the compiler somehow forget
about the const-ness?
Sounds like a bug to me, eg this one:
https://issues.dlang.org/show_bug.cgi?id=20685
32 matches
Mail list logo