I see no need to let FUNCTION_DEF_BUILTIN inherit from BUILTIN_FUNCTIONS

Description

I don;t know why that is, it is a singleton, and inheriting from a singleton can cause wildgrow of objects, and being a singleton is just that to avoid.

Environment

None

Activity

Show:
Thomas Beale
June 21, 2016, 4:22 PM

I have diagrammed this in the way we do it in Eiffel, which has built-in singletons. I forget completely that this doesn't work in most languages. I'll adjust the structures according to this kind of pattern https://sourcemaking.com/design_patterns/singleton

Bert Verhees
June 21, 2016, 4:55 PM
Edited

Sorry for rewriting this, I will now try less confusing.

The purpose of the singleton class is to have the definitions in the hashmap only once, but inheriting from as singleton class contradicts this, because the class will be constructed more times and the hashmap will exist more times.

The right way is, I think, do not make the class singleton, so one can inherit from it without side-effects. Make the hashmap static. In many languages (Java and C, C++) this means that it will be instantiated and loaded in memory only once at the start of a program, and all calls, even from inherited classes, will see the same hashmap.

The class in which the hashmap is only has the purpose to make the hashmap accessible in inheritance and hide it from classes which have not inherited, the hashmap can be defined protected

Reporter

Bert Verhees

Labels

None

Components

Affects versions

Priority

Major
Configure