On Tuesday, 14 December 2021 at 20:58:21 UTC, Adam D Ruppe wrote:
nice. You might want to look at my terminal.d
(arsd-official:terminal on dub) too which has pretty
comprehensive functionality for tons of things. Prolly more
than you need looking at your interface tho but it includes the
On Tuesday, 14 December 2021 at 17:27:13 UTC, Stanislav Blinov
wrote:
Simple. Don't take a `ref`. Just take a `Console`. Classes in D
are reference types, you're not making a copy as you would in
C++ if you were to write `updateFoodToken(Console c)`.
Ah, ok, Reference types! That's great.
On Tuesday, 14 December 2021 at 16:21:03 UTC, Steven
Schveighoffer wrote:
On 12/14/21 11:19 AM, Steven Schveighoffer wrote:
Er... scratch that, this isn't construction, it should use
opAssign. Again, probably because memcpy+postblit is used by
the runtime.
If not reported, it should be.
On Tuesday, 14 December 2021 at 15:14:40 UTC, Steven
Schveighoffer wrote:
On 12/14/21 12:04 AM, Tejas wrote:
Is there anything wrong with the answer I posted?
Can you please tell me if there's anything dissatisfactory
about it? I feel like it does everything the OP wants.
Also, am I wrong
On Tuesday, 14 December 2021 at 13:25:04 UTC, apz28 wrote:
On Tuesday, 14 December 2021 at 05:04:46 UTC, Tejas wrote:
Is there anything wrong with the answer I posted?
Can you please tell me if there's anything dissatisfactory
about it? I feel like it does everything the OP wants.
Also, am
On Tuesday, 14 December 2021 at 17:20:18 UTC, chopchop wrote:
I am using the "ref" here (I put tinyurl to avoid
over-referencing the post instead of the github page itself):
https://tinyurl.com/bdddkmub
yeah D classes are automatically ref unlike c++ so you don't need
the second level of it
On Tuesday, 14 December 2021 at 14:40:00 UTC, RazvanN wrote:
On Sunday, 12 December 2021 at 11:57:43 UTC, vit wrote:
Hello, why does this code fail to compile?
```d
struct Foo(T){
this(Rhs, this This)(scope Rhs rhs){
}
this(ref scope typeof(this) rhs){
}
}
struct Bar{
On Tuesday, 14 December 2021 at 17:20:18 UTC, chopchop wrote:
I am using the "ref" here (I put tinyurl to avoid
over-referencing the post instead of the github page itself):
https://tinyurl.com/bdddkmub
I would like to be able to pass any kind of console to
updateFoodToken ( Console c ), ie
On Monday, 13 December 2021 at 22:30:59 UTC, Adam D Ruppe wrote:
On Monday, 13 December 2021 at 22:06:45 UTC, chopchop wrote:
If I remove the ref, it works as expected, that is to say I
can give a derived class as parameter.
Why are you using the ref to begin with?
What the logic here?
On Tuesday, 14 December 2021 at 05:38:17 UTC, Tejas wrote:
On Monday, 13 December 2021 at 22:30:59 UTC, Adam D Ruppe wrote:
On Monday, 13 December 2021 at 22:06:45 UTC, chopchop wrote:
If I remove the ref, it works as expected, that is to say I
can give a derived class as parameter.
Why are
On 12/14/21 11:19 AM, Steven Schveighoffer wrote:
Er... scratch that, this isn't construction, it should use opAssign.
Again, probably because memcpy+postblit is used by the runtime.
If not reported, it should be.
Simple proof that it is a bug:
```d
immutable (ComplexStruct)[] arr;
On 12/14/21 11:14 AM, Steven Schveighoffer wrote:
On 12/14/21 10:53 AM, Stanislav Blinov wrote:
Now, since we have copy ctors, slice assignment should, ostensibly,
attempt to copy-assign elements (i.e. absent opAssign, try the copy
ctor first).
I agree slice-assign should work here with a
On 12/14/21 10:53 AM, Stanislav Blinov wrote:
Now, since we have copy ctors, slice assignment should, ostensibly,
attempt to copy-assign elements (i.e. absent opAssign, try the copy ctor
first).
I agree slice-assign should work here with a copy ctor. What I think is
happening is that it's
On Tuesday, 14 December 2021 at 15:28:30 UTC, Steven
Schveighoffer wrote:
All the other problems you are having are deriving from this
problem.
Not exactly. One of the problems seems to be a genuine bug:
```d
struct S
{
int[] x;
// doesn't even participate here, neither would
On 12/14/21 3:44 AM, rumbu wrote:
I am trying to understand why in this two different cases (Simple and
Complex), the compiler behaviour is different.
```d
struct SimpleStruct { int x;}
struct ComplexStruct { int[] x; }
void main()
{
SimpleStruct[] buf1;
immutable(SimpleStruct)[]
On 12/14/21 12:04 AM, Tejas wrote:
Is there anything wrong with the answer I posted?
Can you please tell me if there's anything dissatisfactory about it? I
feel like it does everything the OP wants.
Also, am I wrong in using `Unconst` over `Unqual`? Isn't `Unqual`
overkill if you just want
On Sunday, 12 December 2021 at 11:57:43 UTC, vit wrote:
Hello, why does this code fail to compile?
```d
struct Foo(T){
this(Rhs, this This)(scope Rhs rhs){
}
this(ref scope typeof(this) rhs){
}
}
struct Bar{
Foo!int foo;
}
void main(){
}
```
error: Segmentation
On Tuesday, 14 December 2021 at 13:02:16 UTC, Tejas wrote:
On Tuesday, 14 December 2021 at 12:04:36 UTC, RazvanN wrote:
[...]
Then why did my modification work?
```d
struct Foo(T){
this(Rhs, this This)(scope Rhs rhs){
}
this(scope Foo!(T)* rhs){ //replaced typeof(this) with
On Tuesday, 14 December 2021 at 05:04:46 UTC, Tejas wrote:
Is there anything wrong with the answer I posted?
Can you please tell me if there's anything dissatisfactory
about it? I feel like it does everything the OP wants.
Also, am I wrong in using `Unconst` over `Unqual`? Isn't
`Unqual`
On Tuesday, 14 December 2021 at 12:13:23 UTC, Stanislav Blinov
wrote:
Because is(typeof(immutable(ComplexStruct).x) ==
immutable(int[])). Can't bind an array of immutable to array of
mutable. This would require a deep copy, i.e. copy constructor.
This means that the only way to write a
On Tuesday, 14 December 2021 at 12:04:36 UTC, RazvanN wrote:
On Sunday, 12 December 2021 at 11:57:43 UTC, vit wrote:
[...]
The problem is that the compiler will try to generate an inout
copy constructor for Bar that looks roughly like this:
```
this(ref scope inout(Bar) p) inout
{
On Tuesday, 14 December 2021 at 08:44:02 UTC, rumbu wrote:
I am trying to understand why in this two different cases
(Simple and Complex), the compiler behaviour is different.
```d
struct SimpleStruct { int x;}
struct ComplexStruct { int[] x; }
void main()
{
SimpleStruct[] buf1;
On Tuesday, 14 December 2021 at 08:44:02 UTC, rumbu wrote:
I am trying to understand why in this two different cases
(Simple and Complex), the compiler behaviour is different.
```d
struct SimpleStruct { int x;}
struct ComplexStruct { int[] x; }
void main()
{
SimpleStruct[] buf1;
On Sunday, 12 December 2021 at 11:57:43 UTC, vit wrote:
Hello, why does this code fail to compile?
```d
struct Foo(T){
this(Rhs, this This)(scope Rhs rhs){
}
this(ref scope typeof(this) rhs){
}
}
struct Bar{
Foo!int foo;
}
void main(){
}
```
error: Segmentation
On Tuesday, 14 December 2021 at 08:07:43 UTC, WebFreak001 wrote:
The best way would be not doing this at all - when you
manipulate strings/arrays in D you can do so by just assigning
the elements like this:
```d
immutable(char)[] replaceChar(char[] str, char ch1, char ch2)
{
for (ulong
I am trying to understand why in this two different cases (Simple
and Complex), the compiler behaviour is different.
```d
struct SimpleStruct { int x;}
struct ComplexStruct { int[] x; }
void main()
{
SimpleStruct[] buf1;
immutable(SimpleStruct)[] ibuf1;
buf1[0 .. 10] = ibuf1[0 ..
On Tuesday, 14 December 2021 at 08:12:04 UTC, zoujiaqing wrote:
My code:
```D
module http.HttpRequest;
import std.container;
import std.array : Appender;
struct HttpRequest
{
struct Header()
{
Appender!string name;
Appender!string value;
}
string method;
My code:
```D
module http.HttpRequest;
import std.container;
import std.array : Appender;
struct HttpRequest
{
struct Header()
{
Appender!string name;
Appender!string value;
}
string method;
string uri;
int versionMajor = 0;
int versionMinor = 0;
On Monday, 13 December 2021 at 22:43:14 UTC, forkit wrote:
[...]
//char* w = cast(char*)str; // nope. a pointer to a string
constant is
// (supposed to be) immutable,
so expect undefined behaviour.
note:
//char* w = cast(char*)str.toStringz; // also
29 matches
Mail list logo