Property Enhancement
Monkey Forums/Monkey Programming/Property Enhancement
| ||
| Would it be possible to change the Property keyword to help remove a lot of boilerplate code? At the moment, this is how I would define a property: Private
Field someField:Int
Public
Method SomeField:Int() Property
Return someField
End
Method SomeField:Void(someField:Int) Property
Self.someField = someField
EndIt'd be nice if we could do something like this to automatically generate those methods: Private Field someField:Int Property Which will generate those methods (notice I use the same name as the field but with uppercase first letter). If people preferred their own property names and wanted read only, etc. you could do something like this: Private Field someField:Int Property(MyProperty) Get Which would generate: Public
Method MyProperty:Int() Property
Return someField
EndBut not generate the setter. Objective-C and I believe C# already have something similar. Edit: This example is closer to Objective-C's @property and @synthesize than C#'s { get{} set{} } stuff. |
| ||
| Bump. |