Page 1 of 1

Packages and selective permissions

Posted: Wed Feb 13, 2013 10:22 pm
by garethw
My latest source of general befuddlement is the package system, and how best to use it to implement something somewhat analogous to a friend class in C++.

I've written some code that models a popular uProcessor from the 80s. I've exposed a small, clean interface to allow client code to drive it by sticking it all in a package, Vanilla, and exporting the appropriate symbols.

I've also written some code that provides some debug functionality that requires some access to the internals of the above - single-stepping, disassembly, breakpoints, register inspection, stuff like that. It needs access to, well, just about anything - its whole purpose is to violate the black box. I decided to put this in a separate package, Debug, which exports its own interface.

I'm trying to figure out what the best way to arrange this might be. I've thought of a couple of solutions:
  • 1. Just accept the fact that the debug code needs to violate the boundaries, and use Vanilla::<stuff> to access internals and be done with it. The key point here is that the Debug package is built on top of the Vanilla user package.

    2. Put everything in the Debug package; build the Vanilla package with no real functionality, that just exports a restricted interface without debug functions - the key point here being that the Vanilla user package is built on top of Debug.
Or maybe I'm just far too invested in bondage and discipline languages to realize that I should just stop worrying about it?

Re: Packages and selective permissions

Posted: Thu Feb 14, 2013 9:52 am
by Goheeca
It appears to me that import is appropriate here.

Re: Packages and selective permissions

Posted: Sat Feb 16, 2013 9:45 pm
by garethw
import definitely helps :)

I kind of assumed I'd be able to do this with the :import keyword in defpackage, but that doesn't seem to work for un-exported symbols in the source package.

Thanks, Goheeca.