|
Daniel Pfeffer wrote: Could you not create a wrapper around the parts of Microsoft's DNF that you need, providing the same functionality where it exists, but your own implementation where it doesn't?
Unfortunately, no. Read only spans kind of work like string views do in C++ except unlike C++ you have to rely on the CLI to support the feature. You can't even hold Span/ReadOnlySpan instances as fields in classes or structs. It will COMPILE error.
Edit: However, I thought about what you asked and it gave me an idea. To that end I created just enough of ReadOnlySpan<t> in C#/Slang that Deslang could find it and use it. I don't actually use the code for the ReadOnlySpan<t> cutout I made - but it's enough that Slang can resolve the methods on it. So that works.
namespace System
{
internal class ReadOnlySpan<T>
{
public override string ToString()
{
return null;
}
public int Length { get { return 0; } }
public ReadOnlySpan<T> Slice(int position, int length)
{
return null;
}
}
}
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
modified 14-Jan-24 5:45am.
|
|
|
|
|
Never worked with spans and never needed them, I think.
So I'm going to abuse this opportunity to ask a programming question in the Lounge.
What do they do, would I need them in an average LOB application, and if so why and how?
I know I can google it, but you can probably answer my question(s) better.
|
|
|
|
|
With the type of development you do, I don't see you using them, at least directly.
They're a bit into the weeds.
Okay, so like normally
string foobar = "foobar"
string bar = foobar.Substring(3,3);
That's fine of course. One can copy strings. However, it's not efficient, and if you needed to do it a million times a second you might be sweating it.
string foobar = "foobar";
ReadOnlySpan<char> sp = (ReadOnlySpan<char>)foobar;
ReadOnlySpan<char> sbar = sp.Slice(3,3);
Spans basically point to another thing's memory directly without copying. They are a useful way to speed up low level operations on strings and arrays when you need a "view" into them without copying the data.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
Thanks, figured it'd be something like that.
I'll stick to the more readable, concise and expected string.Substring
|
|
|
|
|
Right? Generally developing at the level you do you don't have the time or need to get into the gritty details.
Suffice it to say that MS uses Spans under the hood to make your higher level code perform better than it otherwise would. Doing things like XML and JSON processing, or even *gasp* Regex scanning involves a lot of string manipulation, and therefore under normal circumstances, a lot of copying. Spans, used judiciously can dramatically reduce that copying that's going on under the covers, and Microsoft has taken care of that in their core libraries, so you don't need to worry about it.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
honey the codewitch wrote: Deslang uses some reflection magic. And that magic is .NET Framework only.
I am trying to parse that statement and failing.
Is "Deslang" a third party library or your name for something? I did find the first but unclear how you would be using those.
Also not sure what "magic" you are referring to. Perhaps you are referring to the C# language specification only? Because other than that I think reflection is always available via the System.Reflection namespace. Certainly assemblies always contain the metadata and they must because runtime link resolution requires that information to validate and resolve calls.
This latter part could just be because I never memorize what I am stuffing into a C# app. I just throw things at it until I get the parts I need.
|
|
|
|
|
Deslang is a code generator for generating code that generates code.
Deslang: From Code to CodeDOM and Back[^]
Reflection is available in Core and Standard, but not the particular bits I am using. I get a NotSupported exception coming from deep within the bowels of my CodeDomResolver class due to some reflection chicanery not being functional under anything other than Framework. I haven't run down all the details yet since I found another path forward.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
Wordle 939 3/6*
β¬β¬π¨π©β¬
β¬π©π©π©β¬
π©π©π©π©π©
|
|
|
|
|
Wordle 939 3/6
β¬π¨π©β¬β¬
π©β¬π©β¬β¬
π©π©π©π©π©
|
|
|
|
|
Wordle 939 3/6
β¬β¬π¨β¬β¬
β¬π©β¬π©π©
π©π©π©π©π©
|
|
|
|
|
Wordle 939 3/6*
β¬β¬π¨β¬β¬
β¬π©π¨π¨β¬
π©π©π©π©π©
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Wordle 939 3/6
β¬π¨π¨β¬β¬
π¨π©β¬π¨β¬
π©π©π©π©π©
Ok, I have had my coffee, so you can all come out now!
|
|
|
|
|
boss " ...can you comment your code? "
coder "... my code is self commented "
corollary, not really funny
caller "...I am having a hart attack..."
911 operator " ... everything is peachy fine here..."
modified 13-Jan-24 17:16pm.
|
|
|
|
|
|
Alternate version:
boss: Did you even test this?
coder: Well, it worked on my computer.
"Go forth into the source" - Neal Morse
"Hope is contagious"
|
|
|
|
|
|
dealing with this crap now. 150k of code with nothing but trivial comments.
Boss: what is taking you so long.
me:
Charlie Gilley
βThey who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.β BF, 1759
Has never been more appropriate.
|
|
|
|
|
I have a code base I inherited where almost every source file includes 100 lines or more of change notes.
All of them describe what they changed (renamed "X" to "Y" in function "F"), rather than why.
And people wonder why I want to desecrate the grave of the original author with used coffee...
Software Zen: delete this;
|
|
|
|
|
I ran into this with a government contract. I wrote a comment scrubber that kept the original spacing of the actual source code but got rid of all the comments. Code was so much easier to read and understand without all the idiotic comments.
|
|
|
|
|
Wordle 938 4/6*
π¨β¬β¬β¬π¨
β¬π¨π¨π¨π¨
π¨π©π©β¬π¨
π©π©π©π©π©
|
|
|
|
|
Wordle 938 3/6
β¬β¬β¬β¬β¬
β¬π¨π©β¬π¨
π©π©π©π©π©
|
|
|
|
|
Wordle 938 4/6*
π¨π¨β¬β¬π¨
β¬π¨β¬π¨π¨
π¨π©π©π¨β¬
π©π©π©π©π©
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Wordle 938 5/6*
β¬β¬π¨π¨β¬
π¨β¬π©π¨β¬
π¨π©π©π©β¬
β¬π©π©π©π©
π©π©π©π©π©
Happiness will never come to those who fail to appreciate what they already have. -Anon
And those who were seen dancing were thought to be insane by those who could not hear the music. -Frederick Nietzsche
|
|
|
|
|
Quote: Wordle 938 4/6
π¨π¨β¬π©π¨
β¬π©π©π©π©
β¬π©π©π©π©
π©π©π©π©π©
Ok, I have had my coffee, so you can all come out now!
|
|
|
|
|
Wordle 938 4/6
π¨π¨β¬π¨β¬
β¬π¨π¨π¨π©
β¬π©π©π©π©
π©π©π©π©π©
|
|
|
|