News for hackers. Stuff that matters.
Re:PHP: \ as namespace separator. What were they thinking? by kwamenum86 on Sunday October 26, 2008 @07:00AM (#344206)
They should have stuck with Paamayim Nekudotayim for the namespace and either 1) returned an error for ambiguities or 2) used some prefix for namespaces like !Foo::bar().

1) is less desirable because unlike C++ PHP is not compiled. I could imagine some random included file that you disabled for testing causing an ambiguity error.

2) could work if you choose a representation that is human readable and easily parsable. The exclamation point seems to fit that description.

Re:PHP: \ as namespace separator. What were they thinking? by DougBTX on Sunday October 26, 2008 @07:54AM (#344223)
Lets say bar() returns false. Are the following two lines the same?

    true == !false
    true == !Foo::bar()
Paamayim Nekudotayim is the best option, you could even use it as a prefix in case of ambiguity:

    true == ::Foo::bar()
Re:PHP: \ as namespace separator. What were they thinking? by randallsquared on Sunday October 26, 2008 @08:50AM (#344239)
Easily solved by using '!!' instead of '!'. But it doesn't matter to me. I like to complain about PHP while using it, and I get a lot of stuff done in PHP, but I don't really care about it.
Re:PHP: \ as namespace separator. What were they thinking? by DougBTX on Sunday October 26, 2008 @11:21AM (#344328)
You can chain !, so "true == !! true" is true.
Re:PHP: \ as namespace separator. What were they thinking? by randallsquared on Sunday October 26, 2008 @01:08PM (#344399)
You can, but I can't think of any reason to do so, which is why I mentioned it.
Re:PHP: \ as namespace separator. What were they thinking? by DougBTX on Sunday October 26, 2008 @06:39PM (#344619)
Which of these would be the same?

   !(!(true))
   ! ! true
   !!true
Having !! not be the same as ! ! would probably be the first case in PHP of significant whitespace.
Re:PHP: \ as namespace separator. What were they thinking? by randallsquared on Sunday October 26, 2008 @07:56PM (#344683)
I would assume that the first would be different than the second two, in the case that !! was some other operator. It's not clear to me whether other cases in which there are double-character operators tolerate having whitespace between them. Is "$name++" the same as "$name+ +", or is the latter an error, or neither? I can't be bothered to check right now. :)
Re:PHP: \ as namespace separator. What were they thinking? by qqq on Sunday October 26, 2008 @01:24PM (#344410)
generated code

to convert stuff to explicit true/false

Re:PHP: \ as namespace separator. What were they thinking? by randallsquared on Sunday October 26, 2008 @02:47PM (#344476)
> generated code

Not a problem: either the PHP generated is only safe for a particular version, or they can add parenthesis to distinguish the cases.

> to convert stuff to explicit true/false

I suppose. That would seem like a surprising use to me, and would merit an explanatory comment, but given that, it might be better to just explicitly cast ("(bool)$name"), which saves the comment, and only adds four characters over "!!$name".

Re:PHP: \ as namespace separator. What were they thinking? by qqq on Sunday October 26, 2008 @03:17PM (#344492)
Every syntax quirk that requires the code generator to do something (e.g. add more parentheses) makes code generation harder.
Re:PHP: \ as namespace separator. What were they thinking? by randallsquared on Sunday October 26, 2008 @05:36PM (#344573)
I would naively expect every single expression to be surrounded by parenthesis by default, implemented in the lowest level writeExpression() function or whatever. But I've never written a translator, so...
Re:PHP: \ as namespace separator. What were they thinking? by jrockway on Sunday October 26, 2008 @09:56AM (#344274)
That all depends on whether or not PHP considers true == true. Knowing =='s track record... it wouldn't surprise me if it didn't :)
Re:PHP: \ as namespace separator. What were they thinking? by kwamenum86 on Sunday October 26, 2008 @12:41PM (#344381)
Choose some other prefix then as long as we can use Paamayim Nekudotayim for namespaces :)
Re:PHP: \ as namespace separator. What were they thinking? by Sujan on Sunday October 26, 2008 @03:09PM (#344486)
Last one looks fine to me.