July 02, 2022

On Saturday, 2 July 2022 at 16:15:13 UTC, Ola Fosheim Grøstad wrote:

> >
struct S{}

void f();
void f(S s);

f({}); // which gets called?

It is a parameter list for the constructor of S, so F(S s) gets called.

So in D we would need a new type for a constructor parameter list. We already have parameter lists which have a type, but we can't use that because it would call f(), not f(S).

July 02, 2022

On Saturday, 2 July 2022 at 16:37:55 UTC, Nick Treleaven wrote:

>

On Saturday, 2 July 2022 at 16:15:13 UTC, Ola Fosheim Grøstad wrote:

> >
struct S{}

void f();
void f(S s);

f({}); // which gets called?

It is a parameter list for the constructor of S, so F(S s) gets called.

So in D we would need a new type for a constructor parameter list. We already have parameter lists which have a type, but we can't use that because it would call f(), not f(S).

It could also be ambiguous in the above case.

July 02, 2022

On Saturday, 2 July 2022 at 16:42:20 UTC, Stefan Koch wrote:

>

It could also be ambiguous in the above case.

In what way? f() doesn't take any parameters. An empty list is more than nothing.

July 05, 2022

On Friday, 1 July 2022 at 21:01:43 UTC, Paul Backus wrote:

>

Maybe if the proposal were for some kind of "struct literals", rather than just {} by itself, it would be more attractive.

That would be this issue: https://issues.dlang.org/show_bug.cgi?id=15692.

Rephrasing the example from the second comment:

auto img = createImage(device, VkImageCreateInfo {
	imageType: VkImageType.VK_IMAGE_TYPE_2D,
	format: VkFormat.VK_FORMAT_R8G8B8A8_UNORM,
	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,
});

// Or C#-style "target-typed `new`" / C++-style aggregate initialization
auto img = createImage(device, {
	imageType: VkImageType.VK_IMAGE_TYPE_2D,
	format: VkFormat.VK_FORMAT_R8G8B8A8_UNORM,
	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,
});
July 06, 2022

On Saturday, 2 July 2022 at 16:37:55 UTC, Nick Treleaven wrote:

>

On Saturday, 2 July 2022 at 16:15:13 UTC, Ola Fosheim Grøstad wrote:

> >
struct S{}

void f();
void f(S s);

f({}); // which gets called?

It is a parameter list for the constructor of S, so F(S s) gets called.

So in D we would need a new type for a constructor parameter list. We already have parameter lists which have a type, but we can't use that because it would call f(), not f(S).

So, you have to make a choice, the better choice is to not have implicit conversion and require a splat operator. The other choice is to make {...} unbound and let the use context bind the type. The third choice is to use f({{}}). The forth choice is to introduce proper tuples and type variables and let those represent parameter lists, which might be the best option.

July 06, 2022

On Friday, 1 July 2022 at 11:51:57 UTC, ryuukk_ wrote:

>

I had to write this recently

    void reset()
    {
        state.end_index = 0;
        state.buffer_list = SinglyLinkedList!(ubyte[])();
    }

While not that bad, it's annoying, why can't we do like like: A a = {}?

    void reset()
    {
        state.end_index = 0;
        state.buffer_list = {};
    }

Um, what’s wrong with destroy? It resets any variable to initial state (and calls its destructor). Isn’t it what you need?

July 06, 2022

On Wednesday, 6 July 2022 at 14:14:09 UTC, Ogi wrote:

>

On Friday, 1 July 2022 at 11:51:57 UTC, ryuukk_ wrote:

>

I had to write this recently

    void reset()
    {
        state.end_index = 0;
        state.buffer_list = SinglyLinkedList!(ubyte[])();
    }

While not that bad, it's annoying, why can't we do like like: A a = {}?

    void reset()
    {
        state.end_index = 0;
        state.buffer_list = {};
    }

Um, what’s wrong with destroy? It resets any variable to initial state (and calls its destructor). Isn’t it what you need?

I don't use RAII, destroy does something very specific in my arena allocator

The problem i have with destroy is that it is a global and universal function that accepts anything

It should be either internal, reserved with a prefix, moved to a module, or removed

D likes to steal common words that i can't use in my APIs

debug, version, init, destroy

It forces me to come up with annoying alternatives

dbg, versionn, create, dispose (but i really need destroy)

This is poor design in my opinion

July 06, 2022
On Wed, Jul 06, 2022 at 03:51:56PM +0000, ryuukk_ via Digitalmars-d wrote: [...]
> D likes to steal common words that i can't use in my APIs
> 
> `debug`, `version`, `init`, `destroy`
> 
> It forces me to come up with annoying alternatives
> 
> `dbg`, `versionn`, `create`, `dispose` (but i really need `destroy`)
> 
> This is poor design in my opinion

https://dlang.org/dstyle.html

Quote from section "Keywords":

	If a name would conflict with a keyword, and it is desirable to
	use the keyword rather than pick a different name, a single
	underscore ‘_’ should be appended to it.

This is just a recommendation, of course. But at least you wouldn't have to invent new words for your identifiers.


T

-- 
A program should be written to model the concepts of the task it performs rather than the physical world or a process because this maximizes the potential for it to be applied to tasks that are conceptually similar and, more important, to tasks that have not yet been conceived. -- Michael B. Allen
July 06, 2022
On Wednesday, 6 July 2022 at 16:23:58 UTC, H. S. Teoh wrote:
> On Wed, Jul 06, 2022 at 03:51:56PM +0000, ryuukk_ via Digitalmars-d wrote: [...]
>> D likes to steal common words that i can't use in my APIs
>> 
>> `debug`, `version`, `init`, `destroy`
>> 
>> It forces me to come up with annoying alternatives
>> 
>> `dbg`, `versionn`, `create`, `dispose` (but i really need `destroy`)
>> 
>> This is poor design in my opinion
>
> https://dlang.org/dstyle.html
>
> Quote from section "Keywords":
>
> 	If a name would conflict with a keyword, and it is desirable to
> 	use the keyword rather than pick a different name, a single
> 	underscore ‘_’ should be appended to it.
>
> This is just a recommendation, of course. But at least you wouldn't have to invent new words for your identifiers.
>
>
> T

That's not something i like, more care should have been put when deciding to name and  put a function in the global scope, i shouldn't have to pay for that
July 07, 2022

On Wednesday, 6 July 2022 at 15:51:56 UTC, ryuukk_ wrote:

>

On Wednesday, 6 July 2022 at 14:14:09 UTC, Ogi wrote:

> >
    void reset()
    {
        state.end_index = 0;
        state.buffer_list = {};
    }

Um, what’s wrong with destroy? It resets any variable to initial state (and calls its destructor). Isn’t it what you need?

I don't use RAII, destroy does something very specific in my arena allocator

Why can't you call object.destroy()?

>

The problem i have with destroy is that it is a global and universal function that accepts anything

It should be either internal, reserved with a prefix, moved to a module, or removed

D likes to steal common words that i can't use in my APIs

debug, version, init, destroy

It forces me to come up with annoying alternatives

dbg, versionn, create, dispose (but i really need destroy)

object.destroy is well named, it destroys the data. If you want to unallocate the memory, dispose is actually a better name IMO.