On 24 ביול 2012, at 19:18, Alex Aulbach wrote:

> 2012/7/24 Galen Wright-Watson <ww.ga...@gmail.com>:
>>> Don't see much difference between
>>> 
>>> $a = $b ?: $c;
>>> 
>>> and (for example I used "i" for "if")
>>> 
>>> $a = _i($b, $c);
>> 
>> 
>> When $b is defined, there isn't much appreciable difference. However, this
>> behavior already exists, so there isn't much to debate. In the cases under
>> discussion, a userland function can't suppress undefined variable & index
>> notices, so it isn't a viable substitution.
> 
> Hm, you're right. I normaly don't do such ugly things. :)
> 
> Hum. This behaviour is needed in very special contexts. In my eyes
> only when printing out/filling up the templates etc. Under normal
> circumstances I think, you should program without too much operators,
> because a deflation of operators leads to - hm - deflation of the
> language. Thats the same, as if everybody can create new words: after
> a short time, nobody can understand anybody.
> 
> Hmmmm. But we can make this to a principle in this very, very closed context.
> 
> So: What about if we can create new operators inside PHP with PHP? I
> think not more than 36 operators are needed at any time in a project.
> So we can do this:
> 
> set_operator_handler('i', function ($b, $c) {
>        if (empty($b)) return $b;
>        return $b;
> }, OPERATOR_HANDLE_UNSET_WITHOUT_WARNINGS)
> 
> then we can do this:
> 
> $a = $a ?i: $b;
> 
> This should help for this case and could be a great things for those
> very special cases, when you need the same operation over and over.
> 
> Comments
> ----------------
> 
> Context: I think those operators should be global.
> 
> Security: Hm. Could operators be overwritten? How to test, if an
> operator already exists? I think it should work like including a file.
> E. g. set_operator_handler_once() should be possible, so that a second
> call isn't executed.
> 
> Other things: I don't like the first operator (the operator-name). Any
> goof idea?
> 
> 
> -- 
> Alex Aulbach
> 
> -- 
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

I don't think global operators is good idea since it can make a script very 
complex and you'll have to learn many operators in case the one who wrote it 
decided to make it "operator driven"
However, if we're talking about operators, I do think that adding operator 
override option (for the regular operators, such as +, -, * etc.) will be great 
for OOP - but that's a different topic.


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

Reply via email to