operator overloads in types #583

nddrylliog opened this Issue Feb 14, 2013 · 2 comments


None yet

2 participants


ie. be able to write that:

MyArray: cover template <T> {
    length: Int
    data: T*

    init: func@ (=length) {
        data = gc_malloc(T size * length)

    get: func (index: Int) -> T {

    set: func@ (index: Int, value: T) {
        data[index] = value

    _checkIndex: func (index: Int) {
        if (index < 0 || index >= length) {
            Exception new("Out of bounds array access: %d should be in %d..%d" \
                format(index, 0, length)) throw()

    operator [] (i: Int) -> T {

    operator []= (i: Int, v: T) {
        set(i, v)

It'll also fix weird things like: using a lib that returns a List, and then you try to index it with [] but it doesn't work because you don't import ArrayList/List yourself.


Cough cough #33 cough cough


Closed in 6ec80f5

@nddrylliog nddrylliog closed this Feb 14, 2013
@nddrylliog nddrylliog added a commit that referenced this issue Feb 14, 2013
@nddrylliog nddrylliog Make all other operators work in-class. cf. #583 (or #33 for that mat…
…ter). Still no inheritance.. will see about that laterz.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment