On Saturday, 30 July 2022 at 10:34:09 UTC, ag0aep6g wrote:
You're not making sense. Your `s` is mutable, not immutable.
You're right! I saw the hole at the end of the tunnel late 😀
But if you compile the example below without the `new operator`,
the system does not work and does not give any
On 7/30/22 15:19, Salih Dincer wrote:
On Saturday, 30 July 2022 at 10:02:50 UTC, Timon Gehr wrote:
It's a `const` hole, plain and simple.
This code, which consists of 26 lines, does not compile in DMD 2.087. I
am getting this error:
constHole.d(15): Error: mutable method `source.Updater.o
On Saturday, 30 July 2022 at 10:02:50 UTC, Timon Gehr wrote:
It's a `const` hole, plain and simple.
This code, which consists of 26 lines, does not compile in DMD
2.087. I am getting this error:
constHole.d(15): Error: mutable method `source.Updater.opCall`
is not callable using a `const`
On 30.07.22 09:15, Salih Dincer wrote:
It's possible to do this because it's immutable. You don't need an
extra update() function anyway.
```d
void main()
{
   auto s = S("test A");
   s.update = (_) { s.s = _; };
   s.update("test B");
   assert(s.s == "test B");
   s.s = "test C"
On 7/30/22 00:16, H. S. Teoh wrote:
On Fri, Jul 29, 2022 at 09:56:20PM +, Andrey Zherikov via
Digitalmars-d-learn wrote:
In the example below `func` changes its `const*` argument. Does this
violates D's constness?
```d
import std;
struct S
{
string s;
void delegate(string s) up
On Saturday, 30 July 2022 at 06:04:16 UTC, ag0aep6g wrote:
Yes. Here's a modified example to show that you can also
violate `immutable` this way:
It's possible to do this because it's immutable. You don't need
an extra update() function anyway.
```d
void main()
{
auto s = S("test A")
On 29.07.22 23:56, Andrey Zherikov wrote:
In the example below `func` changes its `const*` argument. Does this
violates D's constness?
Yes. Here's a modified example to show that you can also violate
`immutable` this way:
struct S
{
string s;
void delegate(string s) @safe update;
}
On Friday, 29 July 2022 at 23:15:14 UTC, Salih Dincer wrote:
It's smart to use `delegate`, but `immutable` doesn't
necessarily mean `const`. So if we use `const char`:
```d
struct S
{
char s;
void delegate(char s) update;
}
```
Pardon 😀
I forgot the assert test, also writing const i
On Friday, 29 July 2022 at 21:56:20 UTC, Andrey Zherikov wrote:
In the example below `func` changes its `const*` argument. Does
this violates D's constness?
It's smart to use `delegate`, but `immutable` doesn't necessarily
mean `const`. So if we use `const char`:
```d
struct S
{
char
On Friday, 29 July 2022 at 22:16:26 UTC, H. S. Teoh wrote:
This totally makes sense. Thanks for explanation!
On Fri, Jul 29, 2022 at 09:56:20PM +, Andrey Zherikov via
Digitalmars-d-learn wrote:
> In the example below `func` changes its `const*` argument. Does this
> violates D's constness?
>
> ```d
> import std;
>
> struct S
> {
> string s;
>
> void delegate(string s) update;
> }
>
> void
In the example below `func` changes its `const*` argument. Does
this violates D's constness?
```d
import std;
struct S
{
string s;
void delegate(string s) update;
}
void func(const S* s)
{
writeln(*s);
s.update("func");
writeln(*s);
}
void main()
{
auto s = S("test");
12 matches
Mail list logo