#1071 Implicit conversions

f_lombardo Sat 10 Apr 2010

I think that one of the most interesting features of Scala are implicit conversions. What do you think about adding them to Fantom?

Thanks

Bye

Franco

brian Sat 10 Apr 2010

There is a whole lot of features to love about Scala, but in my opinion implicit conversions isn't one of them. Code is meant to be easily read and understood, and implicit conversions seems to go against that goal. Plus implicit conversions would never work well with Fantom's auto-casting. My goal in Fantom is to create a small, concise standard library which avoids the need to convert from one type to another all the time.

f_lombardo Mon 12 Apr 2010

I agree with you that implicit conversions could make code less readable, but they are a great tool to extend libraries without changing or inherit from them. I mean, It's a tool that goes in the direction of the Open Close Principle without the problems that inheritance creates. Pleas, give them a second chance :-)

Thanks

Bye

Franco

helium Mon 12 Apr 2010

C#'s extension methods give you the same ability to add methods without changing or inheriting.

brian Mon 12 Apr 2010

My personal opinion is that automatic coercing between types is a poor solution for adding methods to existing types.

As Helium said, the best solution I've seen to that problem is C# extension methods. In fact that is almost the exact design I've envisioned for Fantom (probably not a 1.0 thing, but maybe a 1.1 thing)

f_lombardo Mon 12 Apr 2010

I'm really eager to see extension methods in Fantom!

Thanks

Bye

Franco

Login or Signup to reply.