Talk About Network



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: TUPLE
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 5 Topic 850 of 913
Post > Topic >>

Re: TUPLE

by "Greg C" <gmc444@[EMAIL PROTECTED] > Feb 15, 2007 at 05:29 PM

On Feb 1, 2:04 pm, toto <stop-aux-sp...@[EMAIL PROTECTED]
> wrote:
> ECMA allows to declare
>
>         x: TUPLE[count, balance: INTEGER; name, forname: STRING]
>
> My question is: "how useful is it?".
>
> regards

Very useful for setting up lookup tables. Consider this sketch of an
enumeration (stream of consciousness code that's badly formatted and
untested, to get to the point):

class MONTH create make

feature make (a_id: INTEGER) is do id := a_id end

  id: INTEGER

  name: STRING is do Result := table[id].name end

  long_name: STRING is do
    Result := table[id].long_name
    if Result = Void then
      Result := name
    end
  end

feature {NONE} -- Implementation (the point)

  table: TUPLE[id: INTEGER; name, long_name: STRING] is once
    Result := <<
       [ 1, "Jan", "January" ],
       [ 2, "Feb", "February" ],

           -- and so one
    >>
  end

invariant

  valid_id: id >= 1 and then id <= table.count

end




 5 Posts in Topic:
TUPLE
toto <stop-aux-spams@[  2007-02-01 22:04:40 
Re: TUPLE
Peter Horan <peter@[EM  2007-02-02 06:51:07 
Re: TUPLE
J <totuti456@[EMAIL PR  2007-02-02 16:21:46 
Re: TUPLE
"llothar" <l  2007-02-02 15:13:28 
Re: TUPLE
"Greg C" <gm  2007-02-15 17:29:58 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan12V112 Sat May 17 2:05:15 CDT 2008.