[891] in Coldmud discussion meeting

root meeting help first previous next next in chain last in chain last

[COLD] Operator overloading

daemon@ATHENA.MIT.EDU (Wed Jan 10 08:13:38 1996 )

Date: Wed, 10 Jan 1996 14:00:11 +0100
From: silovic@srce.hr (Miroslav Silovic)
To: coldstuff@tombstone.sunrem.com
Reply-To: coldstuff@tombstone.sunrem.com


I don't have the new source on me, but in 2-10, there's 

    if (d1->type == INTEGER && d2->type == INTEGER) {
        /* Replace d1 with d1 + d2, and pop d2. */
        d1->u.val += d2->u.val;
    } else if (d1->type == FLOAT && d2->type == FLOAT) {
        d1->u.fval += d2->u.fval;
    } else if (d1->type == STRING && d2->type == STRING) {
        anticipate_assignment();
        d1->u.str = string_add(d1->u.str, d2->u.str);
    } else if (d1->type == LIST && d2->type == LIST) {
        anticipate_assignment();
        d1->u.list = list_append(d1->u.list, d2->u.list);
    } else {
        cthrow(type_id, "Cannot add %D and %D.", d1, d2);
        return;
    }
    pop(1);

for addition. So, cthrow could be replaced with the method call on the
first argument (I don't feel like rummaging through the source to find
the exact recipe. :) ) Brandon, can this be done?

	Miro