david.h...@gmail.com
unread,Aug 21, 2015, 6:55:06 AM8/21/15Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message as abuse
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ooc-lang
//testfile.ooc
Foo: cover {
number: Int
init: func@ (=number)
}
// version 1
operator += (left: Foo@, right: Foo) { left number += right number }
// version 2
operator -= (left: Foo, right: Foo) -> Foo { Foo new(left number -= right number) }
foo := Foo new(1)
bar := Foo new(2)
foo += bar
foo number toString() println()
Version 2 results in the number 1 being printed, and not 3. This is, perhaps, the expected behavior, though.
Version 1 gives me the error
/home/dhesselbom/versioned/rock/./testfile.ooc: In function ‘___testfile_load’:
/home/dhesselbom/versioned/rock/./testfile.ooc:9:9: error: incompatible type for argument 1 of ‘___testfile____OP_ADD_ASS_Foo__star_Foo’
foo += bar
^
In file included from .libs/ooc/./testfile/./testfile.h:7:0,
from rock_tmp/ooc/./testfile/./testfile.c:3:
.libs/ooc/./testfile/./testfile-fwd.h:33:6: note: expected ‘struct ___testfile__Foo *’ but argument is of type ‘___testfile__Foo’
void ___testfile____OP_ADD_ASS_Foo__star_Foo(___testfile__Foo* left, ___testfile__Foo right);
^
C compiler failed on module ./testfile from ./testfile, bailing out
So apparently I'm doing something wrong here, but I'm *positive* this used to work in older versions of rock (unfortunately, I can't verify it now since I'm unable to build anything older than v0.9.10 for various reasons).
So, is either the correct way to implement the += operator for covers, currently?