❔ a question about generics
vague title because I don't know how would I word it
this might be a weird question, but how could I achieve something like this:
where the provided T type might change the
message
type, for example, if Child
was Parent<int>
then Welcome<Child>() would for an integer15 Replies
doesnt that already work as written
Windows10CE#8553
REPL Result: Failure
Exception: CompilationErrorException
Compile: 644.114ms | Execution: 0.000ms | React with ❌ to remove this embed.
oh, no
i misread
the answer is associated types
😅
this is not real code, I'm just prototyping
which C# does not yet have
sad
thanks for answering :)
essentially associated types would let you do
not the real syntax of course, but shows the idea at least
this looks really nice.
I will have to find a walkaround for my issue
sorry, the lang design people call them existential types https://github.com/dotnet/csharplang/issues/5556
GitHub
[Proposal]: Practical existential types for interfaces · Issue #555...
Practical existential types for interfaces Proposed Prototype: Not Started Implementation: Not Started Specification: Not Started Intro Previously I proposed adding some form of existential types t...
associated types is the Rust (and I believe Haskell?) name for the same concept
Retax#0813
REPL Result: Success
Compile: 575.137ms | Execution: 83.620ms | React with ❌ to remove this embed.
Starlk#3366
REPL Result: Failure
Exception: CompilationErrorException
Compile: 645.970ms | Execution: 0.000ms | React with ❌ to remove this embed.
Oooo
This is pretty neat
Nice idea
Thanks!
I wish the feature windows10ce mentioned becomes real
yeah I assumed they didn't want that
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.