Banana Poop
Banana Poop
CC#
Created by Banana Poop on 3/6/2024 in #help
✅ Using `Func<ReadOnlySpan<char>,bool>` but not allowed due to Pointer Type
I am building a parser, and performance is of concern. So instead of allocating infinite strings whenever I need to take a substring. I'd logically prefer to just take slices of the same buffer using Spans. In addition I want to use Func<ReadOnlySpan<char>,bool> to do some work in helping me parse, which would take in the Span to do some work. However, this is illegal in C# Compiler Error CS0306 due to ReadOnlySpan<char> being a pointer type readonly ref struct. I have considered just making a type, with one function on it, and overriding that in subtypes to get around it, but this is really not suitable. I may for instance wish to compile LINQ expressions at run time, to server as parsers. This has got me stuck since the 'correct' way is illegal, and any other way, is highly comprimised. Thoughts?
16 replies