Re: Re: Why PHP sucks - farce or is there a bit of truth?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



oops, saw my picture and assumed it would come from the correct account,
German Geek.

Tim-Hinnerk Heuer

Twitter: @geekdenz
Blog: http://www.thheuer.com


On 19 October 2013 16:46, German Geek <geek.de@xxxxxxxxx> wrote:

> German Geek is me btw. :-) I have that email as well and must've replied
> to the email that got to that account... What happens when you
> over-automate.
>
> I wouldn't use a 2-factor ternary operator, especially after this
> discussion, lol. Saw that for the first time on that website. I personally
> hate when people obfuscate just to make shorter lines or seem smarter. Code
> is edited by different people if it is useful or good.
>
> Tim-Hinnerk Heuer
>
> Twitter: @geekdenz
> Blog: http://www.thheuer.com
>
>
> On 19 October 2013 16:32, German Geek <geek.de@xxxxxxxxx> wrote:
>
>> I agree, it's not a bug, just a different design or interpretation of the
>> statement. I further agree that the programmer should put parentheses
>> around statements if visually ambiguous. Also, from left to right seems
>> more logical. That it happens in this particular case that the result seems
>> counter-intuitive doesn't mean it is illogical. I just had trouble
>> understanding at first why it would output 'two' instead of 'one' when the
>> contents of the variable clearly was 1.
>>
>> A different construct could be used better used in a case where a
>> variable can have more than 2 values. elseif or even a switch, though more
>> verbose, is probably much more readable.
>>
>> Sorry, Robert, for the huge font. I was sure I had reduced it before
>> sending in gmail... Copy/paste from the website made it that big.
>>
>> I raised the issue also to get a better understanding what other php
>> programmers think and I much better understand some things now.
>>
>>
>> Tim-Hinnerk Heuer
>>
>> Twitter: @geekdenz
>> Blog: http://www.thheuer.com
>>
>>
>> On 19 October 2013 08:20, David Harkness <david.h@xxxxxxxxxxxxxxxxx>wrote:
>>
>>> On Fri, Oct 18, 2013 at 12:02 PM, Jim Giner <
>>> jim.giner@xxxxxxxxxxxxxxxxxx>wrote:
>>>
>>> > That said I see the 'proper' expectation of this statement:
>>> >
>>> > $foo = $a ? $b : $c ? $d : $e;
>>> >
>>> > as:
>>> >
>>> > $foo will be the result of "if $a then $b else if $c then $d else $e;"
>>> >
>>> > Why php interprets it differently is just not logical to me.
>>>
>>>
>>> While I agree that PHP probably should have matched other languages like
>>> C
>>> and Java, a) I have never needed to use this double construct, b) I
>>> wouldn't even if it made sense due to the likely confusion, and c) PHP
>>> has
>>> the Elvis operator ($x ?: $y) which is pure awesomeness so I can forgive
>>> it's wonky ternary precedence.
>>>
>>> Far more troublesome with PHP is the mixed parameter ordering in the
>>> built-in functions. The quote on the top of that page says it all. I'm
>>> constantly having to rely on code-completion for functions I've used for
>>> years to make sure I'm getting the order right. Haystack before needle or
>>> needle before haystack? Both! :(
>>>
>>> Cheers,
>>> David
>>>
>>
>>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux