Re: Private nested class instance accessed via outer class public interface

2023-06-16 Thread Murloc via Digitalmars-d-learn
On Friday, 16 June 2023 at 07:54:21 UTC, Richard (Rikki) Andrew Cattermole wrote: Also we have a Discord server which you are welcome to join! https://discord.gg/bMZk9Q4 Thanks for the invitation. However, I don't like Discord so I don't use it :)

Re: Private nested class instance accessed via outer class public interface

2023-06-16 Thread Murloc via Digitalmars-d-learn
And since classes can be declared locally inside methods, you can also do something similar this way: ```d import std.stdio; import std.conv; Object getB() { class B { private int field = 30; override string toString() => to!string(field); } return cast(O

Private nested class instance accessed via outer class public interface

2023-06-16 Thread Murloc via Digitalmars-d-learn
I'm not sure if this behavior is desired and have any use-cases (should I report it as a bug?), but, for example, C# doesn't allow this. ```d import std.conv; class Outer { private static class Inner { private int field = 30; override string toString() => to!string(field);

Private nested class instance accessed via outer class public interface

2023-06-16 Thread Murloc via Digitalmars-d-learn
I'm not sure if this behavior is desired and have any use-cases (should I report it as a bug?), but, for example, C# doesn't allow this. ```d import std.conv; class Outer { private static class Inner { private int field = 30; override string toString() => to!string(field);

Re: GDC Compilation wtih Directory Present

2023-06-15 Thread Murloc via Digitalmars-d-learn
On Friday, 16 June 2023 at 06:32:21 UTC, Richard (Rikki) Andrew Cattermole wrote: On 16/06/2023 6:26 PM, Murloc wrote: Don't you need to provide a full path to these files relatively to the directory where the compilation process takes place (Test)? Yes. But I suspect you have not written th

GDC Compilation wtih Directory Present

2023-06-15 Thread Murloc via Digitalmars-d-learn
My project structure is the following: ``` Test | +-- pack | | | +-- file1.d | | | +-- file2.d | +-- program.d ``` And here is the code inside these files: ```d // file2.d package int value = -120; ``` ```d // file1.d void printlnValueInFile2() { import std.stdio: writeln; impo

Re: byte and short data types use cases

2023-06-09 Thread Murloc via Digitalmars-d-learn
On Friday, 9 June 2023 at 12:56:20 UTC, Cecil Ward wrote: On Friday, 9 June 2023 at 11:24:38 UTC, Murloc wrote: If you have four ubyte variables in a struct and then an array of them, then you are getting optimal memory usage. Is this some kind of property? Where can I read more about this? S

byte and short data types use cases

2023-06-09 Thread Murloc via Digitalmars-d-learn
Hi, I was interested why, for example, `byte` and `short` literals do not have their own unique suffixes (like `L` for `long` or `u` for `unsigned int` literals) and found the following explanation: - "I guess short literal is not supported solely due to the fact that anything less than `int`