Re: Request for comments - new PHP feature: return typing

From: Date: Wed, 26 Jun 2013 15:46:03 +0000
Subject: Re: Request for comments - new PHP feature: return typing
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On Wed, Jun 26, 2013 at 4:48 PM, Johannes Schlüter
<[email protected]>wrote:

> On Wed, 2013-06-26 at 16:40 +0200, Ferenc Kovacs wrote:
>
> > >
> > I think that the return typehints a bit easier topic than the input type
> > hinting(for scalars), because that affects the caller, while return type
> > hinting is more contained: you write the function, you put the return
> > typehint there, if the method tries to return something else, then your
> > code is at fault.
> > So even if we would allow return typehints for scalars that would only
> > affects those functions where the developer opts-in.
>
> So a function author doesn't trust himself and therefore we change the
> language syntax?
>
> johannes
>
>
or not trusting the subsystem that he/she calls, and he/she wants to make a
hard promise about the return value.
I could also mention, that this feature could be used in static analysis
and IDEs(albeit most IDEs out there already supports docblocks).
I'm not saying that this feature is a must, I just wanted to emphasize that
it is a little bit less touchy subject than the (scalar) input typehints.

-- 
Ferenc Kovács
@Tyr43l - http://tyrael.hu


Thread (35 messages)

« previous php.internals (#67885) next »