Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

  • py: Use the 'py' keyword to indicate this is a Python function.
  • js: Use the 'js' keyword to indicate this is a JavaScript function.

Currently, these are the only two languages which the C3 AI Suite supports for native method definitions

...

Inheritance

Inheritance

Like many modern languages, Types can also inherit fields and methods from other types in an object oriented fashion. The keywords which signal inheritance are `mixes` and `extends`. These follow the name of the new type.

Where C3 Type inheritance differs from other languages, is that these two keywords signal two different types of inheritance.

Mix-ins

This most basic type of inheritance is signaled by the 'mixes' keyword. When a type 'mixes' another type, it inherits all of the fields and methods of that type. The new type gets its own schema and table, and the user can go on to use it as they normally would.

Code Block
type ParentType {
    fieldA: int
    funcA: function(): ReturnType
}

type ChildType mixes ParentType {
    fieldB: double
    funcB: function(): ReturnType
}

In this example, ChildType also includes the field and method defined in the parent type.

Persistable Inheritance

This second type of inheritance is signaled by the 'extends' keyword. When a type 'extends' another type, it inherits its fields and methods, but also resides in the same schema and table as the original type. In fact, a type can only extend a type which has been marked as `extendable`.

Code Block
extendable entity type ParentType schema name "PRT_TYP" {
    fieldA: int
    funcA: function(): ReturnType
}

entity type ChildType extends ParentType type key "CHLD" {
    fieldB: double
    funcB: function(): ReturnType
}

In this example, ParentType is an extendable Persistable type stored in schema 'PRT_TYP'. ChildType extends ParentType and uses type key 'CHLD'.

Annotations

C3.ai developer resources on Annotations:

Examples

Look through the lightbulbAD package and find .c3typ files. Look at these to see the range of possibilities