[M3devel] small objects
hendrik at topoi.pooq.com
hendrik at topoi.pooq.com
Thu Apr 9 21:43:37 CEST 2009
On Thu, Apr 09, 2009 at 08:27:11AM -0700, Mika Nystrom wrote:
>
> hendrik at topoi.pooq.com writes:
> >>
> >> Note that, as we probably all know, the Modula-3 designers expressly
> >> considered, and rejected, full variant records.
> >
> >Are these the factors they based their decision on?
> >
> >(1) The ones in Pascal are insecure without a lot of run-time checking.
> >
> >(2) Objects and inheritance take care of much of the functionality.
> >
> >(3) The ones in Algol 68 involve copying entire records when
> >construction and deconstructing unions of records.
>
> (1) and (2) at least. I'll quote:
>
> "[talk about runtime errors due to freeing still-used references]
>
> Another well-known runtime error is to assign to the tag of a variant
> record in a way that subverts the type system. Distinguishing
> subversive assignments from benign assignments in the language
> definition is error-prone and arbitrary.
If I recall the Pascal definition correctly, the only assignment that
was allowed to the tag of a variant was to assign the entire record,
including the tag and the variant. I don't know of any Pascal compiler
that even tries to check this.
> The objects and classes
> first introduced in Simula and adopted in Oberon and Object Pascal
> are more general than variant records, and they are safe, so we
> have discarded variant records and adopted objects.
>
> [talk about objects]"
>
> (See Cardelli et al., "The Modula-3 Type System" (c) 1989 ACM.)
>
> Mika
>
> >
> >What we're considering not is the case in which (2) provides
> >excessive indirection and garbage-collector load, and in which
> >the copying in (3) is really cheap. There are applications
> >for which this feature could have major effects on efficiency.
> >I have some I'd consider rewriting from C/C++ to Modula 3
> >if this feature were available.
> >
> >-- hendrik
> ....
More information about the M3devel
mailing list