User loginNavigation |
Structural Typing in .NET through Type-ParametersI have a question associated to some functionality I want to implement in a compiler for .NET. I originally called this 'duck typing' but after reading up more on type systems, that's incorrect. The basic idea follows what's called structural typing; the main aim is to implement such a thing through type-parameter extensions. Naturally since this isn't something implemented at the low-level Common Intermediate Language, I'll have to handle the functionality myself. Essentially you would define the requirements of a given type-parameter on the constraints of that type. The information would be encoded within a series of interfaces which represent the various member constraints. Call sites that utilize the functionality would emit a type for every generic closure (a specific set of types closed in a specific instance vs. the full set of possible types, is this term proper?) of the generic type they use. I could go into details of how this will be handled on a functional level, but that's for a different discussion. The question I have is: is structural typing useful for .NET Languages? The concept would be statically typed in that the compiler generates the corresponding types to handle call dispatch. Assemblies built using a constraint-ignorant compiler (like C#) would be processed at run-time when the first call is made. This isn't 'dynamic' typing for the obvious fact that no change to the run-time state of the assembly can affect the object-structure linking and subsequent call dispatch. Insight welcome. By Alexander Morou at 2011-07-09 02:17 | LtU Forum | previous forum topic | next forum topic | other blogs | 5270 reads
|
Browse archives
Active forum topics |
Recent comments
23 weeks 1 day ago
23 weeks 1 day ago
23 weeks 1 day ago
45 weeks 3 days ago
49 weeks 4 days ago
51 weeks 2 days ago
51 weeks 2 days ago
1 year 1 week ago
1 year 6 weeks ago
1 year 6 weeks ago