{"action":"created","issue":{"url":"https://api.github.com/repos/jesserayadkins/lily/issues/129","repository_url":"https://api.github.com/repos/jesserayadkins/lily","labels_url":"https://api.github.com/repos/jesserayadkins/lily/issues/129/labels{/name}","comments_url":"https://api.github.com/repos/jesserayadkins/lily/issues/129/comments","events_url":"https://api.github.com/repos/jesserayadkins/lily/issues/129/events","html_url":"https://github.com/jesserayadkins/lily/issues/129","id":101106656,"number":129,"title":"Have a default to_s for all, including generics.","user":{"login":"jesserayadkins","id":7182625,"avatar_url":"https://avatars.githubusercontent.com/u/7182625?v=3","gravatar_id":"","url":"https://api.github.com/users/jesserayadkins","html_url":"https://github.com/jesserayadkins","followers_url":"https://api.github.com/users/jesserayadkins/followers","following_url":"https://api.github.com/users/jesserayadkins/following{/other_user}","gists_url":"https://api.github.com/users/jesserayadkins/gists{/gist_id}","starred_url":"https://api.github.com/users/jesserayadkins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jesserayadkins/subscriptions","organizations_url":"https://api.github.com/users/jesserayadkins/orgs","repos_url":"https://api.github.com/users/jesserayadkins/repos","events_url":"https://api.github.com/users/jesserayadkins/events{/privacy}","received_events_url":"https://api.github.com/users/jesserayadkins/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jesserayadkins/lily/labels/A:%20Classes","name":"A: Classes","color":"009800"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-14T21:33:47Z","updated_at":"2016-04-03T02:30:41Z","closed_at":"2016-04-03T02:30:41Z","body":"I'm frequently coming up with the problem of 'I want to print a value, but I'm not able to because it's not a string'. Suppose that I've got a list of integers: I currently have to walk through them, to_s them all, and then concat all of that together. Custom classes are terrible too!\r\n\r\nI'd like to have a default to_s that is available on every value, regardless of the type that it has. In the initial implementation, custom classes will not be able to define their own to_s (I want to have some time to think about polymorphism and virtual methods first).\r\n\r\nThe built-in to_s would be the same one across all types. Unfortunately, this means that ```[1,2,3].to_s == [\"1\", \"2\", \"3\"].to_s``` if you start comparing functions.\r\n\r\nAnyway, ```print``` would be rewritten to accept type ```A```. If it gets a non-string, it converts that into a string using the built-in stringification and prints out the result. This would allow writing code like: ```print([1,2,3])```\r\n\r\nFinally, since to_s would become available for every value, it would then be possible to use to_s on generic types, (regardless of any constraints that come in later on)."},"comment":{"url":"https://api.github.com/repos/jesserayadkins/lily/issues/comments/204857429","html_url":"https://github.com/jesserayadkins/lily/issues/129#issuecomment-204857429","issue_url":"https://api.github.com/repos/jesserayadkins/lily/issues/129","id":204857429,"user":{"login":"jesserayadkins","id":7182625,"avatar_url":"https://avatars.githubusercontent.com/u/7182625?v=3","gravatar_id":"","url":"https://api.github.com/users/jesserayadkins","html_url":"https://github.com/jesserayadkins","followers_url":"https://api.github.com/users/jesserayadkins/followers","following_url":"https://api.github.com/users/jesserayadkins/following{/other_user}","gists_url":"https://api.github.com/users/jesserayadkins/gists{/gist_id}","starred_url":"https://api.github.com/users/jesserayadkins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jesserayadkins/subscriptions","organizations_url":"https://api.github.com/users/jesserayadkins/orgs","repos_url":"https://api.github.com/users/jesserayadkins/repos","events_url":"https://api.github.com/users/jesserayadkins/events{/privacy}","received_events_url":"https://api.github.com/users/jesserayadkins/received_events","type":"User","site_admin":false},"created_at":"2016-04-03T02:30:41Z","updated_at":"2016-04-03T02:30:41Z","body":"The more I think about it, it seems that interpolation solved most of this problem. Yeah, it would be nice to eventually be able to stringify a class in a way that it prints out members in order. But, that's more of an 'if' right now. If that happens, well, it's not going to be a default for all types, because it really doesn't need to be now that interpolation has landed.\r\n\r\nI might eventually make some syntax for printing out a class with the member value (plus or minus the variable names). But what this calls for is definitely not going to happen with interpolation now being part of Lily."}}