requestCall append with manifest arrays on some container classes

Consider this code fragment:

 

This fails with a compilation error because {LINKED_LIST}.append only takes objects of type SEQUENCE[G], yet an array does not conform to type SEQUENCE. And in fact, I don't see any easy way of getting a manifest array into a SEQUENCE. For example, I can't say:

 

This seems like an unnecessary restriction and there are several ways it could be resolved. Off the top of my head:

  1. Allow manifest arrays to conform to sequences.
  2. Change append() to take a COLLECTION, a common ancestor to SEQUENCE and ARRAY.
  3. Streamline the base library; the proliferation of container abstractions may be interesting from a theoretical perspective, but in practice I think it tends to lead to cluttered inheritance hierarchies and overly-complex code that performs type conversions that aren't really necessary. (I know this is also the least likely alternative because of its broad impact but I think it may still be a desirable long-term goal.)


Note: I copied this request from Greg's request from Eiffel support website

2.4
Your rating: None Average: 2.4 (5 votes)

Comments

I prefer way 2, change the

I prefer way 2, change the `append'. But don't know how to query items in {COLLECTION}...

In the meantime, you can do

manus_eiffel's picture

In the meantime, you can do

a_list.append (create {ARRAYED_LIST [STRING]}.make_from_array (<< "one", "two", "three">>))

Syndicate content