Please remove/split struct or array[struct] definitions

Place to report issues and suggest improvements to the API documentation.
User avatar
PennyJim
Fast Inserter
Fast Inserter
Posts: 108
Joined: Wed Jan 18, 2023 3:49 am
Contact:

Please remove/split struct or array[struct] definitions

Post by PennyJim »

There's times I want to annotate a function to only take/return the struct, not the array possibility. The definition for the type being tied to it, is annoying.

I'd much rather the places that use it hold the responsibility to do the type or array[struct] definition.
On the other hand, you can make a whole different type for it like StatelessVisualisations.

As I understand how the json format works, this would also optimize its size. While not that important, it's still a positive :]
(though the solution for size would be a special complex type)
User avatar
Therenas
Factorio Staff
Factorio Staff
Posts: 301
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

Re: Please remove/split struct or array[struct] definitions

Post by Therenas »

After consideration, we decided that we won't change this format. It would indeed be more straightforward to use the type that way, but it'll add a layer of indirection to the JSON/website that'll make it harder to understand and use.

You'll have to restrict the type yourself in code when you need that. Or maybe FMTK could get some sort of support for making this easier? I'm not sure.
curiosity
Filter Inserter
Filter Inserter
Posts: 637
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: Please remove/split struct or array[struct] definitions

Post by curiosity »

Or the docs builder could detect and handle the type or array of type case.
User avatar
Therenas
Factorio Staff
Factorio Staff
Posts: 301
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

Re: Please remove/split struct or array[struct] definitions

Post by Therenas »

You mean the docs builder on our side?
curiosity
Filter Inserter
Filter Inserter
Posts: 637
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: Please remove/split struct or array[struct] definitions

Post by curiosity »

Yes.

edit: Actually, from my cursory search, the docs are full of "type or array of type" cases. It's quite clear and has never caused any difficulty, at least for me. IDK what types the OP means, but they absolutely could (and should) be reworked. And I agree with you that things like StatelessVisualisations are the worst. They should also be changed to "type or array of type" at the place of use. Will make it more consistent.
User avatar
Therenas
Factorio Staff
Factorio Staff
Posts: 301
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

Re: Please remove/split struct or array[struct] definitions

Post by Therenas »

Oh you made me realize I only considered this part of the proposal:
On the other hand, you can make a whole different type for it like StatelessVisualisations.
and not this one:
I'd much rather the places that use it hold the responsibility to do the type or array[struct] definition.
This would be tedious and confusing to do manually on our side, but there are ways to automate it for the best of both worlds. We'll be working on that, and I'll move this back to unresolved until then.
Post Reply

Return to “Documentation Improvement Requests”