[Issue 15692] Allow struct member initializer everywhere

2023-01-31 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15692

RazvanN  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||razvan.nitu1...@gmail.com
 Resolution|--- |FIXED

--- Comment #8 from RazvanN  ---
This has been implemented in https://github.com/dlang/dmd/pull/14776

--


[Issue 15692] Allow struct member initializer everywhere

2022-12-17 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15692

Iain Buclaw  changed:

   What|Removed |Added

   Priority|P1  |P4

--


[Issue 15692] Allow struct member initializer everywhere

2022-07-05 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15692

ZombineDev  changed:

   What|Removed |Added

 CC||blac...@bk.ru

--- Comment #7 from ZombineDev  ---
*** Issue 20173 has been marked as a duplicate of this issue. ***

--


[Issue 15692] Allow struct member initializer everywhere

2020-03-20 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15692

Basile-z  changed:

   What|Removed |Added

 CC|b2.t...@gmx.com |

--


[Issue 15692] Allow struct member initializer everywhere

2019-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15692

Basile-z  changed:

   What|Removed |Added

 CC||b2.t...@gmx.com

--- Comment #6 from Basile-z  ---
Another use case is with mixin expressions:

---
struct S
{
int i;
}

void main()
{
S s = mixin(`{1}`);
}
---

--


[Issue 15692] Allow struct member initializer everywhere

2019-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15692

Basile-z  changed:

   What|Removed |Added

 CC||radu.raca...@gmail.com

--- Comment #5 from Basile-z  ---
*** Issue 19237 has been marked as a duplicate of this issue. ***

--


[Issue 15692] Allow struct member initializer everywhere

2017-06-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15692

greensunn...@gmail.com changed:

   What|Removed |Added

 CC||greensunn...@gmail.com

--- Comment #4 from greensunn...@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 ;-)

--


[Issue 15692] Allow struct member initializer everywhere

2017-04-26 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15692

--- Comment #3 from Jacob Carlborg  ---
(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.

--


[Issue 15692] Allow struct member initializer everywhere

2017-04-25 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15692

Lionello Lunesu  changed:

   What|Removed |Added

 CC||lio+bugzi...@lunesu.com

--- Comment #2 from Lionello Lunesu  ---
My 2c: this is more D-like,

auto foo = cast(Foo){ a: 3, b: 4 };

--


[Issue 15692] Allow struct member initializer everywhere

2016-04-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15692

Alex Parrill  changed:

   What|Removed |Added

 CC||initrd...@gmail.com

--- Comment #1 from Alex Parrill  ---
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, , null, ));

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.

--