[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Vala] default-property-value syntax



On Thu, Mar 6, 2008 at 12:36 AM, Florian Brosch <flo brosch gmail com> wrote:
 > Hi, guys.
 >
 >  A new feature of valac 0.1.8 is a way to set the default-value of
a property:
 >
 >  public int rank {
 >   construct set;
 >   private get;
 >   default ( 5 );
 >  }
 >
 >
 >  We talked about the syntax in #vala. Chipzz and I think that following
 >  looks more appealing:
 >
 >  public int rank {
 >   construct set;
 >   private get;
 >   default = 5;
 >  }
 >

 This triggered my attention too. I haven't seen a language with a
 syntax for this.

 The first thing that crossed my mind was

 public int rank  {
   construct set;
   private get;
  } = 5;
 but that's barely readable when you actually have an implementation
 for getter and setter

 private int _rank = 5;
 public int rank { construct get; private set; };
 would be enough in my opinion.

 On the other hand, since the setter already introduces a keyword,
 'value', one could use:

 public int rank {
   construct set;
   private get;
   value = 5;
  }

 Anyway, if the choice is between the two, I would go for the second
 default = 5
 - more readable (as opposed to optimized c++ initialization code that
 obfuscates i=0 into i(0))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]