{"action":"created","issue":{"url":"https://api.github.com/repos/Corsaair/redtamarin/issues/128","repository_url":"https://api.github.com/repos/Corsaair/redtamarin","labels_url":"https://api.github.com/repos/Corsaair/redtamarin/issues/128/labels{/name}","comments_url":"https://api.github.com/repos/Corsaair/redtamarin/issues/128/comments","events_url":"https://api.github.com/repos/Corsaair/redtamarin/issues/128/events","html_url":"https://github.com/Corsaair/redtamarin/issues/128","id":322589043,"number":128,"title":"Program.readLine returns empty string on EOF with no characters read","user":{"login":"wasamasa","id":3588994,"avatar_url":"https://avatars0.githubusercontent.com/u/3588994?v=4","gravatar_id":"","url":"https://api.github.com/users/wasamasa","html_url":"https://github.com/wasamasa","followers_url":"https://api.github.com/users/wasamasa/followers","following_url":"https://api.github.com/users/wasamasa/following{/other_user}","gists_url":"https://api.github.com/users/wasamasa/gists{/gist_id}","starred_url":"https://api.github.com/users/wasamasa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wasamasa/subscriptions","organizations_url":"https://api.github.com/users/wasamasa/orgs","repos_url":"https://api.github.com/users/wasamasa/repos","events_url":"https://api.github.com/users/wasamasa/events{/privacy}","received_events_url":"https://api.github.com/users/wasamasa/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-05-13T12:18:21Z","updated_at":"2018-05-13T15:27:21Z","closed_at":null,"author_association":"NONE","body":"I'm expecting that calling `Program.readLine` and hitting `C-d` will return `null`, however I get an empty string instead. This is kind of surprising, many languages follow this assumption (or alternatively, throw an error). For instance, `gets` in Ruby returns `nil` in that situation, `input` in Python throws an error.\r\n\r\nI've worked around this with the following for now:\r\n\r\n```actionscript\r\nimport C.stdio.*;\r\nvar input:String = fgets(0x7FFFFFFF, stdin);\r\nif (input != null && input.charAt(input.length - 1) == '\\n') {\r\n    return input.slice(0, input.length - 1);\r\n}\r\nreturn input;\r\n```"},"comment":{"url":"https://api.github.com/repos/Corsaair/redtamarin/issues/comments/388635051","html_url":"https://github.com/Corsaair/redtamarin/issues/128#issuecomment-388635051","issue_url":"https://api.github.com/repos/Corsaair/redtamarin/issues/128","id":388635051,"user":{"login":"zwetan","id":236154,"avatar_url":"https://avatars3.githubusercontent.com/u/236154?v=4","gravatar_id":"","url":"https://api.github.com/users/zwetan","html_url":"https://github.com/zwetan","followers_url":"https://api.github.com/users/zwetan/followers","following_url":"https://api.github.com/users/zwetan/following{/other_user}","gists_url":"https://api.github.com/users/zwetan/gists{/gist_id}","starred_url":"https://api.github.com/users/zwetan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zwetan/subscriptions","organizations_url":"https://api.github.com/users/zwetan/orgs","repos_url":"https://api.github.com/users/zwetan/repos","events_url":"https://api.github.com/users/zwetan/events{/privacy}","received_events_url":"https://api.github.com/users/zwetan/received_events","type":"User","site_admin":false},"created_at":"2018-05-13T15:27:21Z","updated_at":"2018-05-13T15:27:21Z","author_association":"OWNER","body":"> I'm expecting that calling `Program.readLine` and hitting `C-d` will return `null`, however I get an empty string instead. This is kind of surprising, many languages follow this assumption (or alternatively, throw an error). For instance, `gets` in Ruby returns `nil` in that situation, `input` in Python throws an error.\r\n\r\nnow on this part I don't agree that `^D` should return `null`\r\n\r\nfollowing the logic that `^D` mean \"End of Transmission\"\r\nit should tell `Program.readLine` to stop blocking\r\nor stop waiting for the transmission\r\n\r\nso something like that\r\n```actionscript\r\nvar input:String = Program.readLine();\r\ntrace( input );\r\n```\r\n\r\nshould have the following behaviour\r\n  - wait for input (eg. block forever)\r\n  - stop if either `\\n` or `EOF` or `^D` is sent\r\n  - return the accumulated buffer\r\n\r\nin the case where nothing were written in the buffer\r\nthen yes it should return the empty string\r\n\r\nagain, as a default \"dumb\" behaviour\r\n\r\nlet me know what you think\r\n\r\n"}}
{"actor":{"display_login":"zwetan"}}