archives

Dynamic inheritance?

Consider class C that inherits from class B in a (statically) typed language. I would like to extend, at runtime, an instance of type B to type C:

    B b = new B();
    Assert(b is B);
    b.Method(); // invokes B.Method() 

    extend b to C();  // partial constructor for C
    Assert(b is B);
    Assert(b is C);
    b.Method(); // invokes C.Method() override 

Is there any reason why this should not be allowed in terms of type safety? If not, what is it called and is there any language out there that supports this?

Heap space analysis for garbage collected languages

Heap space analysis for garbage collected languages, by Elvira Albert, Samir Genaim, Miguel Gómez-Zamalloa:

Accurately predicting the dynamic memory consumption (or heap space) of programs can be critical during software development. It is well-known that garbage collection (GC) complicates such problem. The peak heap consumption of a program is the maximum size of the data on the heap during its execution, i.e., the minimum amount of heap space needed to safely run the program. Existing heap space analyses either do not take deallocation into account or adopt specific models of garbage collectors which do not necessarily correspond to the actual memory usage. This paper presents a novel static analysis for garbage collected imperative languages that infers accurate upper bounds on the peak heap usage, including exponential, logarithmic and polynomial bounds. A unique characteristic of the analysis is that it is parametric on the notion of object lifetime, i.e., on when objects become collectible.

Similar work has been covered here in the past.