WTF Bites


  • 🚽 Regular

    This still pisses me off (C#):

    readonly int myfield;
    // read-only field: OK!
    
    int MyProperty { get; init; }
    // read-only property: OK!
    
    readonly int MyProperty { get; init; } 
    // no, no, NO! you can't use readonly modifier with read-only properties
    // COMPILER ERROR!!eleven!!


  • @Zecc What are you trying to achieve with that modifier? You already declared what operations are defined for that property, which makes it read-only, so?


  • Notification Spam Recipient

    @Bulb said in WTF Bites:

    @Zecc What are you trying to achieve with that modifier? You already declared what operations are defined for that property, which makes it read-only, so?

    Readability would be a good reason.


  • Considered Harmful

    Technically it's not read-only. There is a difference between a constructor (which can set the property to whatever it fucking wants) and an initializer. Which is probably one of the reasons why init accessor was added instead of allowing readonly modifier for a property with a setter.

    What they really should have added is a worm (write once, read many) keyword 🍹

    int MyProperty { worm; }
    

  • 🚽 Regular

    @Bulb said in WTF Bites:

    @Zecc What are you trying to achieve with that modifier? You already declared what operations are defined for that property, which makes it read-only, so?

    The modifier was already there, actually. The only thing I did was change from a field to a property. It's still as read-only as it was before.

    What is the compiler trying to achieve by preventing me from declaring a property as read-only in two different ways? I would have liked how the keyword emphasizes this is a read-only property.

    Btw, although what @Applied-Mediocrity said makes sense, the same thing happens even if you remove the init accessor.

    (Now that I think about it the init modifier doesn't make sense to have in this particular case so I've removed it. In fact I don't think it needs to be a property, even).



  • @Zecc said in WTF Bites:

    What is the compiler trying to achieve by preventing me from declaring a property as read-only in two different ways? I would have liked how the keyword emphasizes this is a read-only property.

    The property is a completely different thing from a member variable just pretending to be similar. The declaration is a syntactic sugar for a getter and setter methods (which you are saying you don't want in this case) and injecting the initializer in the constructor (or something; I am sure how the get and set are implemented, but not how the initializer is). And a private member variable if you request the default implementation of the methods.

    Btw, although what @Applied-Mediocrity said makes sense, the same thing happens even if you remove the init accessor.

    Of course it will. While the syntax looks similar to a member variable, it is a syntactic sugar for a completely different thing that simply does not accept the keyword.

    In fact I don't think it needs to be a property, even.

    IMO the only reason to even have this property syntactic sugar is to allow refactoring a member variable to a getter+setter pair with additional logic without having to change all the client code. So if you don't have any logic in the getter, it should be a plain field, not a property.

    In that light, the Microsoft recommendation to always make public attributes properties is bogus except for a technical reason: if you refactor a member variable into a property, the code is API compatible, but not ABI compatible, so you can't just drop the updated assembly into the client application and have it work.


  • 🚽 Regular

    @Bulb I know all that but I still don't see why I can't apply a readonly modifier to a property as long as I don't try to specify a setter as well.

    Other than :kneeling_warthog: from the compiler writers, which I understand.


    Edit: @Zecc will have said down below in WTF Bites:

    I can declare a property in an interface.

    I can't declare it as read-only, so it's up to the implementing classes which way it is. Which I guess makes sense.


  • Considered Harmful

    @Bulb said in WTF Bites:

    I am sure how the get and set are implemented, but not how the initializer is

    It generates a public setter method as usual, with a compiler attribute to yell at you.



  • @Applied-Mediocrity said in WTF Bites:

    @Bulb said in WTF Bites:

    I am sure how the get and set are implemented, but not how the initializer is

    It generates a public setter method as usual, with a compiler attribute to yell at you.

    :wat-girl:

    … it's so deserializers can use it, ain't it?


  • 🚽 Regular

    This post is deleted!

  • 🚽 Regular

    I can declare a property in an interface.

    I can't declare it as read-only, so it's up to the implementing classes which way it is. Which I guess makes sense.


  • Notification Spam Recipient

    Status: Fucking Outlook.

    4e00e0d1-bf37-4016-aa51-ee654843e221-image.png

    Why the hell is it changing the font mid-keypress? :angry:



  • @Zecc Can you declare the property as {get;} or {get; private set;} ?


  • I survived the hour long Uno hand

    @Tsaukpaetra said in WTF Bites:

    Status: Fucking Outlook.

    4e00e0d1-bf37-4016-aa51-ee654843e221-image.png

    Why the hell is it changing the font mid-keypress? :angry:

    Well, if you weren't busy ramming it... :mlp_eww:



  • @Zecc said in WTF Bites:

    I can declare a property in an interface.

    I can't declare it as read-only, so it's up to the implementing classes which way it is. Which I guess makes sense.

    You declare whether the interface includes the getter and/or the setter. If the interface does not include the setter, it is read-only when accessed through that interface, but the class may choose to add it. If you do include the setter, then the concrete class has to implement it.

    Which is correct in context—C# does not have any way to say an object is supposed to not be modified within some scope and have the compiler check it That's one C++ feature I am sorely missing in both C# and Java¹

    ¹ In C++ you can declare a reference or pointer const and then any access through that reference or pointer is not allowed to modify the object. Semantically it is equivalent to defining an interface on the object that only contains the non-mutating operations and passing that, but the compiler can check you don't violate it accidentally (C++ will let you do anything intentionally if you ask the right way).


  • 🚽 Regular

    @hungrier said in WTF Bites:

    @Zecc Can you declare the property as {get;} or {get; private set;} ?

    What @Bulb said.

    interface Inyaface {
    	int MyInt { get; } // readonly modifier is not allowed
    }
    
    class Implementer: Inyaface {
    	public int MyInt { get; set; } // private set also possible
    }
    
    void Main()
    {
    	Implementer i = new Implementer();
    	i.MyInt = 5; // fine
    
    	Inyaface i2 = i;
    	//i2.MyInt = 5; // no can do
    }
    

    This isn't a :wtf: in my book.

    Oh, but I guess you were asking about this:

    e590a585-feb7-4906-b326-6e9e7c1d2110-image.png

    But it can have an init modifier in the interface, in which case the implementer must also have one.


  • 🚽 Regular

    TIL you can declare abstract properties (in abstract classes, obviously). But not individual abstract accessors.



  • @Zecc You can declare abstract accessors, just not private abstract accessors -- they'd only be available to the interface itself, not an implementer, not even if that implementer tried an explicit interface implementation.



  • @TwelveBaud Unlike C++ where you totally can declare private abstract methods, and it uses them in its standard library and it is actually reasonable and useful. Except it really only makes sense in abstract base classes that have their own state (so calling the virtual method directly without going through the public wrapper is wrong) and not interfaces that have no state (because the implementation has complete control over the state anyway).


  • Discourse touched me in a no-no place

    @Bulb said in WTF Bites:

    Unlike C++ where you totally can declare private abstract methods

    That's in part because C++ only really has three visibility scopes, so private has to be more open than it is in Java or C#.



  • @dkf private isn't more open in C++ than in Java. Except that you can override private virtual methods even though you are not allowed to call them. Which might be actually true in Java as well, not sure.



  • @dkf TIL about internal in C#.

    C++ being C++, you can get fairly granular access with stuff like the passkey/client-attorney/badge idiom. Only really works for methods, though.


  • 🚽 Regular

    @cvi said in WTF Bites:

    @dkf TIL about internal in C#.

    Which I believe is actually the default (except for interfaces where the default is public for obvious reasons), the reason why a lot of the code I write uses it :kneeling_warthog: .


    For those who don't know, it means it is public within an assembly (.dll or .exe).



  • WTF from 3 days ago: So, we were doing a layover in Lille 🇫🇷 on our way back to Germany. Our cars needed some refueling and so we headed to the nearest gas station which happened to be a self-service point with 2 two-sided standalone pumps. I approached one pump where at that time only one car was sitting whereas the other bus took the 2nd pump with two cars in front of him.

    And then I sat for about one minute wondering what the hell the lady in front of me was doing - because it was neither getting out to get gas nor was she getting ready to leave. Instead she was sitting behind the wheel, doing something on her mobile. My father then got out and told her that we'd like to get back to Berlin with our tanks.

    That's when she finally got out of her car and began to use the terminal at the pump to unlock it in order to get gas.

    After five minutes of her fiddling around with the terminal I got out to see what the hell she was doing. She seemed to be highly confused by the actually straightforward instructions of the terminal:

    1. Insert card
    2. Enter PIN
    3. Select type of fuel (E10, Super or Diesel)
    4. Begin refueling

    She then took the pump head for Super. Which I took out of her hands and told her very strictly not to do that because there were two bright yellow stickers on her car's fuel port with big fat "DIESEL" text written on it.
    I then had to argue with her for another five minutes because "she always took Super!"

    Then she fumbled some more with the terminal.

    At that point the other two cars and our other bus had finished refueling and no one else had queued, so I engaged revers and drove to the other pump.

    Only to find that it was out of Diesel because nothing came out (other than a receipt over the grand sum of 0.00€ that is).

    Luckily, the moron had finally buggered off at that point and equally luckily the two pumps seemingly had two independent fuel depots as this one actually delivered the needed Diesel.

    If there ever was an argument for regular checkups to see if you were still deemed worthy of your driver's license, this person was it.


  • Notification Spam Recipient

    @Rhywden said in WTF Bites:

    the two pumps seemingly had two independent fuel depots

    🤔 Huh.


  • BINNED

    @Rhywden said in WTF Bites:

    we'd like to get back to Berlin with our tanks.

    👀



  • @topspin Germans going to Berlin with their tanks is ok. Germans going to Warsaw with their tanks is when you start worrying.


  • BINNED


  • BINNED

    @topspin
    All muricans are now just assuming both city's are adjecent


  • BINNED

    @Luhmann said in WTF Bites:

    @topspin
    All muricans are now just assuming both city's are adjecent

    In comparison they are right too


  • Considered Harmful

    @Luhmann said in WTF Bites:

    @topspin
    All muricans are now just assuming both city's are adjecent

    Nah, we know that you need to traverse the screen door at night on horseback to safely enter the land of polishes.


  • Considered Harmful

    @cvi said in WTF Bites:

    C++ being C++, you can get fairly granular access with stuff like the passkey/client-attorney/badge idiom. Only really works for methods, though.

    Haha yeah - I spent more than a decade with the question of how to emulate friend methods in Java. Turns out, friend methods are stupid.



  • Banks. Do I really need to say more?

    Well, to be precise, let's take this bank. I call their phone number and they tell me to press 2 for infromation in English. Then they tell me to e-mail international@mps.it instead of calling them on the phone. Fine, I do that too. Guess what happens next?

    550 5.1.1 RESOLVER.ADR.RecipNotFound
    


  • @topspin said in WTF Bites:

    @HardwareGeek
    a33f5f14-d7d0-48af-82be-481dcfeafdd8-grafik.png

    That's actually an ad for Polish car thiefs: look, you do not even need to refuel on your way home!



  • @Luhmann said in WTF Bites:

    @topspin
    All muricans are now just assuming both city's are adjecent

    I mean, 570 km isn't that far. Most of the cars I've had the last 20 years could do that distance on one tank if I didn't drive like me.


  • Discourse touched me in a no-no place

    @aitap said in WTF Bites:

    Banks. Do I really need to say more?

    Well, to be precise, let's take this bank. I call their phone number and they tell me to press 2 for infromation in English. Then they tell me to e-mail international@mps.it instead of calling them on the phone. Fine, I do that too. Guess what happens next?

    550 5.1.1 RESOLVER.ADR.RecipNotFound
    

    I've had similar vibes from some insurers. All I wanted to do was to download the insurance schedule for the house insurance so I could make printed record of what was actually covered. Could they supply me with a working link in their letter acknowledging the purchase? No. (The link they supplied was subtly wrong, missing a critical hostname component. There was also an "click here" that went nowhere because they sent the letter on paper. Classic.)



  • … today in programs that cannot handle space percent sign in file names.

    I often need some scratch files in the workspace, so, to make it easy to tell git to ignore those files, I usually name them using some symbol. I know of four that are allowed also on Windows (Linux allows anything) and not special in most contexts so they don't need too careful quoting: ,, %, @ and +. @ means a ‘response file’, i.e. that the file should be read and expanded to more options, to some commands, and + is an alternate option character for some older programs, so , or % usually work best.

    Except with helm. Helm apparently

    • Seems to interpret , as option separator even in places where it makes no sense.
    • Crashes on %. Like
      panic: runtime error: invalid memory address or nil pointer dereference
      [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x18b40d0]
      


  • @Bulb Somebody passing the input string to a scanf() / printf() variant as the format string argument?



  • @Bulb this led me on a search for difference between null and nil.

    Take a shot every time the article implies nothing and zero are the same for programming


  • Considered Harmful

    @homoBalkanus said in WTF Bites:

    @Bulb ...

    Take a shot every time the article implies nothing and zero are the same for programming

    Hahaha, ignants, they left out the empty string.



  • @cvi said in WTF Bites:

    @Bulb Somebody passing the input string to a scanf() / printf() variant as the format string argument?

    Actually, something tries to decode it as URL without first checking that it actually is a URL and not a path.
    It prints a backtrace that points to helm.sh/helm/v3/pkg/cli/values/options.go:118 (the problem is that they ignore errors from the previous statement).


  • Notification Spam Recipient

    @Bulb said in WTF Bites:

    that they ignore errors

    Isn't that like the whole stick with Go, that there are no errors (or at least, exceptions)?



  • @Tsaukpaetra Go does not have exceptions, but neither does C. The fallible functions return a pair of result and error. The problem is that if an error happens, the result may be invalid and if you don't check it—and nothing warns you about that—you can easily step on the invalid result and get a “nil reference panic”.

    Rust also does not have exceptions, but it's Result is either result or error, so you can't use the result without checking you actually got one first. Bit more pain to do quick hacks, but the final results tend to be quite a bit more reliable.


  • Trolleybus Mechanic

    So our new system is synchronizing data with the old system by calling their "API" (writen in PHP, i assume 5.6, same as their other stuff), which after a minute of spinning up fans spews a 15MB json containing, among other things, a list of files to download, with md5 sums.
    The problem is that the files keep changing and they're reusing their names, so after I parse the response, 90% of time at least one md5 doesn't match anymore, which results in a complete rollback. They're whining that "synchronization is too slow", they want "almost realtime".


  • Considered Harmful

    @dkf said in WTF Bites:

    @aitap said in WTF Bites:

    Banks. Do I really need to say more?

    Well, to be precise, let's take this bank. I call their phone number and they tell me to press 2 for infromation in English. Then they tell me to e-mail international@mps.it instead of calling them on the phone. Fine, I do that too. Guess what happens next?

    550 5.1.1 RESOLVER.ADR.RecipNotFound
    

    I've had similar vibes from some insurers. All I wanted to do was to download the insurance schedule for the house insurance so I could make printed record of what was actually covered. Could they supply me with a working link in their letter acknowledging the purchase? No. (The link they supplied was subtly wrong, missing a critical hostname component. There was also an "click here" that went nowhere because they sent the letter on paper. Classic.)

    I'm sure I've ranted about HP's infrastructure here, where looking up anything in their documentation will at some point lead to an URL like http://w23iz587.boston.eastcoast.hp.com/extremely/fucking/long/path/u8293978trfughjdg/incompre ensible/shit/?blah=pdf that doesn't work because the machine it refers to died and redundancy, load balancers, and webapps are for wimps.
    It seemed to have gotten slightly better in the last years wrt URLs.
    Now we had this support case and I had to mail them some log files. Just reply to the mail they sent from a perfectly cromulent address like support-case-blah@hpe.com, right? It's how you do email, I think.
    No reply for about two days, then I get this (no editing, these are the actual hostnames):

    This is the mail system at host p1lg14884.dc01.its.hpecorp.net.
    
    I'm sorry to have to inform you that your message could not
    be delivered to one or more recipients. It's attached below.
    
    For further assistance, please send mail to postmaster.
    
    If you do so, please include this problem report. You can
    delete your own text from the attached returned message.
    
                       The mail system
    
    <gsdxcs64447.routing@am2.exch.hp.com>: delivery temporarily suspended: connect
        to g4w9119.houston.hp.com[16.210.20.214]:25: Connection refused
    

    I'm not sure I even want to know how their internal mail system "works" :facepalm:


  • Notification Spam Recipient

    @LaoC said in WTF Bites:

    "works"

    Narrator: It doesn't. :rimshot:


  • Considered Harmful

    @Tsaukpaetra said in WTF Bites:

    @LaoC said in WTF Bites:

    "works"

    Narrator: It doesn't. :rimshot:

    :thats_the_joke:



  • WTF of my day (ok, only one, the other big one being xcode):

    My hosting provider (for my personal stuff) automatically enables what they call dynamic caching (of a lot of the static-ish resources). They provide a way to adjust the behavior (such as exempting certain files from the caching). But only if you're using wordpress, because it's implemented as a wordpress plugin. No, not a sitetools plugin (usable by anyone, including people who aren't using wordpress). But as a wordpress plugin. So if you're just hosting a site that consists of

    1. a simple html file, but one that changes relatively frequently (because you're tweaking the look) that includes the CSS in a style tag (due to webpack's behavior)
    2. one webpacked js file that changes frequently enough to make caching inadvisable

    all you can do is purge the entire cache for the entire host. Instead of just saying "hey, those 3 files are small enough that I want to always see the changes".

    And I can't use webpack's built-in cache busting...because I'm not using a lodash template or building the entire html from js on page load. It's just a standard HTML file with the js file as the src of a script tag. The CSS gets built into a style tag, which means that the cached html also includes all the cached css. Which gets cached relatively forever by browsers and the host.


  • Notification Spam Recipient

    @Benjamin-Hall said in WTF Bites:

    which means that the cached html also includes all the cached css. Which gets cached relatively forever by browsers and the host.

    Encountering something like this with someone's iPhone, which apparently cached one of the dev builds of the site from long enough ago that it's not talking to the API endpoints correctly anymore, and no amount of "pull down to refresh, maybe?" is fixing it.



  • @Tsaukpaetra said in WTF Bites:

    someone's iPhone

    <there-s-your-problem.gif>. Safari, mobile safari in particular, is super super aggressive about caching things. Mostly things it shouldn't cache ever.


Log in to reply