[nem-en] Declaring Properties in the constructor - ala Boo
Michal Moskal
michal.moskal at gmail.com
Fri Sep 29 22:07:27 CEST 2006
On 9/29/06, Mark Haniford <markhaniford at gmail.com> wrote:
> Hi,
>
> I think one of the neat features of Boo is that you can declare property
> values in the constructor:
> http://boo.codehaus.org/Part+09+-+Methods#Part09-Methods-DeclaringPropertiesintheConstructor
>
> e.g. window = Window (Width: 800, Height: 600, Title: "Window"); // where
> Width, Height, and Title are all public properties in the class Window
>
> This feature seems very convienent to me. It would probably be pretty easy
> to write a macro to do it too, e.g. window = Construct(SomeClass, Width:
> 800, Height: 600, Title: "Window");
>
> But would it be more convenient to have it in the compiler proper? In the
> case of constructors with arguments, you could disallow it, or have optional
> property arguments after the defined constructor arguments
I personally like it -- that would be consistant with custom attributes.
The only problem I see is proper syntax. ':' cannot be used, as it is
typecast operator. On the other hand, plain '=' conflicts with named
parameters (I would rather avoid deciding if something is a property
or named parameter based on context).
--
Michał
More information about the devel-en
mailing list