We all agree that nullable properties need to be addressed.
Now why just don't discuss a possible syntax and move on?
Initializers, parenthesis around unsetters, etc can all be detailed and
discussed later.

Here are the proposed syntaxes:

public DateTime? $date {
  get { ... }
  set { ... }
}

public DateTime $date = null {
  get { ... }
  set { ... }
}

public DateTime $date {
  get { ... }
  set($value = null) { ... }
}

public $date {
  get { ... }
  set(DateTime $value = null) { ... }
}


Now choose your options from 1-4 and move on...
Sometimes you truly love to discuss instead of act. Tsc, tsc, tsc...


Cheers,


On Thu, Jan 10, 2013 at 7:24 PM, Lazare Inepologlou <linep...@gmail.com>wrote:

> Nikita,
>
>
> 2013/1/10 Nikita Popov <nikita....@gmail.com>
>
> > On Tue, Jan 8, 2013 at 7:03 PM, Steve Clay <st...@mrclay.org> wrote:
> >
> > > On 1/8/13 2:56 AM, Christian Stoller wrote:
> > >
> > >> But the way 'nullable' properties are defined is not very intuitive
> and
> > >> unclean, in my opinion. Stas has already mentioned that.
> > >> `public DateTime $date = NULL;` // this looks like the property is
> > >> initialized with null, but it does not show that the property is
> > 'nullable'
> > >>
> > >
> > > Much agreed. After instantiation, these shouldn't behave differently:
> > >
> > > public     $foo = null;
> > > public Foo $foo = null;
> > >
> > > Sure, method signatures have special behavior based on a default value,
> > > but IMO:
> > > 1. those semantics aren't entirely intuitive to begin with
> > > 2. property initializers aren't method sigs
> > > 3. the semantics would apply only to some properties
> > >
> > >
> > >
> > >       public DateTime? $date;
> > >>
> > >> In C# the question mark after a type is a short hand for a generic
> > >> Nullable type.
> > >>
> > >
> > > I like that it's an established practice of doing exactly what we're
> > > trying to do.
> > >
> > > Could we not just make it obvious?:
> > >
> > > public Foo|null $foo;
> > >
> >
> > I updated the RFC to include the current state regarding default value
> and
> > nullability:
> >
> >
> https://wiki.php.net/rfc/propertygetsetsyntax-alternative-typehinting-syntax
> >
> > One question that still needs to be discussed is what syntax regarding
> > parentheses we want to use if this makes it. Currently both set { } and
> > set($foo) { } style accessors are supported. Do we want to keep those two
> > with the new syntax?
> >
> > Nikita
> >
> > PS: I hope I'm not interrupting all those heated annotations discussion
> too
> > much ^^
> >
>
>
>
> In the RFC, one thing is not clear: How to provide typehints for nullable
> properties that actually have accessors.
>
> Will it be like this?
>
> public DateTime $date = null {
>   get { ... }
>   set { ... }
> }
>
>
>
>
> Lazare INEPOLOGLOU
> Ingénieur Logiciel
>



-- 
Guilherme Blanco
MSN: guilhermebla...@hotmail.com
GTalk: guilhermeblanco
Toronto - ON/Canada

Reply via email to