[nem-en] Declaring Properties in the constructor - ala Boo
Mark Haniford
markhaniford at gmail.com
Fri Sep 29 22:50:56 CEST 2006
And just to follow up with what I just wrote, a "with" macro would be more
flexible than Boo's no-argument constructor because you could still have
mandatory constructor arguments and then supply the Property values in the
with clause.
On 9/29/06, Mark Haniford <markhaniford at gmail.com> wrote:
>
> I was wondering if ":" would be problematic for the arguments.
> NoiseEHC's suggestion of a with or init macro seems pretty nice:
>
> e.g. def window = Window() with Width = 800, Height = 600, Title =
> "Window";
>
> Is that macroable?
>
> On 9/29/06, Michal Moskal <michal.moskal at gmail.com> wrote:
>
> > 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ł
> >
> > _______________________________________________
> > https://nemerle.org/mailman/listinfo/devel-en
> >
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /mailman/pipermail/devel-en/attachments/20060929/4b71f8e9/attachment-0001.html
More information about the devel-en
mailing list