Re: Re: Strings for operators
Stefano Corsi <[email protected]> Mon, 12 May 2003 00:42:10 +0000
| Newsgroups | gmane.comp.lang.moto.devel |
|---|---|
| Organization | Moto Project |
| Message-ID | <[email protected]> |
> On Friday, May 9, 2003, at 09:38 AM, Stefano Corsi wrote:
> >> Here is something else worth thinking about with regard to operator
> >> overloading. Would it be possible to take out all the custom code in
> >> motoi and motoc for string addition (and addition of elementary type=
s
> >> to strings) and replace it with overloaded operation functions ?
I've tried and it works fine. We don't even need to delete the addition c=
ode=20
in motoi_domath, because the operator is discovered and used in motoi_mat=
h,=20
called before.
Ehm... by the way, seems a 20% slower.
This is also funny:
${
String a =3D "abcdefghilmnopqrstuvz";
print a[10];
}$
prints 'm' with this operator defined:
char String::[](int index) =3D>
char mxstr_charAt(const char *s, int index);
while:
${
String a =3D "abcdefghilmnopqrstuvz";
a[1] =3D 'z';
print a;
}$
prints 'azcdefghilmnopqrstuvz' with this other:
char String::[](int index, char c) =3D>
char mxstr_replaceCharAt2(char *s, int index, char c);
Stefano