Re: [PHP-DEV] Re: [RFC] Importing namespaced functions

2013-08-09 Thread Leigh
On Aug 8, 2013 9:31 PM, Daniel Bingham daniel.bing...@ellislab.com
wrote:

 Hey Igor,

 I love the RFC, but how about:

 use bar\baz() as baz;

 As an alternative to use function.  Still new syntax, but a little less
 wordy.

The parenthesis add the feeling that it should be evaluated imho, I.e. the
result of that function should be used as baz. That could possibly lead to
confusion. I know you're suggesting as an additional syntax not
alternative, but I don't get good vibes from it.

Also might not even be possible due to how the parser handles parenthesis,
but I'd have to look over the parser grammar to be sure.

But another +1 from me on the RFC as a whole. Now its there I can't believe
it took so long.


Re: [PHP-DEV] Re: [RFC] Importing namespaced functions

2013-08-09 Thread Daniel Bingham
Hey Leigh,

I disagree that it suggests evaluation, but it could easily be a personal
interpretation thing.  In my interpretation, when looking at use
statements, I know nothing is being evaluated.  Symbols are being imported
into the namespace.  How likely is it that baz returns something that can
be imported as a symbol?   Would that even make sense as a feature,
importing the results of an evaluated function? Actually, given those two
questions, I can see how it would cause confusion if your initial
interpretation is that it is being evaluated.

For me, the parenthesis make it easier to read when scanning code.  When
scanning use statements, I'm not scanning the keywords, I'm scanning the
included names.  It's easier to look for parenthesis to denote functions,
it makes them stand out from the class names more. As in this example below:

use foo\bar\baz as baz;
use bar\foo\baz() as baz;
use bar\baz as bbaz;
use baz\foo\bar as bar;
use foo\bar() as bar;
use baz\bar as bbar;

Where as with use function I'd have to check back to the beginning of the
phrase to determine whether I was looking at a class name or function.

use foo\bar\baz as baz;
use function bar\foo\baz as baz;
use bar\baz as bbaz;
use baz\foo\bar as bar;
use function foo\bar as bar;
use baz\bar as bbar;

I think the difference mostly comes down to personal preference, and would
be somewhat alleviated by syntax highlighting.

Also, I have no knowledge of the PHP parser, so I have no idea how easy or
hard this would be to implement.

Daniel




On Fri, Aug 9, 2013 at 1:16 PM, Leigh lei...@gmail.com wrote:


 On Aug 8, 2013 9:31 PM, Daniel Bingham daniel.bing...@ellislab.com
 wrote:
 
  Hey Igor,
 
  I love the RFC, but how about:
 
  use bar\baz() as baz;
 
  As an alternative to use function.  Still new syntax, but a little less
  wordy.

 The parenthesis add the feeling that it should be evaluated imho, I.e. the
 result of that function should be used as baz. That could possibly lead to
 confusion. I know you're suggesting as an additional syntax not
 alternative, but I don't get good vibes from it.

 Also might not even be possible due to how the parser handles parenthesis,
 but I'd have to look over the parser grammar to be sure.

 But another +1 from me on the RFC as a whole. Now its there I can't
 believe it took so long.



[PHP-DEV] Re: [RFC] Importing namespaced functions

2013-08-08 Thread Igor Wiedler
Hi everyone,

I just wanted to bump this topic, since there's not been much feedback during 
the last few weeks. Comments on the patch are also welcome.

RFC: https://wiki.php.net/rfc/use_function
Patch: https://github.com/php/php-src/pull/388

Thanks,

Igor


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



AW: [PHP-DEV] Re: [RFC] Importing namespaced functions

2013-08-08 Thread Robert Stoll
Hi Igor,

Personally I like your RFC. I also like the fact that it is possible to
replace built-in functions where desired by declaring a corresponding use
statement.
I do not see aliases in your RFC but I guess it would also be possible to
write things like: use function foo\bar as foo;

cheers,
Robert

-Ursprüngliche Nachricht-
Von: Igor Wiedler [mailto:i...@wiedler.ch] 
Gesendet: Donnerstag, 8. August 2013 14:29
An: internals@lists.php.net
Betreff: [PHP-DEV] Re: [RFC] Importing namespaced functions

Hi everyone,

I just wanted to bump this topic, since there's not been much feedback
during the last few weeks. Comments on the patch are also welcome.

RFC: https://wiki.php.net/rfc/use_function
Patch: https://github.com/php/php-src/pull/388

Thanks,

Igor


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



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



Re: [PHP-DEV] Re: [RFC] Importing namespaced functions

2013-08-08 Thread Igor Wiedler
Yes, aliases are supported just as you would expect. I will add an example to 
the RFC.

Thanks,

Igor

On Aug 8, 2013, at 8:17 PM, Robert Stoll rst...@tutteli.ch wrote:

 Hi Igor,
 
 Personally I like your RFC. I also like the fact that it is possible to
 replace built-in functions where desired by declaring a corresponding use
 statement.
 I do not see aliases in your RFC but I guess it would also be possible to
 write things like: use function foo\bar as foo;
 
 cheers,
 Robert


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



Re: [PHP-DEV] Re: [RFC] Importing namespaced functions

2013-08-08 Thread Michael Wallner
On 8 August 2013 14:29, Igor Wiedler i...@wiedler.ch wrote:
 Hi everyone,

 I just wanted to bump this topic, since there's not been much feedback during 
 the last few weeks. Comments on the patch are also welcome.

 RFC: https://wiki.php.net/rfc/use_function
 Patch: https://github.com/php/php-src/pull/388


I like it. It improves the state for non-OOP in PHP.

-- 
Regards,
Mike

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



Re: [PHP-DEV] Re: [RFC] Importing namespaced functions

2013-08-08 Thread Daniel Bingham
Hey Igor,

I love the RFC, but how about:

use bar\baz() as baz;

As an alternative to use function.  Still new syntax, but a little less
wordy.  I have nothing for use const, but use const feels more natural
to me than use function does.

Just an idea for pondering!

Dan



On Thu, Aug 8, 2013 at 2:44 PM, Michael Wallner m...@php.net wrote:

 On 8 August 2013 14:29, Igor Wiedler i...@wiedler.ch wrote:
  Hi everyone,
 
  I just wanted to bump this topic, since there's not been much feedback
 during the last few weeks. Comments on the patch are also welcome.
 
  RFC: https://wiki.php.net/rfc/use_function
  Patch: https://github.com/php/php-src/pull/388
 

 I like it. It improves the state for non-OOP in PHP.

 --
 Regards,
 Mike

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