[ nice-Bugs-1427169 ] Missing get method for slicing
"SourceForge.net" <[email protected]> Tue, 27 Jun 2006 10:48:41 -0700
| Newsgroups | gmane.comp.lang.nice.devel |
|---|---|
| Message-ID | <[email protected]> |
Bugs item #1427169, was opened at 2006-02-08 07:42
Message generated for change (Comment added) made by ben77
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112788&aid=1427169&group_id=12788
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: Missing get method for slicing
Initial Comment:
The release notes for 0.9.9 claim that one can slice
lists. However, there seems to be no get method in the
library to actually support this.
Example:
package slicing;
void main (String[] args) {
let array = [0, 1, 2, 3, 4, 5];
let slice = array[2..4];
for (e: slice)
println(e);
}
This results in:
~/programming/nice/slicing/slicing.nice: line 5, column 20:
No possible call for get.
Arguments: (t66[], nice.lang.Range<nice.lang.int>)
Possibilities:
nice.lang.boolean get(nice.lang.long x,nice.lang.int bit)
nice.lang.double get(nice.lang.double[],nice.lang.int)
nice.lang.float get(nice.lang.float[],nice.lang.int)
nice.lang.char get(nice.lang.char[],nice.lang.int)
nice.lang.long get(nice.lang.long[],nice.lang.int)
nice.lang.int get(nice.lang.int[],nice.lang.int)
nice.lang.short get(nice.lang.short[],nice.lang.int)
nice.lang.byte get(nice.lang.byte[],nice.lang.int)
nice.lang.boolean get(nice.lang.boolean[],nice.lang.int)
<T> T get(T[],nice.lang.int)
Object get(nice.lang.Dictionary<?, ?>, ?Object)
nice.lang.char get(java.lang.String s,nice.lang.int index)
<K, K0, V0, V | K <: K0, V <: ?V0> ?V0
get(nice.lang.Map<K, V>,K0)
<T> T get(nice.lang.List<T>,nice.lang.int)
<T, V> V get(java.lang.reflect.Field,T)
compilation failed with 1 error
Daniel Dawson
Email: ddawson at icehouse dot net
----------------------------------------------------------------------
Comment By: B S (ben77)
Date: 2006-06-27 17:48
Message:
Logged In: YES
user_id=929365
So if you add this to your
stdlib/nice/functional/list-operators.nice or to everything
that imports it, then it will work:
<T> Slice<T> sl(Slice<T> t) = t;
override <T> List<T> get(List<T> list, Range<int> slice){
return list[sl(slice)];
}
----------------------------------------------------------------------
Comment By: B S (ben77)
Date: 2006-06-20 01:06
Message:
Logged In: YES
user_id=929365
Ah, the problem is that the `..` operator can return either
a Slice<int> or a Range<int>. Range<int> extends Slice<int>
and implements List<int>, which means that the list[1..2]
could be a list[Range] which could call either
get(List,Slice) or get(List, List), leading to the ambiguity.
----------------------------------------------------------------------
Comment By: B S (ben77)
Date: 2006-06-19 16:46
Message:
Logged In: YES
user_id=929365
If you include nice.functional, you get the methods. However
then you also get this error:
Ambiguity for symbol get. Possibilities are :
<T> nice.lang.List<T> get(nice.lang.List<T>
list,nice.lang.Slice<nice.lang.int> slice)
<T> nice.lang.List<T> get(nice.lang.List<T>
list,nice.lang.Slice<nice.lang.int> slice)
so its still broken.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112788&aid=1427169&group_id=12788
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642