Re: Packing of Struct Fields

2020-10-17 Thread Per Nordlöw via Digitalmars-d-learn
On Saturday, 17 October 2020 at 13:23:38 UTC, Adam D. Ruppe wrote: Use a union. Nice! Thanks!

GtkD CRUD Application

2020-10-17 Thread Alaindevos via Digitalmars-d-learn
I've written the beginning but dont know how to end. What is the way to add functionality for the add,edit,delete button ? //== import gtk.Button; import gtk.Box; import gtk.Label; import gtk.Entry; import gtk.Grid; import gtk.Main; import gtk.MainWindow; import

Re: Best way to confine project to 64 bit builds only?

2020-10-17 Thread Dennis via Digitalmars-d-learn
On Saturday, 17 October 2020 at 14:50:47 UTC, NonNull wrote: I have inherited an open source C project that assumes that the size of a long and the size of a pointer are the same, and I have translated it into very similar D just like

Re: Best way to confine project to 64 bit builds only?

2020-10-17 Thread NonNull via Digitalmars-d-learn
On Saturday, 17 October 2020 at 14:56:33 UTC, Basile B. wrote: On Saturday, 17 October 2020 at 14:50:47 UTC, NonNull wrote: I have inherited an open source C project that assumes that the size of a long and the size of a pointer are the same, and I have translated it into very similar D just

Re: Why is `Appender._data` a pointer to its `Data`-store?

2020-10-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/17/20 12:00 AM, Paul Backus wrote: On Saturday, 17 October 2020 at 00:06:31 UTC, Steven Schveighoffer wrote: Appender is ref counted IIRC. It's not; it uses the GC. Oh yeah. In fact, it was me who did that (in 2010!). My point should have been that the appender is a pImpl to avoid

Re: Packing of Struct Fields

2020-10-17 Thread Per Nordlöw via Digitalmars-d-learn
On Saturday, 17 October 2020 at 12:35:37 UTC, Per Nordlöw wrote: On Friday, 16 October 2020 at 21:26:12 UTC, Steven Schveighoffer wrote: To further explain this -- the padding is added so things like pointer arithmetic on an array work. In my code sample above one can only access the first

Re: Packing of Struct Fields

2020-10-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 17 October 2020 at 13:00:59 UTC, Per Nordlöw wrote: I understand that. I don't want the alignment of `S` to change. I want the padding after `s` That padding is part of S. It is at the end, after its fields, but still part of it. S's layout doesn't depend on what else is around

Re: Packing of Struct Fields

2020-10-17 Thread Per Nordlöw via Digitalmars-d-learn
On Saturday, 17 October 2020 at 13:42:46 UTC, Steven Schveighoffer wrote: I think it *should* be possible to do this, if it's not already, just with pragmas. (i.e. pack T but not S). Agree, a pragma, say `pragma(pack)`, to control this would be great to avoid the unsafe union hack.

Re: Forward referencing functions in D

2020-10-17 Thread NonNull via Digitalmars-d-learn
On Friday, 16 October 2020 at 21:28:18 UTC, Steven Schveighoffer wrote: Inner functions have benefits: 1. They are only accessible inside the function. Which means you only have to worry about correctness while INSIDE that function. 2. inner functions have access to the outer function's stack

Re: Forward referencing functions in D

2020-10-17 Thread Ali Çehreli via Digitalmars-d-learn
On 10/17/20 8:28 AM, NonNull wrote: On Friday, 16 October 2020 at 21:28:18 UTC, Steven Schveighoffer wrote: Inner functions have benefits: 1. They are only accessible inside the function. Which means you only have to worry about correctness while INSIDE that function. 2. inner functions have

Re: How to rebind the default tkd GUI keybinds?

2020-10-17 Thread tastyminerals via Digitalmars-d-learn
On Sunday, 11 October 2020 at 18:51:17 UTC, tastyminerals wrote: Tk default keys are somewhat different from what we used to use for selecting, copying and pasting the text. So, any Tk based GUI app starts with writing the rebinding function for "ctrl+a", "ctrl+c", "ctrl+x" and "ctrl+v" keys,

Re: Struct field destructor not called when exception is thrown in the main struct destructor

