On 2020-09-05 07:14, 60rntogo wrote:
I wouldn't dispute that it is useful, but that's besides the point. If I
declare something private, it's usually because I want to preserve
certain invariants and I want the compiler to provide a guarantee that I
don't accidentally violate them. As it
On Friday, 4 September 2020 at 17:36:00 UTC, Jacob Carlborg wrote:
It's useful for serialization and, as you can see in your
example, for debugging as well. `writeln` will print the values
of the fields in a struct, even for private fields.
I wouldn't dispute that it is useful, but that's
On Friday, 4 September 2020 at 18:23:09 UTC, H. S. Teoh wrote:
On Fri, Sep 04, 2020 at 07:36:00PM +0200, Jacob Carlborg via
Digitalmars-d-learn wrote: [...]
It's useful for serialization and, as you can see in your
example, for debugging as well. `writeln` will print the
values of the fields
On Fri, Sep 04, 2020 at 07:36:00PM +0200, Jacob Carlborg via
Digitalmars-d-learn wrote:
[...]
> It's useful for serialization and, as you can see in your example, for
> debugging as well. `writeln` will print the values of the fields in a
> struct, even for private fields.
It's certainly useful,
On 2020-09-04 12:16, 60rntogo wrote:
Consider the following code.
foo.d
---
module foo;
struct Foo
{
private int i;
}
---
main.d
---
void main()
{
import std.stdio;
import foo;
auto x = Foo();
writeln(x);
// ++x.i;
++x.tupleof[0];
writeln(x);
}
---
As expected, the
On Friday, 4 September 2020 at 10:16:47 UTC, 60rntogo wrote:
Consider the following code.
foo.d
---
module foo;
struct Foo
{
private int i;
}
---
main.d
---
void main()
{
import std.stdio;
import foo;
auto x = Foo();
writeln(x);
// ++x.i;
++x.tupleof[0];
writeln(x);
}
---
As
Consider the following code.
foo.d
---
module foo;
struct Foo
{
private int i;
}
---
main.d
---
void main()
{
import std.stdio;
import foo;
auto x = Foo();
writeln(x);
// ++x.i;
++x.tupleof[0];
writeln(x);
}
---
As expected, the commented line does not compile. If I uncomment