[ nice-Feature Requests-1124210 ] Tuple usage
"SourceForge.net" <[email protected]> Tue, 22 Feb 2005 12:11:09 -0800
| Newsgroups | gmane.comp.lang.nice.devel |
|---|---|
| Message-ID | <[email protected]> |
Feature Requests item #1124210, was opened at 2005-02-16 11:16
Message generated for change (Comment added) made by nobody
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=362788&aid=1124210&group_id=12788
Category: None
Group: None
Status: Open
Priority: 5
Submitted By: Peter Wilson (peterwilson)
Assigned to: Nobody/Anonymous (nobody)
Summary: Tuple usage
Initial Comment:
Make access to tupple contents easier. I believe Groovy
has this feature:
Taken from manual.html:Example 7.2. Method returning
several values using a tuple
#1 usage improvement: allow local variables on tupple
returns:
declaration:
(int, int) minMax(int x, int y) = x < y ? (x, y) : (y, x);
use:
(x, y) = minMax(3,5); // not very convincing for this
function.
println("(" + x + ", " + y + ")");
#2 usage improvement: allow local variables on tupple
arguments:
void printTuple((int x, int y) tuple)
{
// /** Declare two local variables, and assign to each
the //corresponding value
// in the tuple.
// */
// (int x, int y) = tuple;
println("(" + x + ", " + y + ")");
}
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2005-02-22 12:11
Message:
Logged In: NO
My misunderstanding. - From your reply, the current usage
is fine.
However, example 7.2 in the User's Manual is misleading as
it fails to use feature #2. It should be updated, or shown
as an alternative.
----------------------------------------------------------------------
Comment By: Daniel Bonniot (bonniot)
Date: 2005-02-22 09:15
Message:
Logged In: YES
user_id=88952
I'd like to ask for some clarifications:
For #1:
You can already do
(x, y) = minMax(3,5);
provided that x and y are previously declared. You can also
declared them at that spot with:
(int x, int y) = minMax(3,5);
Is that you want to be able to declare them without
specifying the type? I believe this could be useful, but a
specific syntax should be used to make that clear.
Consistently, this should be
let (x, y) = minMax(3,5);
and
var (x, y) = minMax(3,5);
for constant and variables, respectively.
Does this correspond to what you expected?
For #2:
Unless I'm mistaken, what you are asking for is already
possible:
void printTuple((int x, int y) tuple)
You can even leave the name 'tuple' out since it is not used:
void printTuple((int x, int y))
Is that so? Is this missing from the documentation?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=362788&aid=1124210&group_id=12788
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click