• 0 Posts
  • 63 Comments
Joined 2 years ago
cake
Cake day: June 26th, 2023

help-circle

  • vithigar@lemmy.catoProgrammer Humor@lemmy.mlWhat the F#
    link
    fedilink
    arrow-up
    2
    arrow-down
    1
    ·
    13 days ago

    i is still a value type, that never changes. Which highlights another issue I have with the explanation as provided. Using the word “reference” in a confusing way. Anonymous methods capture their enclosing scope, so i simply remains in-scope for all calls to those functions, and all those functions share the same enclosing scope. It never changes from being a value type.






  • C# .NET using reflection, integer underflow, and a touch of LINQ. Should work for all integer types. (edit: also works with char values)

    // this increments i
    private static T Increment<T>(T i)
    {
        var valType = typeof(T);
        var maxField = valType.GetField("MaxValue");
        var minField = valType.GetField("MinValue");
        if (maxField != null)
        {
            T maxValue = (T)maxField.GetValue(i);
            T minValue = (T)minField.GetValue(i);
    
            var methods = valType.GetTypeInfo().DeclaredMethods;
            var subMethod = methods.Where(m => m.Name.EndsWith("op_Subtraction")).First();
                   
            T interim = (T)subMethod.Invoke(
                null,
                [i, maxValue]);
    
            return (T)subMethod.Invoke(
                null, 
                [interim, minValue]);
        }
        throw new ArgumentException("Not incrementable.");
    }
    

  • I’m the primary developer for a third party tool for Elite Dangerous and this is basically my entire thought process when I want to work on it.

    I could work on Observatory…

    Or I could play some Elite…

    Or I could just stare at my screen ineffectually for several hours.

    Staring at the screen wins frighteningly often.









  • It’s an extremely bizarre suggestion given your request. I do want to defend the game (though not the suggestion) a little though.

    It initially presents as you say, but offers you opportunities to fight back in your capacity as border control. Letting in the right people can help the resistance and incite a coup, or enable you and your families escape from the country. It isn’t just Be A Good Tankie Simulator 2013, though you can play it that way too.


  • For those of you who’ve never experienced the joy of PowerBuilder, this could often happen in their IDE due to debug mode actually altering the state of some variables.

    More specifically, if you watched a variable or property then it would be initialised to a default value by the debugger if it didn’t already exist, so any errors that were happening due to null values/references would just magically stop.

    Another fun one that made debugging difficult, “local” scoping is shared between multiple instances of the same event. So if you had, say, a mouse move event that fired ten times as the cursor transited a row and in that event you set something like integer li_current_x = xpos the most recent assignment would quash the value of li_current_x in every instance of that event that was currently executing.




  • There are a few options there.

    As someone else mentioned if you’re using IPv6 then it doesn’t matter, you’re already routing internally even if you’re using the public DNS name, no extra work required.

    All the rest are for IPv4.

    If you’re not behind CGNAT some routers/gateways are also smart enough with their routing to recognise when they need to route back to their own external IP and will loop back locally instead of making any hops out to the internet. Again, if this is the case for you then no additional work is required other than perhaps running a traceroute to confirm.

    Another option is to add a local DNS entry for the name you’re using to resolve to a local IP address instead of your public address. The complexity (or even possibility) of this is going to vary considerably with your setup. If you’re running your own local DNS e.g. pihole or similar then it’s trivial. This is how mine is set up.

    If all your clients are going to be on PCs (or devices you have more than the typical manufacturer allowed modicum of control over) then you can do something kind of like the previous, just with all your local hosts files.

    If none of the above are options, then you’ll unfortunately have to fall back on using a local name/address, which means a slightly different client setup for devices you use exclusively in your home versus ones you might use elsewhere.