Is that possible for a user-defined function calling another user-defined function in Stan chunk functions? For instance, I defined two functions build_b_spline and g. My second function g is supposed to call build_b_spline inside. When I tried to complied my codes, it looks the g function is not able to find the first function build_b_spline. Could anyone help to clarify this? Thanks in advance.
The error indicates that build_b_spline is expecting the first argument (t) to have type real[] (i.e., an array of reals), but you’re passing an array of integers (i.e., int[]).
You either need to change the declaration of build_b_spline to expect the first argument to have type int[], or you need to change the type of data that you’re passing to it (i.e., you need t to have type real[])
That’s a good technical point. I am not a copyright lawyer, so the following is an informed speculation at best.
It is unclear exactly at which point a piece of code becomes copyrightable. In most jurisdictions, copyright requires that there was a “creative act”. So I almost definitely can’t copyright a piece of code like real my_log(real a) { return log(a);}. The build_b_spline function in question would IMHO most likely be copyrightable, but that does not mean all code snippets we share on the forums are. There is a wide gray zone.
It is usually considered sufficient to link to a license or - for popular licenses - just mention the license name (instead of copying the exact license text). Note that the case study with the original code does exactly that. This hinges on a somewhat liberal interpretation of “retain the above copyright notice”, but I find it extremely unlikely this could be challenged.
In our Terms of service we say that all user posted content is licensed as Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. So reposting anything already licensed under almost any CC license is OK without any further comment. Practically, I think mixing and matching broadly permissive licenses, especially swapping loose license (e.g. BSD 3-clause) for more restrictive (e.g. CC BY-NC-SA) is quite OK and unlikely (though not impossible) to be challenged in practice - anyone challenging would need to show standing (i.e. it would almost certainly need to be the author of the code). Then, they should ask us to remove the offending content (e.g. a DMCA notice) and if we comply, then they would need to show actual harm caused by the differing license to ask for compensation.
To summarise: I think@ygao43 is technically right, but the requirements of “retaining” the license should be easy to satisfy. The harder problem is that our ToS says that all content is CC BY-NC-SA 3.0, and @ygao43 is definitely unable to relicense the code themselves to match our ToS.
It might be worthwhile for us to think about rewording the licensing terms in our ToS to allow people to explicitly add a different free license to (a part of) their post. This would IMHO resolve similar issues completely.
Glad to see your detailed explanation. It makes more sense now. I am quite new to Stan and there are so much to learn, including the copyright of the coding.