How about some __initialize magic?
russhy
russhy at gmail.com
Sun Nov 28 16:36:05 UTC 2021
On Sunday, 28 November 2021 at 08:54:39 UTC, Stanislav Blinov
wrote:
> On Sunday, 28 November 2021 at 03:19:49 UTC, russhy wrote:
>> I would love to be able to do:
>
> This is orthogonal to this discussion. Even if concise
> initializer syntax that you suggest was allowed...
>
>> ```D
>>
>> T* t = alloc();
>>
>> (*t) = .{};
>> ```
>
> ...that's an assignment. I.e. that would lower down to
> `uninitializedGarbage.opAssign(T.init);`. Destructing garbage
> and/or calling operators on garbage isn't exactly the way to
> success :)
>
> Which is the crux of the problem in question, and why things
> like `emplace` exist in the first place.
this is the exact same issue
this is exactly why i mentioned it
emplace is a library, it doesn't solve anything
it solves people's addiction to "import" things
if you tell people they need to import package to to
initialization, then the language is a failure
``.{}`` wins over ``__initialize``
there need to be a movement to stop making syntax such a pain to
write, and make things overall consistent
It's the same with enums
``MyEnumDoingThings myEnumThatINeed =
MyEnumDoingThings.SOMETHING_IS_NOT_RIGHT;``
And now you want to same for everything else
``(*raw1).__initialize(forward!(arg1, arg2));``
more typing! templates!! more long lines!!! more slowness!!!!
More information about the Digitalmars-d
mailing list