[nem-en] Declaring Properties in the constructor - ala Boo

Mark Haniford markhaniford at gmail.com
Fri Sep 29 21:52:36 CEST 2006


That's not the same thing.  In Boo, you can have a default constructor (or
one with no arguments), and then supply as many property values as you see
fit at instantiation.  Your example just shows named parameters, which is
nice, but you still have to define your constructor as normal, and at
instantiation you still have to supply the same number of arguments.  Notice
in my example, that I only defined the constructor with an int being passed
in, and the string is an optional property value.  See the link I posted
earlier for the Boo example.


On 9/29/06, vc <vc at rsdn.ru> wrote:
>
>    > class SomeClass
>    > {
>    >     [Accessor(AnInt, flags=WantSetter)]
>    >     private mutable _an_int : int;
>    >
>    >     [Accessor(AString, flags=WantSetter)]
>    >     private mutable _a_string : string;
>    >
>    >
>    >     public this(i : int) {
>    >         AnInt = i;
>    >     }
>    > }
>    >
>    > sc = SomeClass(3, AString: "hello");
>
>    Nemerle already support this:
>
>    using Nemerle.Utility;
>
>    public class A
>    {
>      public this(test : string)
>      {
>        _test = test;
>      }
>
>      [Accessor] _test : string;
>    }
>
>    def a = A(test = "test");
>    _ = a;
>
>    And mach more! :)
>
>    using Nemerle.Utility;
>
>    [Record]
>    public class A
>    {
>      [Accessor] test : string;
>    }
>
>    def a = A(test = "test");
>    _ = a;
>
>
> _______________________________________________
> https://nemerle.org/mailman/listinfo/devel-en
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /mailman/pipermail/devel-en/attachments/20060929/83930ed5/attachment.html


More information about the devel-en mailing list