isaacg1 / pyth

Pyth, an extremely concise language. Try it here:
https://pyth.herokuapp.com/
MIT License
263 stars 57 forks source link

Documentation of .[ is wrong. #150

Closed orlp closed 8 years ago

orlp commented 9 years ago

For example it says:

On <any><int><seq> pad left.

Which is just flat out wrong.

isaacg1 commented 9 years ago

Fixed by #151

orlp commented 8 years ago

No, no, no, no!

I just realized that Jakob fixed the entirely wrong thing. The reference implementation was (almost) good, the documentation was wrong!

Consider the current (wrong) documentation:

On <seq><any><int> pad right. On <int><seq><any> pad left and right. On <any><int><seq> pad left.

That is incredibly, incredibly inconsistent. The order of <seq> and <any> is inconsistent, and the place of the integer does not match where the padding will occur. I propose the following:

On <seq><any><int> pad right. On <seq><int><any> pad left and right. On <int><seq><any> pad left.

jakobkogler commented 8 years ago

@orlp With your notation you can't distinguish pad right from pad left and right, when <any> is also from type <int>.

My main idea was the following:

And the other two parameter rotate with it.

jakobkogler commented 8 years ago

And if you don't rotate the parameters, you get problems with <any> = <seq>.

The main reason I changed the behavior instead of the documentation was to make the documentation easier. The behavior was correct for <any> = <int>, but worked differently for <any> = <string>. The documentation would have been twice as long and more complicated.

orlp commented 8 years ago

I apologize, I totally forgot about distinguishing <any> = <seq>