Reputation: 1593
Recently there was a discussion about adding Extension Property to Nemerle language. But the syntax is unclear.
Updated proposed syntax:
module MExtension
{
[ExtensionProperty(string)] public StringProp : int { get; set; }
[ExtensionProperty(int)] public IntProp : string { get { "abc" } }
}
module MTest
{
F() : void
{
def x : int = "ab".StringProp;
"abc".StringProp = 100;
def y : string = 10.IntProp;
}
}
Note: module == static class
What do you think ?
Upvotes: 2
Views: 286
Reputation: 6101
I don't like it because of duplication:
So the refactoring can be slightly complicated. How about the following approach?
module MExtension
{
property PropName(this arg : Type1) : Type2
{
get
{
...
}
set
{
... = value
}
}
}
or even autoproperty:
module MExtension
{
property PropName(this arg : Type1) : Type2 { get; set; }
}
Upvotes: 0