Thought on typecase

I find it uncomfortable that it is not easy to select a parameterized
type with a typecase. Suppose:
trait X[\T extends Y\] end
then I can't specify a clause that matches any instantiation of X. It
is possible to create an additional nonparametric trait that X
extends, but it isn't practical nor nice to do so just to be able to
use typecase. I could do
trait X[\T extends Y\] extends X[\Y\] end
but leads to a stack overflow if I then use X[\Y\] (just as trait Z
extends Z end does). I can create a ticket for this if it's
appropriate, but the question could be whether it is legal to declare
that a trait extends itself (doesn't it always?).

Re: Thought on typecase

In fact, creating a supertype of X is not helpful, because in the type
clause I want to be able to use members of X. For example:

component TypecaseFrustration

trait Super end

trait Y end

trait X[\T extends Y\] extends Super
    f(): () = println "f()"
end

run(args) = do
    x = object extends X end
    typecase x of
        Super => () (* can't call x.f() here *)
    end
end

end

On Fri, Jun 6, 2008 at 11:21 PM, Sorin Miklós Zsejki
<zsejki@...> wrote:
> I find it uncomfortable that it is not easy to select a parameterized
> type with a typecase. Suppose:
> trait X[\T extends Y\] end
> then I can't specify a clause that matches any instantiation of X. It
> is possible to create an additional nonparametric trait that X
> extends, but it isn't practical nor nice to do so just to be able to
(Continue reading)


Gmane