Re: Can I create a package with friendly modules

2022-06-11 Thread forkit via Digitalmars-d-learn
On Sunday, 12 June 2022 at 05:05:46 UTC, forkit wrote: e.g. If I could something like this: // foo_1.d module foo_1 private int a; // a is private to module foo_1 // foo_2.d module foo_2 private int b; // b is private to module foo_2 // foo.d module foo[dependencies:foo_1, foo_2]; import

Re: UI Library

2022-06-11 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 11 June 2022 at 21:44:17 UTC, harakim wrote: I tried the solution I suggested and it did not work because the child would occlude the parent (which is in the comments now that I see it.) yeah minigui's model is to tile the widgets; they aren't supposed to overlap (except their

Re: UI Library

2022-06-11 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 11 June 2022 at 01:20:17 UTC, harakim wrote: The issue I'm having is that I don't understand how to assign bounds in the nested widget. I'm sure there's a very clean solution. I basically want a paintContent method but with the bounds dynamically assigned by the parent. Well the

Can I create a package with friendly modules

2022-06-11 Thread forkit via Digitalmars-d-learn
Is it possible to create a package.d, consisting of (for example), two modules, where each module can access private declarations within each other. In essence, declaring 'a module level friendship', or a kind of 'extended module' if you want. I might still want to add another module to the

Re: Can I create a package with friendly modules

2022-06-11 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 12 June 2022 at 05:05:46 UTC, forkit wrote: Is it possible to create a package.d, consisting of (for example), two modules, where each module can access private declarations within each other. In essence, declaring 'a module level friendship', or a kind of 'extended module' if you

Re: a struct as an multidimensional array index

2022-06-11 Thread z via Digitalmars-d-learn
On Saturday, 11 June 2022 at 15:01:05 UTC, Ali Çehreli wrote: On 6/11/22 00:09, z wrote: > I rechecked and it should be `X Y Z` for static array, but `Z Y X` for > indexing/dynamic array creating with `new` How so? i meant with the syntax in (1), the spec's documentation appears to say they

Re: a struct as an multidimensional array index

2022-06-11 Thread Ali Çehreli via Digitalmars-d-learn
On 6/11/22 13:36, z wrote: > i meant with the syntax in (1), the spec's documentation appears to say > they are equivalent in result with `new *type*[X][Y]` form. > > (1) https://dlang.org/spec/expression#new_multidimensional (3. multiple > argument form) Thank you. I see now: The values in

Re: UI Library

2022-06-11 Thread harakim via Digitalmars-d-learn
On Saturday, 11 June 2022 at 01:20:17 UTC, harakim wrote: On Friday, 20 May 2022 at 12:07:46 UTC, Adam D Ruppe wrote: On Friday, 20 May 2022 at 03:47:14 UTC, harakim wrote: Thank you. I will definitely give that a try. But just ask me if something comes up since I can push fixes to master p

Error: cannot use non-constant CTFE pointer in an initializer `cast(immutable(char)*)TEST`

2022-06-11 Thread test123 via Digitalmars-d-learn
how to work this around. ```d __gshared const TEST = import(`onlineapp.d`); extern(C) void main(){ __gshared bin_ptr = TEST.ptr; } ``` ```sh dmd2 -betterC -J. onlineapp.d onlineapp.d(3): Error: cannot use non-constant CTFE pointer in an initializer `cast(immutable(char)*)TEST` ```

Re: Why allow initializers of non-static members that allocate?

2022-06-11 Thread Bastiaan Veelo via Digitalmars-d-learn
On Saturday, 11 June 2022 at 01:52:58 UTC, Mike Parker wrote: People getting bit by `new` in field initialization often enough that I think a warning would be helpful. The problem is so much bigger because it is not just a case of being aware not to use `new` in member initialisers. As you

Re: Why allow initializers of non-static members that allocate?

2022-06-11 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 11 June 2022 at 10:37:30 UTC, Bastiaan Veelo wrote: So that’s why I used “why” in the title of this thread, which I haven’t seen an answer to yet. What is the practical case where that warning would be annoying? When would you actually want this behaviour? After actually

Re: a struct as an multidimensional array index

2022-06-11 Thread Salih Dincer via Digitalmars-d-learn
On Friday, 10 June 2022 at 17:26:48 UTC, Ali Çehreli wrote: I've written about this multiple times in the past but D's way is consistent for me. That must be because I always found C's syntax to be very illogical on this. [...] I think so too... I think D is very consistent with our

Re: Error: cannot use non-constant CTFE pointer in an initializer `cast(immutable(char)*)TEST`

2022-06-11 Thread Tejas via Digitalmars-d-learn
On Saturday, 11 June 2022 at 11:51:43 UTC, Tejas wrote: On Saturday, 11 June 2022 at 10:07:46 UTC, test123 wrote: how to work this around. ```d __gshared const TEST = import(`onlineapp.d`); extern(C) void main(){ __gshared bin_ptr = TEST.ptr; } ``` ```sh dmd2 -betterC -J. onlineapp.d

Re: Error: cannot use non-constant CTFE pointer in an initializer `cast(immutable(char)*)TEST`

2022-06-11 Thread Tejas via Digitalmars-d-learn
On Saturday, 11 June 2022 at 10:07:46 UTC, test123 wrote: how to work this around. ```d __gshared const TEST = import(`onlineapp.d`); extern(C) void main(){ __gshared bin_ptr = TEST.ptr; } ``` ```sh dmd2 -betterC -J. onlineapp.d onlineapp.d(3): Error: cannot use non-constant CTFE

Re: Why allow initializers of non-static members that allocate?

2022-06-11 Thread Salih Dincer via Digitalmars-d-learn
On Saturday, 11 June 2022 at 02:22:28 UTC, matheus wrote: Well would this be annoying? Yes, mainly if I already know this, but if not, then it would be like a nice to know warning for newbies like myself. By the way this would be only in the cases that a static array field being initialized

Re: a struct as an multidimensional array index

2022-06-11 Thread z via Digitalmars-d-learn
On Saturday, 11 June 2022 at 03:56:32 UTC, Chris Katko wrote: On Friday, 10 June 2022 at 17:26:48 UTC, Ali Çehreli wrote: On 6/10/22 08:13, z wrote: > arrays of arrays has different order for declaration and addressing, > and declaring array of arrays has different order depending on how you >

Re: a struct as an multidimensional array index

2022-06-11 Thread Ali Çehreli via Digitalmars-d-learn
On 6/11/22 04:16, Salih Dincer wrote: > I think D is very consistent with our feelings. That is, the order in > memory is in the form of rows x columns. Yet, there are no rows or columns because neither D nor C (nor C++) have multip-dimensional arrays. They all have arrays where elements are

Re: a struct as an multidimensional array index

2022-06-11 Thread Ali Çehreli via Digitalmars-d-learn
On 6/11/22 00:09, z wrote: > I rechecked and it should be `X Y Z` for static array, but `Z Y X` for > indexing/dynamic array creating with `new` How so? I wrote the following program: import std.stdio; void main() { enum X = 2; enum Y = 3; enum Z = 4; int[X][Y][Z] s; int[X][Y][] d

Re: sha256 to bigint

2022-06-11 Thread Paul Backus via Digitalmars-d-learn
On Saturday, 11 June 2022 at 13:09:44 UTC, vc wrote: Hello, is there any way to represnts a sha256 hash like 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 in BigInt ? I've try so far auto t = BigInt("2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824") and

Re: sha256 to bigint

2022-06-11 Thread vc via Digitalmars-d-learn
On Saturday, 11 June 2022 at 13:09:44 UTC, vc wrote: Hello, is there any way to represnts a sha256 hash like 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 in BigInt ? I've try so far auto t = BigInt("2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824") and

Re: Why allow initializers of non-static members that allocate?

2022-06-11 Thread Bastiaan Veelo via Digitalmars-d-learn
On Saturday, 11 June 2022 at 10:52:58 UTC, Mike Parker wrote: I agree with your initial assessment that it should be an error. It really only makes sense to allow the dynamic allocation if the fields are immutable and, in the case of arrays, the initializer is a literal. 

sha256 to bigint

2022-06-11 Thread vc via Digitalmars-d-learn
Hello, is there any way to represnts a sha256 hash like 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 in BigInt ? I've try so far auto t = BigInt("2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824") and it gives me invalid digit