I'm implementing a lightweight sequence-like type. I want it to have a toOpenArray proc, like seq and string do, so my type will work with any function that takes an openarray. But the compiler refuses to consider it: as soon as it sees the return type it shuts me down.
proc toOpenArray(s: MySeq): openarray[byte] =
^ Error: invalid type: 'openArray[byte]' in this context: 'proc (): openArray[byte]' for proc
I s'pose this is part of the "openarray only works as a parameter type" limitation. Is there any workaround; a pragma or something? Or are only "magic" procs allowed to do this?