[Prev][Next][Index][Thread]

Re: Dylan Object Protection



In article <dJzr6.1179$xU.61669849@news.xtra.co.nz>, "merridy" 
<merridy@xtra.co.nz> wrote:

> Hi there,
> I was wondering if anyone knew...
> How well does Dylan allow you to control access to the data fields (and
> perhaps methods) within objects? Can you define private/public/protected
> data? Who can access them?  Friends?

Dylan does not have anything like private/public/protected at the class 
level.  Protection in Dylan is done by exporting or not exporting things 
from the module.

When you export a class from a module it does *not* automatically export 
method and field names (to be precise using Dylan terminology: it does 
not export slot getters and setters).  You can individually choose to 
export or not export the accessors for any slot -- and you can export 
the ability to read a slot (the "getter") without exporting the ability 
to assign to the slot (the "setter").  You can even export the ability 
to assign to the slot without exporting the ability to *read* it, if 
you're that perverse.

Anything that is in the same module has full and total access to the 
class.  Effectively, everything in the same module is a "friend".

-- Bruce



Follow-Ups: References: