{"action":"created","issue":{"url":"https://api.github.com/repos/BIDData/BIDMat/issues/40","labels_url":"https://api.github.com/repos/BIDData/BIDMat/issues/40/labels{/name}","comments_url":"https://api.github.com/repos/BIDData/BIDMat/issues/40/comments","events_url":"https://api.github.com/repos/BIDData/BIDMat/issues/40/events","html_url":"https://github.com/BIDData/BIDMat/issues/40","id":102070216,"number":40,"title":"newOrCheck methods could probably be generic","user":{"login":"kjameslubin","id":7716455,"avatar_url":"https://avatars.githubusercontent.com/u/7716455?v=3","gravatar_id":"","url":"https://api.github.com/users/kjameslubin","html_url":"https://github.com/kjameslubin","followers_url":"https://api.github.com/users/kjameslubin/followers","following_url":"https://api.github.com/users/kjameslubin/following{/other_user}","gists_url":"https://api.github.com/users/kjameslubin/gists{/gist_id}","starred_url":"https://api.github.com/users/kjameslubin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kjameslubin/subscriptions","organizations_url":"https://api.github.com/users/kjameslubin/orgs","repos_url":"https://api.github.com/users/kjameslubin/repos","events_url":"https://api.github.com/users/kjameslubin/events{/privacy}","received_events_url":"https://api.github.com/users/kjameslubin/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-20T06:16:35Z","updated_at":"2015-09-27T17:08:22Z","closed_at":"2015-09-27T17:08:22Z","body":"Given that the omat parameter is always generic anyway, it's likely we could write a catch-all newOrCheck method in Mat and override it individually. The reason I mention it is that implementing caching for generic matrix methods could end up requiring quite a few pattern matches. It's manageable at the moment (just FMat's, SMat's, GMat's and GSMat's) but could grow in complexity.\r\n\r\nIn practice the methods pattern match on the omat type inside the function body, so it should be 'safe' to make the method generic. \r\nhttps://github.com/BIDData/BIDMat/blob/master/src/main/scala/BIDMat/DMat.scala#L1459-L1465\r\n\r\nSomething might be lost vis-a-vis (e.g.) reflection, though. I still don't understand Scala's type erasure semantics very well."},"comment":{"url":"https://api.github.com/repos/BIDData/BIDMat/issues/comments/143577633","html_url":"https://github.com/BIDData/BIDMat/issues/40#issuecomment-143577633","issue_url":"https://api.github.com/repos/BIDData/BIDMat/issues/40","id":143577633,"user":{"login":"jcanny","id":1195924,"avatar_url":"https://avatars.githubusercontent.com/u/1195924?v=3","gravatar_id":"","url":"https://api.github.com/users/jcanny","html_url":"https://github.com/jcanny","followers_url":"https://api.github.com/users/jcanny/followers","following_url":"https://api.github.com/users/jcanny/following{/other_user}","gists_url":"https://api.github.com/users/jcanny/gists{/gist_id}","starred_url":"https://api.github.com/users/jcanny/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcanny/subscriptions","organizations_url":"https://api.github.com/users/jcanny/orgs","repos_url":"https://api.github.com/users/jcanny/repos","events_url":"https://api.github.com/users/jcanny/events{/privacy}","received_events_url":"https://api.github.com/users/jcanny/received_events","type":"User","site_admin":false},"created_at":"2015-09-27T17:08:22Z","updated_at":"2015-09-27T17:08:22Z","body":"This sounds reasonable. The only caveat is that the newOrCheck functions need to work with null matrix arguments when there's  no container to reuse, so you cant use the omat parameter to infer the type. You have to introduce another matrix argument which you match the type to. That should be available in the contexts you're interested in."}}