[nem-en] Expression problem, expressiveness of Nemerle generics
Sandro Magi
smagi at higherlogics.com
Fri May 11 20:23:26 CEST 2007
Kamil Skalski wrote:
>> augment them? In particular, overly-restrictive generic constraints are
>> the root of the problem I encountered with the C# implementation, and
>> I'm wondering whether a Nemerle implementation might be safer (at least
>> for Nemerle users).
>>
>
> To remove them you would need to modify compiler to use its own
> constraints logic instead of native .NET generics, which I'm not
> really sure is worth doing.
I figured as much. I imagine a language with this additional
expressiveness could decorate the class and methods with attributes that
encode the constraints. Seems this would force the language to employ
casting and return 'object' everywhere for the cases that generics can't
safely express.
> Otherwise you could just hide the needed
> casts and type-checks behind generated code - thus making it more safe
> for users.
Yes, that's what I currently do; it's just more awkward than the
standard visitor pattern, and not very "functional".
> I think that building a nicer syntax and generating parts of the
> boilerplate code by macros would be quite interesting extension of
> your implementation :)
That would be very nice for Nemerle users, no doubt. Thanks for taking
the time to look at this. :-)
Sandro
More information about the devel-en
mailing list