From murdoch.duncan at gmail.com  Wed Oct 12 22:43:19 2011
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Wed, 12 Oct 2011 16:43:19 -0400
Subject: [Rd] how to make a true binary package?
In-Reply-To: <B37C0A15B8FB3C468B5BC7EBC7DA14CC6356C2E83A@LP-EXMBVS10.CO.IHC.COM>
References: <1318350794267-3895117.post@n4.nabble.com>	<4E947232.70301@gmail.com>
	<1318352963569-3895262.post@n4.nabble.com>
	<B37C0A15B8FB3C468B5BC7EBC7DA14CC6356C2E83A@LP-EXMBVS10.CO.IHC.COM>
Message-ID: <4E95FBE7.6010400@gmail.com>

On 12/10/2011 3:57 PM, Greg Snow wrote:
> If you want to hide some code from accidental or casual sight then I have had some success with adding something like this to the .R file for a package (the petals function in TeachingDemos in this case):
>
> .onAttach<- function(...) {
>      petals<- petals
>      attr(petals,'source')<- "Don't Cheat!"
>      assign('petals',petals,'package:TeachingDemos')
> }
>
> Though that would only slow an experienced R programmer down by maybe 10 seconds if they really wanted to see the code, it might take an intermediate level R programmer a whole minute to figure out how to work around this.  But it would prevent an honest user that knew of a license or agreement to not look at the code from accidentally seeing what they agreed not to.

You should be aware that this will no longer work in R 2.14.0, which 
finally drops the "source" attribute.  This would achieve a similar effect:

srcfile <- srcfilecopy("", "Don't cheat")
srcref <- srcref(srcfile, c(1,1,1,12))
attr(petals, "srcref") <- srcref

Duncan Murdoch

> You could also include something in the code that checked the attribute and stopped working if it was changed or somehow notified you of the change.  Combining this with the license agreements as others have said might give you additional recourse.
>
> You can see the petals.R file in the TeachingDemos package on R-forge for another example of obfuscating (bleaching) a key piece of code.  Combining the 2 might slow down an expert by a whole 30 seconds, but at least they would not be able to claim that they accidentally saw the code.
>
> Whether this violates the spirit of R licensing or not is another issue.
>



[Rd] how to make a true binary package?
Duncan Murdoch