{"action":"created","issue":{"url":"https://api.github.com/repos/scriptcs/scriptcs/issues/1141","repository_url":"https://api.github.com/repos/scriptcs/scriptcs","labels_url":"https://api.github.com/repos/scriptcs/scriptcs/issues/1141/labels{/name}","comments_url":"https://api.github.com/repos/scriptcs/scriptcs/issues/1141/comments","events_url":"https://api.github.com/repos/scriptcs/scriptcs/issues/1141/events","html_url":"https://github.com/scriptcs/scriptcs/pull/1141","id":142798192,"number":1141,"title":"Custom Printers","user":{"login":"gregoryyoung","id":381274,"avatar_url":"https://avatars.githubusercontent.com/u/381274?v=3","gravatar_id":"","url":"https://api.github.com/users/gregoryyoung","html_url":"https://github.com/gregoryyoung","followers_url":"https://api.github.com/users/gregoryyoung/followers","following_url":"https://api.github.com/users/gregoryyoung/following{/other_user}","gists_url":"https://api.github.com/users/gregoryyoung/gists{/gist_id}","starred_url":"https://api.github.com/users/gregoryyoung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gregoryyoung/subscriptions","organizations_url":"https://api.github.com/users/gregoryyoung/orgs","repos_url":"https://api.github.com/users/gregoryyoung/repos","events_url":"https://api.github.com/users/gregoryyoung/events{/privacy}","received_events_url":"https://api.github.com/users/gregoryyoung/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-22T22:20:56Z","updated_at":"2016-03-23T05:34:30Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/scriptcs/scriptcs/pulls/1141","html_url":"https://github.com/scriptcs/scriptcs/pull/1141","diff_url":"https://github.com/scriptcs/scriptcs/pull/1141.diff","patch_url":"https://github.com/scriptcs/scriptcs/pull/1141.patch"},"body":"*This is not intended to be accepted but to act as a point of discussion*\r\n\r\nI have implemented here custom pretty printing into scriptcs. I felt something like this after writing it.\r\n\r\n![image](https://cloud.githubusercontent.com/assets/381274/13969233/34e9c7ee-f08a-11e5-87e1-5304bdc064f6.png)\r\n\r\nIts really ugly. The code does however now work. Here is an example:\r\n\r\n```code\r\ngreg@clown:~/src/scriptcs$ artifacts/Release/bin/scriptcs -Repl\r\nscriptcs (ctrl-c to exit or :help for help)\r\n\r\n> 5 + 5\r\n10\r\n> Repl.AddCustomPrinter<int>(x => \"hello greg this is your integer \" + x)\r\nadding custom printer\r\n> 5 + 6                                                                   \r\nhello greg this is your integer 11\r\n> Repl.AddCustomPrinter<int>(x => \"redefining printer integer is \" + x)   \r\nadding custom printer\r\n> 5 + 6                                                                 \r\nredefining printer integer is 11\r\n```\r\n\r\nThis is a very common thing used in the F# repl. As an example here is a little library that gives you definitions for record types http://fssnip.net/cV so it looks like\r\n\r\n```code\r\n// +--------+--------+--------+\r\n// | Label1 | Label2 | Label3 |\r\n// +--------+--------+--------+\r\n// | Value1 | Value2 | Value3 |\r\n// +--------+--------+--------+\r\n// | Value1'| Value2'| Value3'|\r\n// +--------+--------+--------+\r\n```\r\n\r\nWe make heavy use of this in privateeye\r\n\r\n```code\r\n> mostCalledMethods() |> Seq.take 10;;\r\nval it : seq<profilersession.MethodInformation> =\r\n\r\n--------------------------------------------------------------------------------\r\n|Name                             |  Called| Total Time|Allocs|  A. Size|Thrown|\r\n--------------------------------------------------------------------------------\r\n|ProcessBlock (byte[],int)        | 3176533| 16402.0126|     0|        0|     0|\r\n|get_Chars (int)                  |  170507|   483.9711|     0|        0|     0|\r\n|get_Rank ()                      |  140403|  2138.1667|     0|        0|     0|\r\n|GetRank (System.Array)           |  140403|   915.1704|     0|        0|     0|\r\n|get_Length ()                    |  131869|  2944.0053|     0|        0|     0|\r\n|__icall_wrapper_mono_object_new_s|   81548|   922.2145| 81548|  3493132|     0|\r\n|CachePropertyInfo (System.Reflect|   78383|   302.0055|     0|        0|     0|\r\n|ReadSegment (byte[],int,int)     |   76117|   416.0591|     0|        0|     0|\r\n|GetAttributeFlagsImpl ()         |   73713|   874.5466|     0|        0|     0|\r\n|GetAttributes (System.RuntimeType|   73713|   291.3721|     0|        0|     0|\r\n--------------------------------------------------------------------------------\r\n```\r\n\r\nNow in terms of implementation the one here is a mess but I think it can be improved upon. I don't know all the code that well, In dealing with the dependency graph:\r\n\r\n![image](https://cloud.githubusercontent.com/assets/381274/13969503/fb28fe24-f08b-11e5-94e2-ce070b436b1a.png)\r\n\r\nI really don't think Repl should be exposed all the way on ScriptHost but it may actually be useful there as you can easily add quite a few other Repl configurations there. An alternative might be to isolate the dependency into ICustomPrinter and put this on ScriptHost.\r\n\r\nSome of the rest will likely require some refactoring of dependencies and how they relate. Before just embarking on that I figured it would be worth bringing it up as a discussion.\r\n\r\nSo first question, does pretty printing seem like a reasonable feature worth following up on?\r\n\r\nSecond question, how do people see refactoring things to make dependency handling a bit more sane than it is here?\r\n\r\nGreg"},"comment":{"url":"https://api.github.com/repos/scriptcs/scriptcs/issues/comments/200190823","html_url":"https://github.com/scriptcs/scriptcs/pull/1141#issuecomment-200190823","issue_url":"https://api.github.com/repos/scriptcs/scriptcs/issues/1141","id":200190823,"user":{"login":"glennblock","id":141124,"avatar_url":"https://avatars.githubusercontent.com/u/141124?v=3","gravatar_id":"","url":"https://api.github.com/users/glennblock","html_url":"https://github.com/glennblock","followers_url":"https://api.github.com/users/glennblock/followers","following_url":"https://api.github.com/users/glennblock/following{/other_user}","gists_url":"https://api.github.com/users/glennblock/gists{/gist_id}","starred_url":"https://api.github.com/users/glennblock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glennblock/subscriptions","organizations_url":"https://api.github.com/users/glennblock/orgs","repos_url":"https://api.github.com/users/glennblock/repos","events_url":"https://api.github.com/users/glennblock/events{/privacy}","received_events_url":"https://api.github.com/users/glennblock/received_events","type":"User","site_admin":false},"created_at":"2016-03-23T05:34:30Z","updated_at":"2016-03-23T05:34:30Z","body":"Thanks a ton for the effort @gregoryyoung, this looks VERY COOL!. I'll take a look at the code...."}}