{"action":"opened","issue":{"url":"https://api.github.com/repos/crystal-lang/crystal/issues/2800","repository_url":"https://api.github.com/repos/crystal-lang/crystal","labels_url":"https://api.github.com/repos/crystal-lang/crystal/issues/2800/labels{/name}","comments_url":"https://api.github.com/repos/crystal-lang/crystal/issues/2800/comments","events_url":"https://api.github.com/repos/crystal-lang/crystal/issues/2800/events","html_url":"https://github.com/crystal-lang/crystal/issues/2800","id":159770193,"number":2800,"title":"Request on improving DL module","user":{"login":"hyronx","id":12110866,"avatar_url":"https://avatars.githubusercontent.com/u/12110866?v=3","gravatar_id":"","url":"https://api.github.com/users/hyronx","html_url":"https://github.com/hyronx","followers_url":"https://api.github.com/users/hyronx/followers","following_url":"https://api.github.com/users/hyronx/following{/other_user}","gists_url":"https://api.github.com/users/hyronx/gists{/gist_id}","starred_url":"https://api.github.com/users/hyronx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hyronx/subscriptions","organizations_url":"https://api.github.com/users/hyronx/orgs","repos_url":"https://api.github.com/users/hyronx/repos","events_url":"https://api.github.com/users/hyronx/events{/privacy}","received_events_url":"https://api.github.com/users/hyronx/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-06-11T11:54:13Z","updated_at":"2016-06-11T11:54:13Z","closed_at":null,"body":"Hi,\r\n\r\nI'm playing around with this module and it currently has really not many features. \r\nSo I want to show you my ideas on how to improve it.\r\n\r\n**1. A new name**\r\n_DL_ is not really meaningful if you don't know the dl library and even then it could be something different. Renaming it to _DynamicLibrary_ or _DynLib_ would make it more clear what this module is about\r\n\r\n**2. Renaming the functions**\r\nWith the first point it wouldn't be a problem to rename _dlopen_ to just _open_ and later (when implemented) also using _symbol_ or _sym_ instead of _dlsym_.\r\n\r\n**3. Changing the module to a class**\r\nInstead of passing the `Pointer(Void)` around to a symbol method or the like, the class could store it in an instance variable making it easier to load multiple symbols and, in the `finalize` method, could automatically close the library:\r\n\r\n(In my opinion  _DynamicLibrary_ is a more suitable name)\r\n`my_lib = DynamicLibrary.new \"my_lib\", flags`\r\n`my_func = my_lib.symbol \"my_func\"`\r\n`my_func2 = my_lib.symbol \"my_func2`\r\n\r\ninstead of\r\n\r\n`handle = DynLib.open \"my_lib\", flags`\r\n`my_func = DynLib.symbol handle, \"my_func\"`\r\n`my_func2 = DynLib.symbol handle, \"my_func2\"`\r\n`DynLib.close handle`\r\n\r\nI could create a new feature branch and implement this stuff together with the additional methods :)\r\n\r\nSorry for any English mistakes...\r\n\r\n"}}
{"actor":{"display_login":"hyronx"}}