Continuing with the series "Hidden features" I think it's time to Delphi Prism. I believe that's a great way to encourage the development of delphi prism, is that we all share what we discovered in the daily use of this great language.
Bye.
Continuing with the series "Hidden features" I think it's time to Delphi Prism. I believe that's a great way to encourage the development of delphi prism, is that we all share what we discovered in the daily use of this great language.
Bye.
Most definitely interface delegation, it's the part I miss the most in C#.
I tried to explain it a bit more detailed in this prismwiki article
Or that one can constrain generic type parameters to be Enums or Delegates. (Which C# simply won't allow)
There's more to it, obviously. But the other useful features it has over C# are already all over the marketing stuff from RO and CG. So not really hidden. ;-)
First of all: Class contracts. It's on the Oxygene language since it was still called Chrome and will find it's way into C# only with the upcoming release of .NET 4.0.
Then it's the parallel support & future variables. Just by using declarations you can order to execute certain methods in background threads.
Last, but not least, I love the AOP feature 'Cirrus'. Actually it's used for AOP, but I see it more as an interface to write plugins for the compiler that will be executed on defined locations in your code.
Auto-notifying properties.
This:
type Foo = public class
public property Name : String; notify;
end;
Is equivalent to this in C#:
public class Foo : INotifyPropertyChanged, INotifyPropertyChanging {
private string _name;
public event PropertyChangingEventHandler PropertyChanging;
public event PropertyChangedEventHandler PropertyChanged;
protected OnPropertyChanging(PropertyChangingEventArgs e) {
if (PropertyChanging != null) {
PropertyChanging(this, e);
}
}
protected OnPropertyChanged(PropertyChangedEventArgs e) {
if (PropertyChanged != null) {
PropertyChanged(this, e);
}
}
public string Name {
get { return _name; }
set {
if (value != _name) {
OnPropertyChanging(new PropertyChangingEventArgs("Name"));
_name = value;
OnPropertyChanged(new PropertyChangedEventArgs("Name"));
}
}
}
}