On 9/12/07, Marcus Boerger <[EMAIL PROTECTED]> wrote: > > Hello Robert, > > yeah ifsetor if much better than the @-?: combination. But for 5.3 that > would be all we could do. For 6 and in the long run we might do a real > ifsetor. If ever we could come to a consensus... and no i don't really > like > to restart discussions on ifsetor at this point.
It was my understanding that ifsetor had been rejected long ago, after going around the list a few times after your proposal of it in 2004. I'd hate to hold up other language progress in the hopes of eventually restarting discussion on it, unless you'd like to bring a modified proposal now. Meanwhile, array_get() provides the most-needed functionality while avoiding the issues that prevented ifsetor's acceptance. There's a backward compatibility problem with ifsetor: its special syntax means that there's no way to write a pure-PHP userland version of it. The effect is that there's no upgrade path for applications that have to straddle both old and new versions of PHP, and practical usefulness of ifsetor would be delayed for years after release. Of course, accepting array_get() now would not preclude bringing up ifsetor again someday on its unique merits. Here is the patch and unit test file for array_get(): http://ashearer.com/software/array_get/2007-09-10-php6/array_get.diffhttp://ashearer.com/software/array_get/2007-09-10-php6/array_get.phpt And here is the backward compatibility function: if (!function_exists('array_get')) { function array_get($arr, $key, $default = false) { if (array_key_exists($key, $arr)) { return $arr[$key]; } else { return $default; } } } Tuesday, September 11, 2007, 7:17:02 PM, you wrote: > > > On Tue, 2007-09-11 at 18:54 +0200, Marcus Boerger wrote: > >> Hello Andrew, > >> > >> how about @<expression>?:<default> style? > >> > >> Like: $val = $myarray[$key] ?: $default; > > > Did you mean like: > > > @$val = $myarray[$key] ?: $default; > > > Because that's an expensive assignment since it will hit the error > > handler when the index is not assigned. I thought the ifsetor system was > > going to throttle undefined index notices for the left operand. > > > Cheers, > > Rob. > Best regards, > Marcus > >