isaacg1 / pyth

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

"u" seems to hang #179

Closed vendethiel closed 8 years ago

vendethiel commented 8 years ago

trying to compile this code:

u+GH[1 2 3

hangs on pyth.herokuapp

jakobkogler commented 8 years ago

That's not a bug. There are two version of u. One where you provide a list to iterate over and a starting value:

u+GH[1 2 3)0

and one, where you only provide a starting value. In this case H iterates over 0, 1, 2, ... until infinity. In this case u stops, when the lambda expression computes a values, that it computed earlier.

In your code you invoced the second case. G will get the following values:

[1, 2, 3] -> [1, 2, 3, 0] -> [1, 2, 3, 0, 1] -> [1, 2, 3, 0, 1, 2] -> ...

The list gets bigger each time. Therefore G will never reach a value, that it had before. So this will create an infinite loop.

Btw. if you want the the first value to be the starting value, you can use:

.U+bZ[1 2 3
vendethiel commented 8 years ago

makes sense, thanks. I still think it's a bug that the runtime is not bounded?

isaacg1 commented 8 years ago

@vendethiel One major use case for the unbounded runtime is that it allows you to make interactive programs, by using functions like w and E.

vendethiel commented 8 years ago

oh, okay, fair enough :). Thanks!

vendethiel commented 8 years ago

@isaacg1 maybe I can then request a "compile only" button? So I can realize the generated code, and why it hangs

Maltysen commented 8 years ago

@vendethiel The solution to that is not a compile only button, but real time feedback, if I ever get around to it… D: