[Prev][Next][Index][Thread]
Re: Sealed as Source Annotation
"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?
> 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?
> Thus Dylan programmers only have this problem when they want to extend
> someone *else's* sealed class
Ahhh. Thus the basis for TOM, where _everything_ can be extended upon,
even compiled libs.
> is these properties of <integer> that allows the Dylan compiler to
> automatically use "int" instead of "Integer" in many places in the
> compiled code, and automatically and transparently switch between them
> on assignment, passing function arguments, putting them into collections
> etc.
Ahhh.
> 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? Or does
Dylan address this?
Maury
Follow-Ups:
References: