Why does IParseable<T> place the T : IParseable<T> constraint on T? What is this recursive constraint needed for?

Why does IParseable<T> need to be recursive?
625 Views Asked by Marcin At
1
There are 1 best solutions below
Related Questions in C#
- Passing arguments to main in C using Eclipse
- kernel module does not print packet info
- error C2016 (C requires that a struct or union has at least one member) and structs typedefs
- Drawing with ncurses, sockets and fork
- How to catch delay-import dll errors (missing dll or symbol) in MinGW(-w64)?
- Configured TTL for A record(s) backing CNAME records
- Allocating memory for pointers inside structures in functions
- Finding articulation point of undirected graph by DFS
- C first fgets() is being skipped while the second runs
- C std library don't appear to be linked in object file
- gcc static library compilation
- How to do a case-insensitive string comparison?
- C programming: Create and write 2D array of files as function
- How to read a file then store to array and then print?
- Function timeouts in C and thread
Related Questions in RECURSION
- Needing a private and public method for the same recursive function
- Recursive function in PHP function : how to prevent return value?
- Json implicit format with recursive class definition
- java update all children in list
- recursively editing member variable: All instances have same value
- Editing pseudo_encrypt PostgreSQL function with Recurrsion to Avoid Certain IDs
- How to copy elements from array one to array two using recursion?
- create_progress_bar in recursive functions in R
- How to check that all values are equal in array using recursion?
- String List of filepaths to structured object
- FIFO Stock Valuation Through CTE-Recursion
- Recursion - nth element from last in a linkedlist
- Parsing user entered int into digits not working C++
- reverse a linked list using recursion error
- How to find Relationships between Objects
Related Questions in INTERFACE
- C++ inheritance, interfaces
- Multiple service contract inter-commnication
- Passing Variables from VBA to R-Script
- Static interface equivalent C#
- What text (in English) should I use when asking the user to overwrite a document?
- Java generic class that contains an instance of implementation of generic interface
- HuggableInterface in PHP and PSR-8
- How do I define constants that must be overridden inside an interface?
- Symfony : is there a best practice about the directories' name including traits and interfaces?
- How to design structure with modifiable fields?
- Why introducing Autocloseable instead of extending the possible exceptions in Closeable
- CI accessing property on interface
- C# list of "Type" that implements specific interface
- ResultTransformer interface in java
- How can I guarantee that a class that implements an interface also extends a class?
Related Questions in C#-11.0
- Passing arguments to main in C using Eclipse
- kernel module does not print packet info
- error C2016 (C requires that a struct or union has at least one member) and structs typedefs
- Drawing with ncurses, sockets and fork
- How to catch delay-import dll errors (missing dll or symbol) in MinGW(-w64)?
- Configured TTL for A record(s) backing CNAME records
- Allocating memory for pointers inside structures in functions
- Finding articulation point of undirected graph by DFS
- C first fgets() is being skipped while the second runs
- C std library don't appear to be linked in object file
- gcc static library compilation
- How to do a case-insensitive string comparison?
- C programming: Create and write 2D array of files as function
- How to read a file then store to array and then print?
- Function timeouts in C and thread
Related Questions in .NET-GENERIC-MATH
- How do I properly use INumber in .NET 7 in F#?
- C# 11 - What have we gained by adding IAdditionOperators to this method?
- Int32.Min vs Int32.MinMagnitude
- How to have a generic variable to INumber in .NET 7?
- Adding operator support to interfaces (Preview Feature in .NET 6)
- How can I use IAdditionOperators<,,> from .NET 6 preview 7?
- Resolving Operator '+' cannot be applied to operand of type 'T' and 'T'
- How to generate constant values with generic math
- How can I do simple math with a generic INumber in .NET 7 / C#11?
- Generic math how to cast from INumber to a "concrete" type (int/double/etc)
- Designing generic types with constraints on generic math interfaces
- Why does IParseable<T> need to be recursive?
- Is it possible to define an operator that accepts a parameter of a generic numerical type different than the base class?
- How to obtain an "accurate", unscaled IEEE-754 floating point number in C#
- IFloatingPoint missing ReadSignificandLittleEndian and other readers
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
This is so called Curiously_recurring_template_pattern (CRTP) and as far as I understand it is not strictly required (and actually it can't enforce the "correct" behaviour) but as mentioned in the Preview Features in .NET 6 – Generic Math article it's usage is a hint to support one of the quite important scenarios for static abstract interface members calls - using it via generic interfaces:
Let's imagine the following interface:
and next method:
If we implement next classes pair:
Then next call will not compile:
And while CRTP does not prevent from "incorrect" usage (i.e.
class MyClass1 : IParsable<MyClass1>will allowclass MyClass : IParsable<MyClass1>, as far as I remember there is no language construct to enforce such behaviour) it is heavily hinting on the desired usage.Note that
class MyClass : IParsable<MyClass1>can be used in similar method but it becomes quite clumsy (partly due to specifics of C# generic types inference):Post from Stephen Cleary discussing CRTP.
UPD
There was a breaking change between .NET 6 and .NET 7 -
System.IParseablewas renamed toSystem.IParsable