[nem-en] Declaring Properties in the constructor - ala Boo
d
d at hell.art.pl
Sat Sep 30 15:30:44 CEST 2006
On Sep 29, 2006, at 10:07 PM, Michal Moskal wrote:
> On 9/29/06, Mark Haniford <markhaniford at gmail.com> wrote:
>
>> 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).
Right, the idea is nice. Quite useful. But I see Nemerle is
beginning to overflow with features, which will be understandable to
some and not quite so clear to others. My suggestion would be then,
to give features that are not commonly known (be it in the OO, or the
FP world) a clear, descriptive syntax. For example:
def c = Cons (1, 2, x = "foo", initializers (y = "bar", z = "baz"));
This seems clear to me, but maybe you can think of something
better. You know, along those lines.
cheers,
d
--
https://hell.art.pl == terror.org.pl == terror.icm.edu.pl/~d/gpg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
Url : /mailman/pipermail/devel-en/attachments/20060930/6e709627/PGP.bin
More information about the devel-en
mailing list