You can do this with traits:
trait Foo
trait Bar <: Foo
I'm not exactly sure about its nature, I think it's called virtual
classes, because:
class Baz <: Foo
<console>:1: error: classes are not allowed to be virtual
class Baz <: Foo
^
On 01/14/2015 09:08 PM, Fiery wrote:
> Just one of my thinking being around there for quite a while about
> extending the concise style of other part of Scala language specs,
> "extends" just looks verbose and I personally took it as one typical
> Java expression.
> I admit that I got too tried of Java's verbosity and I feel very much
> excited about making changes thru Scala's expressiveness and simplicity.
>
> Just take a look at languages that considered more modern, like Python:
>
> class sub_class(super_class) .....
>
> like Ruby:
> class SubClass < SuperClass .....
>
> these are languages from which Scala get some of the syntax inspiration.
>
> Plus, using colon makes it look more consistent with Scala's type system:
>
> val word: String = "Hello"
> var iter *:* Int = 1
> def func *:* String = "I am a string"
> val func *:* Int = { num *:* Int => num }
>
> and take a look at what it will be like if use colon to replace extends:
>
> class MoreString(val more *:* String, val count *:* Int) *:* String
> {.........}
>
> I like using "with" to differentiate trait from class, here is how to
> mixin traits.
> class MoreStrongString(val more *:* String, val count *:* Int) *:*
> String with StrongFeature {.........}
>
>
> I understand that colons in Scala means slightly differently as what I
> suggest with class inheritance, but look at function result type, it's
> also a little different from the type for val/var. So there is nothing
> to lose with a more beautifully simple and clean world.
>
> --
> You received this message because you are subscribed to the Google
> Groups "scala-language" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
scala-languag...@googlegroups.com
> <mailto:
scala-languag...@googlegroups.com>.
> For more options, visit
https://groups.google.com/d/optout.