Documentation for usage of "abstract" keyword (especially on methods)


Where can I find documentation of how to use the “abstract” keyword in the C3 Type System? I thought it was equivalent to the “abstract” keyword in Java, but there must be some subtle differences that I’m failing to grasp.

I have a NON-ABSTRACT Type A mixing in an abstract Type B with abstract method M. However, Type A does not implement the abstract method M. This should be an error, but I CAN provision the package with type A. And in fact, I can make an object of type A (of course, you can’t call the method on type A, because it’s not defined).

What does the “abstract” keyword on a method mean? If we can’t ensure that the method is defined on any non-abstract subclasses, does declaring an abstract method serve any purpose?

My understanding of using abstract classes and interfaces comes from:
"When an abstract class is subclassed, the subclass usually provides implementations for all of the abstract methods in its parent class. However, if it does not, then the subclass must also be declared abstract."



I think it has nothing to do with the abstract as know in programming languages like Java.
For instance AbstractDataset is an abstract type, defined as

abstract type AbstractDataset mixes AbstractTensor

Yet you can create instances of this type as of any other C3 type, (something you can’t do with abstract Java classes):

var ad = AbstractDataset.make({shape: [1]})

C3.typesys.Obj {shape: Array(1), axes: Array(0), indices: C3.t…s.Map}



Wow, I didn’t think you could make AbstractDataset, but I just tried your command on the JS console and it works (!). I wondered if this might be peculiar to the JS client, that it’s not being strict on what can be made (I also tested “type A” in the JS console when I made my post). But looking at the code-gen code for in c3server, it does have a make() function.

Now I’m really confused about the purpose of the “abstract” keyword… I thought I had understood it when used on Types, but maybe I don’t understand it at all.



You are correct that is the intention. We don’t have full validation yet, but it’s coming. We are also working on “final” and “default” to provide a full set of options. The “Method Declaration” documentation topic has a description of the model.

1 Like