Skip to content

There should be an AbstractObject class #3467

@telephon

Description

@telephon

We could extend sclang's flexibilty considerably if we'd added AbstractObject, a superclass for Object. This class would only support a minimal interface of methods (mainly for introspection). This would follow the idea of Ruby's BasicObject.

By default, all classes would still inherit from Object. By inheriting from AbstractObject, it would be possible to build alternative behaviours for objects which are not currently possible.

The most immediate practical impact would be that we could make Object prototyping safe (currently, pseudo-methods may be overridden later by a class extension of any class above Event).

I have written number of experimental classes with a similar approach, which is to be found here: https://github.com/telephon/Neutral

The current inheritance scheme:
Object ––superclass–> nil
Meta_Object ––superclass–> Class

The new inheritance scheme would be:
Object ––superclass–> AbstractObject ––superclass–> nil
Meta_Object ––superclass–> Meta_AbstractObject ––superclass–> Class

Side Note: a primitive for directly forwarding a method call to a different receiver unchanged would make the implementation very efficient, and could make it an alternative to method extensions.

(was: #1831)

Metadata

Metadata

Assignees

No one assigned

    Labels

    comp: class librarySC class librarycomp: sclangsclang C++ implementation (primitives, etc.). for changes to class lib use "comp: class library"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions