This page is no longer maintained — Please continue to the home page at

A design question when using stackable trait

No replies
linjie nie
Joined: 2009-06-17,
User offline. Last seen 42 years 45 weeks ago.
Hi list -
being new to Scala, I have a design question when using stackable trait.
I have a class here -

class Executor [T <: Task] {
  def add(task: T) = {

And then, I'd like to have a 'wrapper' on this, to do with logging of task executing.
Something like this -

trait ExeLoger[T <: Task ] extends Executor[T] {
  override abstract def add(task: T) = {
    println + "added"// I want to add a shower for task here


As the comment on the println line, I want a class type for show task here.
So I modified the trait like this -

trait ExeLoger[T <: Task : Descriptor ] extends Executor[T]

But this doesnt compile. Saying that 'traits cannot have type parameters with context bounds `: ...' nor view bounds `<% ...''
So, gurus, could please give me some advise? How to design to solve this problem?
Is this a right place to use stackable trait?

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland