[Prev][Next][Index][Thread]
Re: Sealed as Source Annotation
In article <963624615.108986@nnrp.gt.ca>, "Maury Markowitz"
<maury@remove_this.sympatico.ca.invalid> wrote:
> "Bruce Hoult" <bruce@hoult.org> wrote in message
> bruce-171C44.12310614072000@news.akl.ihug.co.nz">news:bruce-171C44.12310614072000@news.akl.ihug.co.nz...
> > You will know, but I expect most Java programmers won't, that a sealed
> > class in Dylan *can* be extended, but only within the same compile
> > unit.
>
> As one that is similarily newbie to Dylan as the original poster, what
> does htis "mean" in terms I may be more familiar with? Does "compile
> unit" map onto "package" well?
"Compile unit". Literally, whatever unit of source code you compile at
one time, so that the compiler can see all the definitions at once and
make optomizations between mutually-dependent things.
In Dylan, a "library" consists of a number of source files, all of which
are read at the same time by the compiler (ok, it parses them all, and
then optomizes them all, and then generates code for them all) and which
produce e.g. a single DLL.
> > In the case of Dylan, a large part of the reason for having "sealing"
> > is to enable more static, faster, code to be generated.
>
> Why is this? I understand a little of the reasoning in Java, but much
> of this is foreign to my Obj-C experience - the only language/runtime
> I feel I have any basic grasp on it's inner workings. This
> information does what to the compiler's output exactly? Does it
> increase dispatch times?
Why? Because without it Dylan would run as slowly as Java while with it
Dylan runs as fast as C.
> > What Dylan *does* do, is to provide unsealed base classes for all the
> > sealed classes in the runtime library. So <integer> is a subclass of
> > <number> and <byte-string> is a subclass of <string>. The user is free
> > to create new subclasses of <number> and <string>. If you write code
> > that has variables and function arguments declared as <number> and
> > <string> then you can pass objects of user-defined classes into them,
> > but your code will be slower than if you use <integer> and
> > <byte-string>.
>
> While this can often address the problem on the code side, it doesn't
> help the tools side much. For instance, what if you have a IDE tool that
> generates something using a byte-string, but you need to add to it?
Add to it in what way?
You can't subclass <byte-string>, but you can of course add new methods
to it.
-- Bruce
References: