-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Converters with openarray #2652
Comments
I think "borrowing" methods of another type's implementation or marking a type as compatible (from an API perspective). What I mean by that is that a type marked with a sequence would inherit sequence procedures ( Real purpose: array helpers for https://github.com/megawac/RingBuffer.nim |
@megawac Reinvented 'concept'? |
Can concept do this already? I thought it was more similar to On Fri, May 8, 2015 at 11:05 AM, Andreas Rumpf notifications@github.com
|
Got hit by this yesterday, here is a test case Pure seqimport sequtils
proc flatten[T](a: seq[T]): seq[T] = a
proc flatten[T](a: seq[seq[T]]): auto = a.concat.flatten
let s = @[@[1,2,3],@[4,5,6]]
echo s.flatten
# @[1, 2, 3, 4, 5, 6] Openarray doesn't match seqimport sequtils
proc flatten[T](a: seq[T]): seq[T] = a
proc flatten[T](a: openarray[seq[T]]): auto = a.toSeq.concat.flatten
let s = @[@[1,2,3],@[4,5,6]]
echo s.flatten
# @[@[1, 2, 3], @[4, 5, 6]] Last case, for some reason there are generic instantiantions now import sequtils
proc flatten[T](a: openarray[T]): auto = a
proc flatten[T](a: openarray[seq[T]]): auto = a.toSeq.concat.flatten
let s = @[@[1,2,3],@[4,5,6]]
echo s.flatten Error openarray_conversion.nim(8, 7) template/generic instantiation from here
openarray_conversion.nim(4, 48) template/generic instantiation from here
lib/pure/collections/sequtils.nim(473, 36) template/generic instantiation from here
lib/system.nim(684, 9) template/generic instantiation from here
lib/system.nim(652, 16) Error: invalid type: 'openarray[seq[int]]' in this context: 'proc (s: var seq[openarray[seq[int]]], len: Natural){.noSideEffect.}' Please note that while waiting for issue #5708, return type of flatten must be |
Converter to seq doesn't get used when the proc expects an openarray:
The text was updated successfully, but these errors were encountered: