So if I post now, and then immediately after, maybe I can GET a prime?
Magus
@Magus
Best posts made by Magus
-
RE: The Backup Likes Thread - Just for @HardwareGeek and @Luhmann, now with extra 😽🐈
-
RE: The Backup Likes Thread - Just for @HardwareGeek and @Luhmann, now with extra 😽🐈
I still think I like @translator best. Maximum entertainment value for minimum effort.
-
RE: Is there a site like Daily WTF that explains why it's a WTF?
An honest question usually gets a reasonable answer.
And quite a few totally unreasonable ones, to be fair.
-
RE: Apple's newest iPhone, 2016
@accalia They've been saying they were planning this for some time... It's nice, because now you can't listen to music while your phone charges!
-
RE: Contempt Culture
@magus Addendum: No one's self-worth should be derived from what software they use. Ever. That's the road to completely avoidable pain and grief.
-
RE: The Backup Likes Thread - Just for @HardwareGeek and @Luhmann, now with extra 😽🐈
Wait, I thought you were a fox, not a Tau...
-
RE: A Crime a Day posted in Funny stuff
-
RE: Targeted advertising fail
The exact moment I opened this thread, I got a phone call. It was in Chinese. I don't speak that. I say it counts!
-
RE: NodeJS reality check
@sockpuppet7 Because you can't trust that your code works otherwise. Congratulations, you've discovered why dynamic typing is bad.
Latest posts made by Magus
-
RE: Expirements in coalescence
@topspin the language provided one essentially allows you to chain a bunch of
?.
calls, such asa?.Child?.Child
, which leaves you with either null or the final child type. You then often use?? SomeDefault() ;
to eliminate null if you have a default you want.What gets interesting with the one in the op is that you can bring multiple objects into the query, and use let and the select line to call basically any code you want along the way, and the end result will always be an empty list or one which contains the object you want to select, even if you're constructing that dependent on everything else not being null.
The problem, other than the innate weirdness of it, is that in most cases, guarding against all those nulls explicitly may be better, if that's invalid input to whatever you're constructing. Which makes the primary use, imo, the optional construction of types with non nullable arguments.
-
RE: Expirements in coalescence
@Zecc in this case, the If is more of an IfExists, and there are overloads that do more complicated things. Part of the goal, I believe, was that your compiled code has no ifs in the normal sense, making decompilation slightly more obfuscated. Because the ifs are probably in a different assembly.
Honestly I'm far more interested in the other parts, since they allow for some interesting lazy evaluation on nullable objects.
Still extremely bizarre though.
-
Expirements in coalescence
My job right now is awesome. That said, there's some weird stuff going on in our codebase, which seems appropriate to talk about here. Basically, years ago, we had some guys, apparently, who really liked functional programming. They got really interested in two particular concepts: railway oriented programming and branchless programming. They also wanted to get rid of null. The resulting code in our system is in my opinion needlessly complex and thoroughly y, but I do see some value to some of that.
C#9 introduced the ability to disable nullability by default, and with that enabled it as a parameter restriction. This enables some interesting stuff with extension methods. I decided to try implementing a few that bring the basics of some of the stuff we do at work to modern c#.
First, the branchless:
public static void If<T>(T? value, Action then, Action? orElse = null)
and the variant with aU
return andFunc<T, U>
parameters. This part is weird, and I don't know that I like it, but it was simple.The more interesting part is the coalescent linqy part. Implementations of select, where, and select many on
T?
, which allow things up to and including the following:var result = from customer in GetCustomer("Brian") from product in GetProduct(44) from price in product.Price from name in customer.Name select new Purchase(price, name);
Where the result will now be either an empty list or an instance of Purchase, regardless of whether any of the properties or methods return null.
I think this is stupid overkill, but it was kind of fun, and protecting a constructor call in this way is beyond the abilities of the normal c#
?.
. It may have value, but it's too weird for me to want to use in general I think. -
RE: Video game spotlight thread
So the doom eternal dlc dropped in the past month, and while I've rage quit several times, I highly recommend it.
-
RE: The Official Funny Stuff Thread™
@Atazhaia I like how that translates to "empty yoko"
-
RE: The Official Status Thread
Today I got all the achievements and side quests done in dragon ball z Kakarot. That game is fun.
-
RE: Variable Capture in C#
@Tsaukpaetra it's a rare case that most people will never encounter, so it's not surprising that you wouldn't know about it. This thread was a TIL.
-
RE: Tales from Coronavee-rooss Italy, mamma mia!
The guy next to me at work apparently had the virus. It's been over two weeks since he was in the office, so I'm not too worried, but he's oldish and has at least one condition that puts him in a risk group, but he is apparently recovering. So alarming, but ultimately good.
-
RE: how can this virus be declining on SK?
@jinpa how do you intend to isolate them better? If the chances that the less vulnerable have it goes up, the chances that the person who feeds the vulnerable has it goes up.