Skip to content

Add TDict doc entry and add a small summary#99

Merged
pjaap merged 2 commits into
masterfrom
doc/tdict
Oct 24, 2025
Merged

Add TDict doc entry and add a small summary#99
pjaap merged 2 commits into
masterfrom
doc/tdict

Conversation

@pjaap

@pjaap pjaap commented Oct 22, 2025

Copy link
Copy Markdown
Member

@Da-Be-Ru and I wondered about the magic behind the scenes of the type dictionary system.
We thought it might help future us and other people if we add a small summary of what is going on.
Moreover, this is now a top level doc entry, since new user also ask why we access grid components by type.

@j-fu I removed the CairoMakie compat in the docs. Was there a reason for that? It does not work with Julia 1.12 and I do not like compats in docs.

@j-fu

j-fu commented Oct 23, 2025

Copy link
Copy Markdown
Member

Basically ok for me, go ahead.

Generally, I am not 100% happy with the TDict stuff which emerged relatively early in my Julia career. Clearly one could create singletons from all the types and pass these. So like const Coordinates=CoordinatesType() etc.

Another possibility would dictionaries with Val{::Symbol} as key types. This also would allow to dispatch on e.g. ::Val{:NodeCells} and with a bit more voodoo this could be written (since Julia 1.8) as grid.NodeCells.

See voodoo here...

In fact, as the last part of the example shows, we might be able to do this even without breaking...

@j-fu

j-fu commented Oct 23, 2025

Copy link
Copy Markdown
Member

But: JuliaLang/julia#25750 (comment)

I think it is very useful when reading code to be able to distinguish between direct struct field access and syntactic sugar for a function call."

@pjaap pjaap merged commit 34f85ad into master Oct 24, 2025
14 checks passed
@pjaap

pjaap commented Oct 24, 2025

Copy link
Copy Markdown
Member Author

Interesting discussion in 25750...

Clearly one could create singletons from all the types and pass these. So like const Coordinates=CoordinatesType() etc.

I agree. I also used singletons in another project intuitively. But this does not change the general logic, does it? We only get rid of the Type{...} annotations. However, this would probably fix #94 .

TBH: up to the discussion with @Da-Be-Ru on the TDict, the purpose was not completely clear to me. Now I fully understood the idea. I'll let this sink in for some time and then we can discuss a possibly "better" approach.

@pjaap pjaap deleted the doc/tdict branch May 19, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants