Re: Overloading (CVS commit) - Relationals implemented
Stefano Corsi <[email protected]> Tue, 29 Apr 2003 10:54:10 +0000
| Newsgroups | gmane.comp.lang.moto.devel |
|---|---|
| Organization | Moto Project |
| Message-ID | <[email protected]> |
Alle 01:09, marted=EC 29 aprile 2003, David Hakim ha scritto:
> The reason I didn't overload =3D=3D for strings when coding conditional=
s
> originally is that I felt there was value in always being able to test
> pointer equality of two objects with =3D=3D since there are cases wher=
e
> you want to verify you have the same instance of an object (as opposed
> to an equivalent object).
>
> So I'm wondering now if we want to make =3D=3D overloadable at all sinc=
e
> its default behavior is applicable to all objects by default, and
> instead offer overloading only of the 'eq' operator and the other
> string comparison operators so they really become 'programmatic object
> comparison operators'
You are probably right. The change is very easy, because I suppose we onl=
y=20
need to operate on this switch in motox.c and get rid ov all ..._M cases:
switch (op) {
case REL_GT_S:
case REL_GT_M:
fbasename =3D moto_strdup(env, "_gt"); break;
case REL_LT_S:
case REL_LT_M:
fbasename =3D moto_strdup(env, "_lt"); break;
case REL_EQ_S:
case REL_EQ_M:
fbasename =3D moto_strdup(env, "_equal"); break;
case REL_NE_S:
case REL_NE_M:
fbasename =3D moto_strdup(env, "_notequal"); break;
case MATH_ADD:
fbasename =3D moto_strdup(env, "_plus"); break;
case MATH_SUB:
fbasename =3D moto_strdup(env, "_minus"); break;
default:
fbasename =3D NULL;
}
then add something in mx.l.
>
> What does
>
> iset1 < iset2
>
> mean ? Is it based on the size of the sets ?
Yeah, I needed some simple example for relational ops and I choosed to co=
mpare=20
sets by size, even if maybe other criteria could be a choice... the sum o=
f=20
all ints for example? The biggest int? My algebra is still at an elementa=
ry=20
level!
Stefano