On Wed, Dec 23, 2015 at 3:24 PM, Daniel Eggert via swift-users <swift-users@swift.org> wrote: > I have an array of String and need to call withCString on each one and then > pass the resulting array of UnsafePointer<Int8> to a C api. The unsafe > pointer is only valid within the scope of withCString. > > So I built the following, but the compiler doesn’t like it: > > % swift scopedReduceAndApply.swift > scopedReduceAndApply.swift:18:16: error: value of type 'Self.SubSequence' has > no member 'Distance' > return tail.scopedReduceAndApply(f, g: g, list: ll) > ^~~~ ~~~~~~~~~~~~~~~~~~~~ > > What is ‘Distance’ and why doesn’t SubSequence of CollectionType have it?
That's just a bad error message. > extension CollectionType where SubSequence : CollectionType { I think you need this constraint to be propagated all the way down, for recursive calls, so you need: extension CollectionType where SubSequence == Self Or, if you want to allow the toplevel type to differ: extension CollectionType where SubSequence : CollectionType, SubSequence.SubSequence == SubSequence Dmitri -- main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if (j){printf("%d\n",i);}}} /*Dmitri Gribenko <griboz...@gmail.com>*/ _______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users