- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Is there a type bound that makes this work?
Thu, 2009-10-08, 09:06
Dear Scalarazzi,
trait ToDo[ToBe <: ???] { object Body extends ToBe }
Best wishes,
--greg
--
L.G. Meredith
Managing Partner
Biosimilarity LLC
1219 NW 83rd St
Seattle, WA 98117
+1 206.650.3740
http://biosimilarity.blogspot.com
trait ToDo[ToBe <: ???] { object Body extends ToBe }
Best wishes,
--greg
--
L.G. Meredith
Managing Partner
Biosimilarity LLC
1219 NW 83rd St
Seattle, WA 98117
+1 206.650.3740
http://biosimilarity.blogspot.com
Thu, 2009-10-08, 09:37
#2
Re: Is there a type bound that makes this work?
this works with AnyRef as type bound
trait ToDoModule { type ToBe ; trait ToDo[ToBe <: AnyRef] }
class Foo
object ToDoModuleWithFoo
extends ToDoModule { type ToBe = Foo ; object ToDo extends Foo }
it is, more involved than Miles suggestion
2009/10/8 Miles Sabin <miles [at] milessabin [dot] com>
--
__~O
-\ <,
(*)/ (*)
reality goes far beyond imagination
trait ToDoModule { type ToBe ; trait ToDo[ToBe <: AnyRef] }
class Foo
object ToDoModuleWithFoo
extends ToDoModule { type ToBe = Foo ; object ToDo extends Foo }
it is, more involved than Miles suggestion
2009/10/8 Miles Sabin <miles [at] milessabin [dot] com>
2009/10/8 Meredith Gregory <lgreg [dot] meredith [at] gmail [dot] com>:
> trait ToDo[ToBe <: ???] { object Body extends ToBe }
You can't extend a type parameter or abstract type member directly,
but you can get an equivalent effect using abstract members and
refinements,
trait ToBe
trait ToDo { val Body : ToBe }
trait MyToBe extends ToBe
new ToDo { object Body extends MyToBe } // encoding of new ToDo[MyToBe]
Cheers,
Miles
--
Miles Sabin
tel: +44 (0)7813 944 528
skype: milessabin
http://www.chuusai.com/
http://twitter.com/milessabin
--
__~O
-\ <,
(*)/ (*)
reality goes far beyond imagination
2009/10/8 Meredith Gregory :
> trait ToDo[ToBe <: ???] { object Body extends ToBe }
You can't extend a type parameter or abstract type member directly,
but you can get an equivalent effect using abstract members and
refinements,
trait ToBe
trait ToDo { val Body : ToBe }
trait MyToBe extends ToBe
new ToDo { object Body extends MyToBe } // encoding of new ToDo[MyToBe]
Cheers,
Miles