I just read the slides about CAPerl (http://caperl.links.org/) and it's an
interesting idea. Leaving aside the question of whether this would work in
Perl5 or not, I think it would be very interesting to look at building this
concept into Perl6. Here's how I'd envision doing so:

    * Any subroutine is allowed to work with the parameters it was given.
(If you didn't want it to work with those, why did you give them to it?)
Variables outside its scope are, by default, not allowed.
    * When looking at a variable you're allowed to see, you are only allowed
to use the methods it exposes - no peeking!
    * A subroutine may be explicitly granted access to a variable in a
parent scope through the "grant" keyword. (More later.)
    * A subroutine may be disallowed access to a variable in a parent scope
through the "revoke" keyword. (More later.)
    * Access to resources outside the program (files, etc) must be provided
to the subroutine through parameters or explicit grants.
    * The outermost scope is completely trusted. (Someone has to be ...)

Grant/revoke (names may be changed, as needed) take the following
(pseudocode) signatures:
    grant ( Sub, Var, [Var, ... ] )
    revoke( Sub, Var, [Var, ... ] )

It is an error to:
    * attempt to grant/revoke access to a variable you don't have access to
    * attempt to grant/revoke access to a variable that isn't in scope for
the grantee

Thanks,
Rob

Reply via email to