Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Eiffel > Re: generics wi...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 8 Topic 818 of 927
Post > Topic >>

Re: generics with multiple constraints

by "Bernd Schoeller" <google_my@[EMAIL PROTECTED] > Sep 1, 2006 at 04:17 AM

On Fri, 01 Sep 2006 00:00:17 +0200, Felix Breuer <felix@[EMAIL PROTECTED]
> wrote:
> suppose I want to create a generic class
>
>   A [B -> COMPARABLE  & HASHABLE]
>
> meaning that I want classes B that can act as a parameter to A
> to descend from both COMPARABLE and HASHABLE. How can I
> achieve this? Eiffel's syntax seems to allow only one constraint per
> formal parameter. Is there some workaround? This looks like a fairly
> standard situation to me, so maybe someone encountered this
> before?
>
> Thanks,
> Felix

This is currently not possible and also conceptually not as easy as it  
seems: what is the static type of a variable declared 'b : B'? What are  
the features that can be called on it?

A workaround might be to declare 'A[B->COMPARABLE]' and to use assertions 

for the conform type checks for HASHABLE. Not nice, no static typing ...

Bernd

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
 




 8 Posts in Topic:
generics with multiple constraints
"Felix Breuer"   2006-08-31 15:00:17 
Re: generics with multiple constraints
"Bernd Schoeller&quo  2006-09-01 04:17:02 
Re: generics with multiple constraints
Gerald Hammer <Gerald.  2006-09-01 10:40:15 
Re: generics with multiple constraints
"@[EMAIL PROTECTED]   2006-09-01 18:55:40 
Re: generics with multiple constraints
Gerald Hammer <Gerald.  2006-09-01 21:50:34 
Re: generics with multiple constraints
"Damian D." <  2006-09-01 02:00:06 
Re: generics with multiple constraints
Gerald Hammer <Gerald.  2006-09-01 11:14:47 
Re: generics with multiple constraints
"Bernd Schoeller&quo  2006-09-01 20:23:01 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Jul 9 5:51:26 CDT 2008.