June 30, 2022

On Thursday, 30 June 2022 at 13:47:47 UTC, Adam Ruppe wrote:

>

Or similar. The key point is the magic file template builds an array of all files in its static constructors which you then process later at runtime.

I had no idea templates could contain static constructors!
Did I miss some piece of documentation?
Thanks a lot, this basically behaves as I would hope!

The only part about this that seems a little disappointing is it still having to work at run-time. I'm also curious what this would create in the application. Are you left with potentially dozens if not hundreds of useless functions in the code? The static this methods are all separate instances correct?

June 30, 2022
On Thursday, 30 June 2022 at 14:38:30 UTC, HuskyNator wrote:
> Did I miss some piece of documentation?

Key concept is a template is just another aggregate...

> I'm also curious what this would create in the application. Are you left with potentially dozens if not hundreds of useless functions in the code? The `static this` methods are all separate instances correct?

No, it combines them all into a single one per-module in the compiler. Then the modules are combined at run time by walking an array of them and running each function in turn.
June 30, 2022
On Thursday, 30 June 2022 at 14:45:49 UTC, Adam D Ruppe wrote:
> On Thursday, 30 June 2022 at 14:38:30 UTC, HuskyNator wrote:
>> Did I miss some piece of documentation?
>
> Key concept is a template is just another aggregate...

I'm not sure saying 'its self-evident' is a great way of writing documentation.
It's not evident to me, and none of the tutorials / documentation seems to even mention it.
June 30, 2022
On Thursday, 30 June 2022 at 15:37:20 UTC, HuskyNator wrote:
> It's not evident to me, and none of the tutorials / documentation seems to even mention it.

I talked about it in my book, but yeah, it could probably use a call out somewhere else.
July 01, 2022

On Thursday, 30 June 2022 at 15:49:07 UTC, Adam D Ruppe wrote:

>

I talked about it in my book, but yeah, it could probably use a call out somewhere else.

The github page on the specs does not seem to have an issues section on github.
Is there any place to suggest this addition?


On a similar note the language spec does not put .capacity in the Array properties table (https://dlang.org/spec/arrays.html#array-properties). My ide does not even suggest it exists (code-d in vscode).

July 01, 2022
On Friday, 1 July 2022 at 12:13:03 UTC, HuskyNator wrote:
> Is there any place to suggest this addition?

the bugzilla issues.dlang.org

> _On a similar note the language spec does not put `.capacity` in the Array properties table (https://dlang.org/spec/arrays.html#array-properties).

try my search engine

dpldocs.info/capacity

it will bring up

http://druntime.dpldocs.info/object.capacity.html

I think this isn't technically defined by the language and is a pure library construct. Just the auto-imported library thing/

> My ide does not even suggest it exists (code-d in vscode)._

can't trust ides tbh.
July 01, 2022
On Friday, 1 July 2022 at 12:24:55 UTC, Adam D Ruppe wrote:
> On Friday, 1 July 2022 at 12:13:03 UTC, HuskyNator wrote:
> I think this isn't technically defined by the language and is a pure library construct. Just the auto-imported library thing/

It is references, but hidden in the text somewhere. (also note it seems to be applicable to static arrays as well, though it yields 0) https://dlang.org/spec/arrays.html#dynamic-arrays:~:text=To%20guarantee%20copying%20behavior%2C%20use%20the%20.dup%20property%20to%20ensure%20a%20unique%20array%20that%20can%20be%20resized.%20Also%2C%20one%20may%20use%20the%20.capacity%20property%20to%20determine%20how%20many%20elements%20can%20be%20appended%20to%20the%20array%20without%20reallocating.


July 01, 2022
On Friday, 1 July 2022 at 12:44:01 UTC, HuskyNator wrote:
> (also note it seems to be applicable to static arrays as well, though it yields 0)

I'm assuming this isn't part of a library in any case.
July 01, 2022
On Friday, 1 July 2022 at 12:47:49 UTC, HuskyNator wrote:
> On Friday, 1 July 2022 at 12:44:01 UTC, HuskyNator wrote:
>> (also note it seems to be applicable to static arrays as well, though it yields 0)
>
> I'm assuming this isn't part of a library in any case.

Never mind, I hadn't considered UFC.
Didn't make that out from the documentation either.
Apologies for the slight post overdose 😅
1 2
Next ›   Last »