{"action":"opened","issue":{"url":"https://api.github.com/repos/jkuczm/MathematicaClasslessObjects/issues/11","labels_url":"https://api.github.com/repos/jkuczm/MathematicaClasslessObjects/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/jkuczm/MathematicaClasslessObjects/issues/11/comments","events_url":"https://api.github.com/repos/jkuczm/MathematicaClasslessObjects/issues/11/events","html_url":"https://github.com/jkuczm/MathematicaClasslessObjects/issues/11","id":61640692,"number":11,"title":"usage question 1: setting methods (functions) in constructors","user":{"login":"ibeatty","id":835461,"avatar_url":"https://avatars.githubusercontent.com/u/835461?v=3","gravatar_id":"","url":"https://api.github.com/users/ibeatty","html_url":"https://github.com/ibeatty","followers_url":"https://api.github.com/users/ibeatty/followers","following_url":"https://api.github.com/users/ibeatty/following{/other_user}","gists_url":"https://api.github.com/users/ibeatty/gists{/gist_id}","starred_url":"https://api.github.com/users/ibeatty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ibeatty/subscriptions","organizations_url":"https://api.github.com/users/ibeatty/orgs","repos_url":"https://api.github.com/users/ibeatty/repos","events_url":"https://api.github.com/users/ibeatty/events{/privacy}","received_events_url":"https://api.github.com/users/ibeatty/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-03-14T16:41:46Z","updated_at":"2015-03-14T16:41:46Z","closed_at":null,"body":"Hi.\r\n\r\nFirst: Thanks 10^3 for creating and sharing this. It is a Godsend.\r\n\r\nSecond: Please forgive me if this is the wrong venue for communicating questions to you. I don't have enough reputation points on Stack Exchange yet to post a comment on your excellent answer there, and I'm new to GitHub so I'm unfamiliar with the conventions.\r\n\r\nThird: I'm trying to use this package in a *Mathematica* project, and I'm having trouble figuring out how to accomplish a couple of less basic things. The first is simple to describe: Is it possible to define a \"constructor\" that takes methods (set-delayed rules) as well as properties (set-immediately rules)? I tried the obvious, simply passing a function in as one of the constructor parameters and then setting the object rule to it, but no luck:\r\n\r\n```Mathematica\r\nancestor@construct[obj_Symbol, v0$_, r0$_, f$_Function] := (\r\n  DeclareObject[obj, $self];\r\n  obj@r0 = r0$;\r\n  obj@v0 = v0$;\r\n  obj@f := f$;\r\n  obj )\r\n```\r\n\r\nI've tried with `:=` and `=` in that code, and I've tried various methods of defining the function that I pass to the constructor: delayed or not, as a normal f[x_] rule or a pure function, etc.\r\n\r\n```Mathematical\r\nClearAll[child];\r\nff = (#^2) &;\r\nancestor@construct[child, 20, 0, ff];\r\n```\r\n\r\nIn all cases, I'm getting the following error message:\r\n\r\n```\r\nObject::objectMember: The call child@0 didn't match any of defined member patterns in child nor in its ancestors: {ancestor,Object}.\r\n```\r\n\r\nI can, of course, bypass the constructor and simply define the method for the child directly, with setDelayed, but it would be helpful (and ultimately easier for users of my project) if I could handle it in the constructor. Is this possible? Am I being dumb or blind?\r\n\r\nBTW, I'm moderately but not expertly skilled with Mathematica, but I'm not yet conversant with the subtleties of HoldAll and when/how to use it.\r\n\r\nThanks,\r\n:Ian"}}