Thread overview | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
April 06, 2016 [Issue 15692] Allow struct member initializer everywhere | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=15692 Alex Parrill <initrd.gz@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |initrd.gz@gmail.com --- Comment #1 from Alex Parrill <initrd.gz@gmail.com> --- My use case: Vulkan uses structs to pass large amounts of parameters around. My current code looks like this: VkImageCreateInfo imgInfo = { imageType: VkImageType.VK_IMAGE_TYPE_2D, format: VkFormat.VK_FORMAT_R8G8B8A8_UNORM, // TODO: only allocate alpha if needed extent: image.size, mipLevels: image.mipLevels, arrayLayers: image.layers, samples: VkSampleCountFlagBits.VK_SAMPLE_COUNT_1_BIT, tiling: VkImageTiling.VK_IMAGE_TILING_LINEAR, //VK_IMAGE_TILING_OPTIMAL, usage: VkImageUsageFlagBits.VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VkImageUsageFlagBits.VK_IMAGE_USAGE_SAMPLED_BIT, sharingMode: VkSharingMode.VK_SHARING_MODE_EXCLUSIVE, initialLayout: VkImageLayout.VK_IMAGE_LAYOUT_PREINITIALIZED, }; enforceVK(vkCreateImage(device, &imgInfo, null, &image.img)); It'd be really nice if it were possible to specify the struct inline with the creation call: auto img = createImage(device, VkImageCreateInfo { imageType: VkImageType.VK_IMAGE_TYPE_2D, // ... initialLayout: VkImageLayout.VK_IMAGE_LAYOUT_PREINITIALIZED, }); It'd also be very helpful for returning info structs from lamdas: auto queueCreateInfo = priorities .enumerate .filter!(x => x[1].length > 0) .map!((x) { VkDeviceQueueCreateInfo info = { queueFamilyIndex: x[0], queueCount: cast(uint) x[1].length, pQueuePriorities: x[1].ptr, }; return info; }) .array; You also basically have to use the the named field initialization syntax because each Vulkan info struct begins with a `sType` field and a `pNext` field, which at the moment should be a struct-specific constant and null that you don't really want to specify each time you create the struct. -- |
April 26, 2017 [Issue 15692] Allow struct member initializer everywhere | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=15692 Lionello Lunesu <lio+bugzilla@lunesu.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lio+bugzilla@lunesu.com --- Comment #2 from Lionello Lunesu <lio+bugzilla@lunesu.com> --- My 2c: this is more D-like, auto foo = cast(Foo){ a: 3, b: 4 }; -- |
April 26, 2017 [Issue 15692] Allow struct member initializer everywhere | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=15692 --- Comment #3 from Jacob Carlborg <doob@me.com> --- (In reply to Lionello Lunesu from comment #2) > My 2c: this is more D-like, > > auto foo = cast(Foo){ a: 3, b: 4 }; I disagree, this looks weird. -- |
June 08, 2017 [Issue 15692] Allow struct member initializer everywhere | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=15692 greensunny12@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |greensunny12@gmail.com --- Comment #4 from greensunny12@gmail.com --- I just revived a DIP that deals with this topic: https://github.com/dlang/DIPs/pull/71 Help to polish it is welcome ;-) -- |
December 12, 2019 [Issue 15692] Allow struct member initializer everywhere | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=15692 Basile-z <b2.temp@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |radu.racariu@gmail.com --- Comment #5 from Basile-z <b2.temp@gmx.com> --- *** Issue 19237 has been marked as a duplicate of this issue. *** -- |
December 12, 2019 [Issue 15692] Allow struct member initializer everywhere | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=15692 Basile-z <b2.temp@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |b2.temp@gmx.com --- Comment #6 from Basile-z <b2.temp@gmx.com> --- Another use case is with mixin expressions: --- struct S { int i; } void main() { S s = mixin(`{1}`); } --- -- |
March 21, 2020 [Issue 15692] Allow struct member initializer everywhere | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=15692 Basile-z <b2.temp@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC|b2.temp@gmx.com | -- |
July 05, 2022 [Issue 15692] Allow struct member initializer everywhere | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=15692 ZombineDev <petar.p.kirov@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |black80@bk.ru --- Comment #7 from ZombineDev <petar.p.kirov@gmail.com> --- *** Issue 20173 has been marked as a duplicate of this issue. *** -- |
December 17, 2022 [Issue 15692] Allow struct member initializer everywhere | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=15692 Iain Buclaw <ibuclaw@gdcproject.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P1 |P4 -- |
January 31, 2023 [Issue 15692] Allow struct member initializer everywhere | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=15692 RazvanN <razvan.nitu1305@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |razvan.nitu1305@gmail.com Resolution|--- |FIXED --- Comment #8 from RazvanN <razvan.nitu1305@gmail.com> --- This has been implemented in https://github.com/dlang/dmd/pull/14776 -- |
Copyright © 1999-2021 by the D Language Foundation