On Fri, 2008-01-04 at 12:37 -0500, Robert Cummings wrote:
> On Fri, 2008-01-04 at 18:23 +0100, Pierre wrote:
> > On Jan 4, 2008 6:20 PM, Marcus Boerger <[EMAIL PROTECTED]> wrote:
> > > Hello Pierre,
> > >
> > >   we never accepted this as a pro argument. Infact we often saw the
> > > necessaity to highlight something is optional to vote against it. We do 
> > > this
> > > for a reason. That is we only want to support mainstream features.
> > 
> > My point of view is that this feature should be a mainstream feature.
> > To make it optional was to lower the issues for those who don't care
> > about argument strictness. We did not give them this choice for the OO
> > strictness.
> 
> IMHO, optionally inclusion of type hinting for functions/methods can
> only be a boon to code quality and readability. IMHO when a type hint is
> provided and a parameter doesn't match the type hint then I think a
> fatal error should occur. This forces the user of the function that has
> type hinting to ensure their data is of the correct type. This prevents
> accidental wrong data conversion. However, I see the other side of the
> coin too where automatic type conversion could be desirable also.
> Perhaps a mixed solution would be viable?
> 

I don't think conversion would make sense here, as PHP will
automatically convert the variable before you use it anyway. Hinting
will prevent mistakes, conversion will just try to ignore them, which is
what PHP does already.

> <?php
> 
> function foo( require int $a, require string $b ){}
> 
> foo( '5', 'bleh' );  // <-- fatal error
> 
> ?>
> 
> Contrast versus:
> 
> <?php
> 
> function foo( int $a, string $b ){}
> 
> foo( '5', 'bleh' );  // <-- no exception or error $a in foo() will
>                      //     be type int (automatic conversion)
> 
> ?>
> 
> Versus (still allowed default style):
> 
> <?php
> 
> function foo( $a, $b ){}
> 
> foo( '5', 'bleh' );  // <-- no exceptions or type conversions
> 
> ?>
> 
> Thoughts?
> 
> Cheers,
> Rob.
> -- 
> ...........................................................
> SwarmBuy.com - http://www.swarmbuy.com
> 
>     Leveraging the buying power of the masses!
> ...........................................................
> 

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to