Re: Can this be done with a conversion operator in C++ ?
class A {
operator B() const {return B(...);}
};
However, this needs to be placed in the converted-from class, which
contradicts your earlier requirement that class A should not be modified.
I see that you were getting the point I tried to make in my post.
I guess it is possibly quite hard to maintain a
large Scala codebase over time, is this so?
The piece of Scala code I pasted in this thread was the second Scala progra=
m I wrote the first one being the mandatory "hello world" program. I just w=
rote the sample code in this topic to verify that I got the point with impl=
icits in Scala. So I can't even make a qualified guess to answer your quest=
ion. Well, what I can say is that the Scala books recommend to handle impli=
cits with care. So the problems seems to be understood. One of the biggest =
Scala apps seems to be Akka (akka.io). But these guys will for sure tell yo=
u nothing else except for that Scala is fantastic ;-).
The implicit conversion operators in Scala seem to be much more automatic=
and actually quite scary.
I'm currently looking at Kotlin (http://kotlin.jetbrains.org/) where implic=
its are explicitly not part of the language and at Scala as some replacemen=
t for Java which just cannot keep pace with other modern programming lanuga=
ges out there.
Currently, I'm trying to make up my head whether implicits are an argument =
for or against Scala. It is easy to jump to conclusions, but it is not easy=
to make a well-based decision. I did a lot of development in Smalltalk. In=
Smalltlak you can do something like this:
2 become: 3
This will make every number with the value 2 in your system change to 3. In=
evitably, your system will shut down after evaluating this line of code. Ne=
vertheless, Smalltalk IMHO is a very sound language. But I agree that those=
things are scary and should be handled with great care.
Regards, Oliver