Hi -
Sorry to be asking a Scala syntax question here in the Lift group, but
I figured somebody here would know, since this Scala syntax occurs
quite a bit in the Lift source code.
When reading some of the Lift source I come across a particular Scala
"idiom" involving parameterized types with bounds, whose semantics I'm
unsure of.
For example:
class MappedTextarea[ T <: Mapper[ T ] ] ( owner : T, maxLen: Int )
extends
MappedString[ T ]( owner, maxLen ) { ... }
What I'm unsure about here is the part where it says:
T <: Mapper[ T ]
At first, this made no sense to me - how could a type T be a subtype
of type Mapper[ T ] ?
Then I guessed that maybe the two occurrences of T are unrelated to
each other - ie, class MappedTextarea is parameterized over a type T,
which must be a subtype of a type Mapper[ T ] -- where the second T is
actually in a separate scope so that it has nothing to do with the
first T.
Is that what this really means?
And, if that's really the case, then I guess the other occurrences of
T later in the text:
owner : T
MappedString[ T ]
are also referring to the first occurrence of T -- the type T which is
upper-bounded by type Mapper[ T ].
Finally, does this mean that the above code could also have been
written equivalently as follows:
class MappedTextarea[ T <: Mapper[ U ] ] ( owner : T, maxLen: Int )
extends
MappedString[ T ]( owner, maxLen ) { ... }
using U instead of T for the type parameter that's in a separate
scope?
Thanks for any help.
- Stefan Scott
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---