AdeptLanguage / Adept

The Adept Programming Language
GNU General Public License v3.0
121 stars 9 forks source link

Undeclared type 'int' #35

Closed ghost closed 3 years ago

ghost commented 3 years ago

@IsaacShelton

a POD <$T> int

result:

Undeclared type 'int'
IsaacShelton commented 3 years ago

@t0md3an This is because int is not a polymorphic type. int can only be used as:

a int

The <$T> only applies to polymorphic types.

MyArray :: struct <$T> (items *$T, length usize)

main :: {
    a <int> MyArray
}

This is equivalent templates in C++:

template <typename T>
struct Array {
    T* items;
    size_t length;
};