r/lolphp • • Nov 15 '14

new safe casting function RFC. casting "-10" to string is valid but casting "+10" is not..

here the comment where one user asked the author of RFC about this. I am not able to follow his reasoning. What do you think?

21 Upvotes

67 comments sorted by

View all comments

Show parent comment

2

u/i_make_snow_flakes Nov 16 '14

When you see +1, do you read it as + applied to value 1, or as "plus one"? That is the essence of my argument...

1

u/midir Nov 16 '14

When you see +1, do you read it as + applied to value 1, or as "plus one"?

Either? It depends on the context in which I saw it.

That is the essence of my argument...

I know what your argument is. My argument is simply that that argument is not supported by merely pointing to the fact that $a = +1; compiles, since so does $a = + +1; and infinity billion other things. What is supported by a complex language's syntax is not the same as what has to be supported by a string-to-int conversion function.

Whether +1 should be supported by it regardless, is not something I'm trying to debate, since I don't care either way.

2

u/i_make_snow_flakes Nov 16 '14

My argument is simply that that argument is not supported by merely pointing to the fact that $a = +1; compiles

Not only that, but "+1" can be considered as a the representation of a single value at a higher level, and not as an expression, even though at a lower level it is treated as an expression.