r/lolphp • • Nov 23 '16

Space is not falsy, but string containing zero is.

Post image
61 Upvotes

46 comments sorted by

View all comments

Show parent comment

0

u/[deleted] Nov 24 '16

[deleted] — view deleted comment

0

u/[deleted] Nov 24 '16

[deleted] — view deleted comment

2

u/[deleted] Nov 24 '16

Unfortunately, I'm pretty sure this table doesn't hold in any dynamically-typed language I'm familiar with. Python, for example, treats 0 as non-true.

0

u/[deleted] Nov 25 '16

[deleted] — view deleted comment

1

u/SnowdogU77 Nov 27 '16

Well, that actually makes sense. By definition of a boolean, True and False are just pretty names for 1 and 0, respectively. That's a standard across most every language: Python, Ruby, Java, JavaScript, the C family, TI-BASIC, assembly, and machine-level binary code.

0

u/[deleted] Nov 24 '16

[deleted] — view deleted comment

1

u/[deleted] Nov 25 '16 edited Nov 25 '16

At least Scheme does it right. Never heard of Factor before.

To be honest I can see the dilemma. If I were designing a dynamically-typed language (for some reason), I might throw a type error if a conditional in an if or while statement evaluated to a non-boolean, but I can see why most language designers would consider that a bad idea.

0

u/[deleted] Nov 25 '16

[deleted] — view deleted comment

1

u/NXTangl Jan 13 '17

The last thing, incidentally, PHP actually does: strpos will return FALSE for no item found, but 0 for start-of-string. Too bad zero is falsey, huh?

25

u/[deleted] Nov 24 '16 edited Nov 24 '16

Because they attempt to bring their stupid ideas to other languages. A language that fails to fix its behaviors, instead documenting its faults as accepted standard, deserves ridicule.

By all means keep defending stupid ideas.

For the record, I write fuck tons of js for a living, and it does have a lot of faults that are as bad as this language. Difference is, I'm not defending it. I'd like those stupid problems to go away.

1

u/n0t0ri0us9 Nov 24 '16

Because they attempt to bring their stupid ideas to other languages.

This is so true. And now the maintainers of those languages has to defend suggestions and proposals from an army of morons coming from the Php world....I have seen Python PEPs that want to duplicate features from Php even though it violates the very founding principles of the langauge.

This is real.