Re: [PHP-DEV] [VOTE]Call for voting: support use list in foreach

2012-08-18 Thread Nikita Popov
On Sat, Aug 18, 2012 at 6:34 AM, Laruence wrote: > Hi: > This feature introduces list() support in foreach constructs(more > info can be found here: https://wiki.php.net/rfc/foreachlist). > > please vote for this: https://wiki.php.net/rfc/foreachlist#vote Hi Lauruence! Is this vote just fo

Re: [PHP-DEV] [RFC] Generators

2012-08-18 Thread Nikita Popov
On Tue, Aug 14, 2012 at 7:59 PM, Aaron Holmes wrote: > Thanks for clarifying. It makes sense now, considering foreach's behavior > and the generators statefulness allowing what otherwise seems inconsistent. > However, might it make sense to no-op instead of erroring? If generators > allow rewind()

Re: [PHP-DEV] [RFC] Generators

2012-08-18 Thread Derick Rethans
On Sat, 11 Aug 2012, Nikita Popov wrote: > Hi internals! > > I think there already was a lot of discussion on the generators, so > it's time to move to the next step. I'd like to vote on the feature in > two weeks, so this the "announce[ment] on internals@, by the author, > with the intention of

Re: [PHP-DEV] [RFC] Generators

2012-08-18 Thread Nikita Popov
On Sat, Aug 18, 2012 at 2:21 PM, Derick Rethans wrote: > I've some comments how that I've read the RFC: > >> Recognition of generator functions >> >> 1. Any function which contains a yield statement is automatically a >> generator function. >> >> 2. The initial implementation required that generat

Re: [PHP-DEV] Re: Generators in PHP

2012-08-18 Thread Nikita Popov
On Thu, Aug 9, 2012 at 4:49 AM, Sherif Ramadan wrote: >> >> One question, though: It looks based on the voting like finally {} blocks >> are going in. So... what should happen in the following situation: >> >> function stuff() { >> try { >> foreach (range(1, 100) as $i) { >> yield $i;

Re: [PHP-DEV] Re: Generators in PHP

2012-08-18 Thread Nikita Popov
On Thu, Aug 9, 2012 at 4:49 AM, Sherif Ramadan wrote: >> >> One question, though: It looks based on the voting like finally {} blocks >> are going in. So... what should happen in the following situation: >> >> function stuff() { >> try { >> foreach (range(1, 100) as $i) { >> yield $i;

[PHP-DEV] re: removing an item from an array

2012-08-18 Thread Morgan L. Owens
Rasmus Schultz wrote: > I disagree - this is (or should be) a simple, atomic operation... > yet, you've got a function-call, an intermediary variable, a boolean > test, and an unset statement repeating the name of the array you're > deleting from. > > This should be a simple statement or function

Re: [PHP-DEV] [RFC] Generators

2012-08-18 Thread lester
> On Sat, 11 Aug 2012, Nikita Popov wrote: > >> Hi internals! >> >> I think there already was a lot of discussion on the generators, so >> it's time to move to the next step. I'd like to vote on the feature in >> two weeks, so this the "announce[ment] on internals@, by the author, >> with the inten

Re: [PHP-DEV] [RFC] Generators

2012-08-18 Thread Rasmus Lerdorf
On 08/18/2012 10:12 AM, les...@lsces.co.uk wrote: > Since this is yet another area where 'one does not have to use it if one > does not want to' ... FLAGGING to the other users that a function is a > 'special one' rather than just a normal function with a generator function > seems to me just a nec

Re: [PHP-DEV] [RFC] Generators

2012-08-18 Thread Nikita Popov
On Sat, Aug 18, 2012 at 4:12 PM, wrote: > Since this is yet another area where 'one does not have to use it if one > does not want to' ... FLAGGING to the other users that a function is a > 'special one' rather than just a normal function with a generator function > seems to me just a necessity?

Re: [PHP-DEV] removing an item from an array

2012-08-18 Thread Levi Morrison
On Sat, Aug 18, 2012 at 12:42 AM, Alexey Zakhlestin wrote: > > On 16.08.2012, at 0:18, Rasmus Schultz wrote: > >> How come there is no straight-foward obvious way to simply remove a given >> value from an array? > > Well, this sounds like a reason for creating SplSet class > There's already SplO

Re: [PHP-DEV] Inline typecasting / typehinting for classes and interfaces

2012-08-18 Thread André Rømcke
( resending with correct formatting, and missing context while at it, sorry about that ) On Aug 15, 2012, at 8:33 PM, Nikita Popov wrote: > (...) > > Another aspect here is that there is no reasonable syntax for this > feature, at least I can't think of one: > > * The syntax `$foo = (Interface

Re: [PHP-DEV] [RFC] Generators

2012-08-18 Thread Lester Caine
Nikita Popov wrote: I don't understand this argument. Generator functions are transparent to the user. You use a generator function just like you would use a function that returns an array. From a user point of view it does not matter whether getLinesFromFile() is just a function returning an ar

Re: [PHP-DEV] re: removing an item from an array

2012-08-18 Thread Andrew Faulds
On 17/08/12 22:41, Rasmus Lerdorf wrote: On 08/17/2012 05:35 PM, Rasmus Schultz wrote: Most other languages have more than one collection-type... since PHP has only the single, hybrid array-type which acts both as a hash and as an array, something like this ought to be available. I don't know w

Re: [PHP-DEV] Combined assignment operator for short ternary

2012-08-18 Thread Andrew Faulds
On 18/08/12 03:36, Tjerk Meesters wrote: Sent from my iPhone On 18 Aug, 2012, at 5:41 AM, Sebastian Krebs wrote: Hi, Don't know, how complicated this is (and also someone (not me) must implement it, because I can't :X), but to be in sync with the operators the short ternary operator shoul

Re: [PHP-DEV] re: removing an item from an array

2012-08-18 Thread Andrew Faulds
On 18/08/12 14:52, Morgan L. Owens wrote: Rasmus Schultz wrote: > I disagree - this is (or should be) a simple, atomic operation... > yet, you've got a function-call, an intermediary variable, a boolean > test, and an unset statement repeating the name of the array you're > deleting from. > > Th

Re: [PHP-DEV] re: removing an item from an array

2012-08-18 Thread Morgan L. Owens
On 2012-08-19 10:25, Andrew Faulds wrote: On 18/08/12 14:52, Morgan L. Owens wrote: How simple is it? Does it: 1) Remove one occurrence of the element (presumably the first) or all? 2) Reindex the array (as someone else argued was necessary to make it "properly indexed" afterwards) or not? 3) M

Re: [PHP-DEV] re: removing an item from an array

2012-08-18 Thread Andrew Faulds
On 19/08/12 01:39, Morgan L. Owens wrote: On 2012-08-19 10:25, Andrew Faulds wrote: On 18/08/12 14:52, Morgan L. Owens wrote: How simple is it? Does it: 1) Remove one occurrence of the element (presumably the first) or all? 2) Reindex the array (as someone else argued was necessary to make it

Re: [PHP-DEV] Re: Generators in PHP

2012-08-18 Thread Stas Malyshev
Hi! > For PHP we would need to have some similar behavior. PHP's current > exception model is incompatible with GeneratorExitException (because > PHP does not have BaseExceptions). So what I'd probably do instead is > monkeypatch a ZEND_RETURN opcode at the current execution position and Patching

Re: [PHP-DEV] [VOTE]Call for voting: support use list in foreach

2012-08-18 Thread Laruence
On Sat, Aug 18, 2012 at 5:48 PM, Nikita Popov wrote: > On Sat, Aug 18, 2012 at 6:34 AM, Laruence wrote: >> Hi: >> This feature introduces list() support in foreach constructs(more >> info can be found here: https://wiki.php.net/rfc/foreachlist). >> >> please vote for this: https://wiki.php.

Re: Re: [PHP-DEV] removing an item from an array

2012-08-18 Thread Morgan L. Owens
On 2012-08-19 04:08, Levi Morrison wrote: On Sat, Aug 18, 2012 at 12:42 AM, Alexey Zakhlestin wrote: On 16.08.2012, at 0:18, Rasmus Schultz wrote: How come there is no straight-foward obvious way to simply remove a given value from an array? Well, this sounds like a reason for creating Sp