2020-10-17 Thread tchaloupka via Digitalmars-d-learn
On Friday, 16 October 2020 at 16:00:07 UTC, Steven Schveighoffer wrote: On 10/16/20 9:12 AM, tchaloupka wrote: So when the exception is thrown within Foo destructor (and it's bad on it's own but can easily happen as destructors aren't nothrow @nogc by default). Is this behavior expected?

Re: Packing of Struct Fields

2020-10-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 17 October 2020 at 12:44:44 UTC, Per Nordlöw wrote: Can `align`s be inserted in S or/and T so that T is packed to 8 bytes but still aligned to 8 bytes? Yes. Put an align on the OUTSIDE of the struct you are nesting, then put one INSIDE the struct you want the contents packed.

Re: Packing of Struct Fields

2020-10-17 Thread Per Nordlöw via Digitalmars-d-learn
On Saturday, 17 October 2020 at 12:51:21 UTC, ag0aep6g wrote: c does come directly after s. The padding between b and c is part of s. If you don't want that padding, you can use `align(1)` to define S without padding. But then 75% of the ints in an S[] will be misaligned. I understand that.

Re: How do I use translation module in vibe.d?

2020-10-17 Thread aberba via Digitalmars-d-learn
On Tuesday, 13 October 2020 at 17:02:54 UTC, Jack wrote: On Tuesday, 13 October 2020 at 08:07:17 UTC, aberba wrote: On Friday, 9 October 2020 at 21:07:28 UTC, jack wrote: [...] https://www.github.com/vibe-d/vibe.d/tree/master/examples%2Fweb-i18n There's also an example here My dub.json

Re: Packing of Struct Fields

2020-10-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/17/20 9:00 AM, Per Nordlöw wrote: On Saturday, 17 October 2020 at 12:51:21 UTC, ag0aep6g wrote: c does come directly after s. The padding between b and c is part of s. If you don't want that padding, you can use `align(1)` to define S without padding. But then 75% of the ints in an S[]

Re: Best way to confine project to 64 bit builds only?

2020-10-17 Thread NonNull via Digitalmars-d-learn
On Saturday, 17 October 2020 at 15:03:29 UTC, Dennis wrote: If you want to exactly match the original C code's semantics, I suggest translating (unsigned) long with c_long or c_ulong. You can import them here: ``` import core.stdc.config: c_long, c_ulong; ``` Then you could add this: ```

Re: Packing of Struct Fields

2020-10-17 Thread Per Nordlöw via Digitalmars-d-learn
On Friday, 16 October 2020 at 21:26:12 UTC, Steven Schveighoffer wrote: To further explain this -- the padding is added so things like pointer arithmetic on an array work. In my code sample above one can only access the first element anyhow so I don't understand why this restriction is

Re: Packing of Struct Fields

2020-10-17 Thread ag0aep6g via Digitalmars-d-learn
On 17.10.20 14:35, Per Nordlöw wrote: struct S {     int i;     bool b; } struct T {     S s; // reinterpreting this as an array can only access this first element anyway     char c; // so why can't this be aligned directly after `s` without any padding? } c does come directly after

Re: Packing of Struct Fields

2020-10-17 Thread Per Nordlöw via Digitalmars-d-learn
On Saturday, 17 October 2020 at 12:44:44 UTC, Per Nordlöw wrote: Can `align`s be inserted in S or/and T so that T is packed to 8 bytes but still aligned to 8 bytes? I don't see why this shouldn't be the default behaviour... I though this would do the trick but not... struct S {

Best way to confine project to 64 bit builds only?

2020-10-17 Thread NonNull via Digitalmars-d-learn
I have inherited an open source C project that assumes that the size of a long and the size of a pointer are the same, and I have translated it into very similar D just like https://dlang.org/blog/2018/06/11/dasbetterc-converting-make-c-to-d/ D has the size of long fixed at 64 bits, so a

Re: vibe.d / experience / feedback

2020-10-17 Thread aberba via Digitalmars-d-learn
On Wednesday, 14 October 2020 at 15:11:29 UTC, Alaindevos wrote: Is there an example just more functional then skeleton http server ? Sending data to the server and back . If you're having vibe.d trouble and can't get a quick response, jump in the discord. We're there to help?

Re: Best way to confine project to 64 bit builds only?

2020-10-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 17 October 2020 at 14:50:47 UTC, NonNull wrote: I have inherited an open source C project that assumes that the size of a long and the size of a pointer are the same static assert(long.sizeof == void*.sizeof);

Re: Best way to confine project to 64 bit builds only?

2020-10-17 Thread Basile B. via Digitalmars-d-learn
On Saturday, 17 October 2020 at 14:50:47 UTC, NonNull wrote: I have inherited an open source C project that assumes that the size of a long and the size of a pointer are the same, and I have translated it into very similar D just like

Re: Best way to confine project to 64 bit builds only?

2020-10-17 Thread NonNull via Digitalmars-d-learn
On Saturday, 17 October 2020 at 14:56:35 UTC, Adam D. Ruppe wrote: On Saturday, 17 October 2020 at 14:50:47 UTC, NonNull wrote: I have inherited an open source C project that assumes that the size of a long and the size of a pointer are the same static assert(long.sizeof == void*.sizeof);

IRe: GtkD CRUD Application

2020-10-17 Thread aberba via Digitalmars-d-learn
On Saturday, 17 October 2020 at 14:53:35 UTC, Alaindevos wrote: I've written the beginning but dont know how to end. What is the way to add functionality for the add,edit,delete button ? //== import gtk.Button; import gtk.Box; import gtk.Label; import gtk.Entry;

Re: vibe.d / experience / feedback

2020-10-17 Thread shamsmehra90 via Digitalmars-d-learn
I could not even find demo code doing a redirect which is the most basic stuff. https://mcdvoicesurvey.onl https://mybk-experience.onl

Re: How to rebind the default tkd GUI keybinds?

2020-10-17 Thread starcanopy via Digitalmars-d-learn
On Saturday, 17 October 2020 at 09:33:04 UTC, tastyminerals wrote: On Sunday, 11 October 2020 at 18:51:17 UTC, tastyminerals wrote: Tk default keys are somewhat different from what we used to use for selecting, copying and pasting the text. So, any Tk based GUI app starts with writing the

Re: vibe.d / experience / feedback

2020-10-17 Thread Andre Pany via Digitalmars-d-learn
On Saturday, 17 October 2020 at 16:35:29 UTC, shamsmehra90 wrote: I could not even find demo code doing a redirect which is the most basic stuff. https://mcdvoicesurvey.onl https://mybk-experience.onl There are 6 examples doing a redirect: https://github.com/vibe-d/vibe.d/search?q=redirect=

Re: GtkD CRUD Application

2020-10-17 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Saturday, 17 October 2020 at 14:53:35 UTC, Alaindevos wrote: I've written the beginning but dont know how to end. What is the way to add functionality for the add,edit,delete button ? //== I put an example[1] here. The fields are not editable. You will