CSOD: return and throw



  • I've anonymised the name of the type and the parameters, but the rest (including the misspelling of retrieve) is unchanged.

    public static Foo RetriveFromBarAndBaz(string bar, string baz)
    {
    	try
    	{
    		Foo foo = PersistentClass<Foo>.RetrieveUnique("Bar= :bar AND Baz= :baz", new QueryParameter("bar", bar), new QueryParameter("baz", baz));
    		return foo;
    	}
    	catch
    	{
    		return null;
    		throw;
    	}
    }

    I'm not sure which is worse: that my predecessor apparently thought that this was a sensible catch block (this is a representative member of a set of 10 similar methods), or that the compiler doesn't even give a warning about the unreachable throw statement.


  • Discourse touched me in a no-no place

    @pjt33 said:

    including the misspelling of retrieve
    Erm.... how should it be spelt then?



  • g - e - t



  • @PJH said:

    @pjt33 said:
    including the misspelling of retrieve
    Erm.... how should it be spelt then?
    Observe how it is spelt/spelled in the function name.


  • Discourse touched me in a no-no place

    @HardwareGeek said:

    @PJH said:
    @pjt33 said:
    including the misspelling of retrieve
    Erm.... how should it be spelt then?
    Observe how it is spelt/spelled in the function name.
    Ah - I only spotted the version in the try block.


  • Considered Harmful

    The problem is that this code was written for a quantum computer that can exist in a superposition of having both returned and thrown.



  • @HardwareGeek said:

    Observe how it is spelt/spelled in the function name.

    How is it riced?



  • @morbiuswilters said:

    @HardwareGeek said:
    Observe how it is spelt/spelled in the function name.

    How is it riced?

    Wheat are you talking about? I was just echoing PJH's British misspelling of spelled. It's those Brits that barley speak English.



  • @HardwareGeek said:

    @morbiuswilters said:
    @HardwareGeek said:
    Observe how it is spelt/spelled in the function name.

    How is it riced?

    Wheat are you talking about? I was just echoing PJH's British misspelling of spelled. It's those Brits that barley speak English.

    Spelt is a grain. It was a pun.

    Spelled/Spelt are both correct, even in Proper American English, but "spelt" always makes me think of low-gluten hippie bread..



  • @morbiuswilters said:

    @HardwareGeek said:
    @morbiuswilters said:
    @HardwareGeek said:
    Observe how it is spelt/spelled in the function name.

    How is it riced?

    Wheat are you talking about? I was just echoing PJH's British misspelling of spelled. It's those Brits that barley speak English.

    Spelt is a grain. It was a pun.

    I think I figured that out.



  • @HardwareGeek said:

    @morbiuswilters said:
    @HardwareGeek said:
    @morbiuswilters said:
    @HardwareGeek said:
    Observe how it is spelt/spelled in the function name.

    How is it riced?

    Wheat are you talking about? I was just echoing PJH's British misspelling of spelled. It's those Brits that barley speak English.

    Spelt is a grain. It was a pun.

    I think I figured that out.

    Oh. Dammit..

    Quick, somebody do something stupid so I look less stupid by comparison!


  • Trolleybus Mechanic

    @morbiuswilters said:

    Quick, somebody do something stupid so I look less stupid by comparison!
     

    [url="http://what.thedailywtf.com/"]http://what.thedailywtf.com/[/url]



  • @Lorne Kates said:

    @morbiuswilters said:

    Quick, somebody do something stupid so I look less stupid by comparison!
     

    http://what.thedailywtf.com/

    Whew, that was a close one! wipes sweat from brow



  • @morbiuswilters said:

    @Lorne Kates said:

    @morbiuswilters said:

    Quick, somebody do something stupid so I look less stupid by comparison!
     

    http://what.thedailywtf.com/

    Whew, that was a close one! wipes sweat from brow

    So far, that's making you look like a genius.



  • @HardwareGeek said:

    @morbiuswilters said:
    @Lorne Kates said:

    @morbiuswilters said:

    Quick, somebody do something stupid so I look less stupid by comparison!
     

    http://what.thedailywtf.com/

    Whew, that was a close one! wipes sweat from brow

    So far, that's making you look like a genius.

    That thing makes Nagesh seem smart.

    That thing makes me seem smart.



  • @Ben L. said:

    @HardwareGeek said:
    @morbiuswilters said:
    @Lorne Kates said:

    @morbiuswilters said:

    Quick, somebody do something stupid so I look less stupid by comparison!
     

    http://what.thedailywtf.com/

    Whew, that was a close one! wipes sweat from brow

    So far, that's making you look like a genius.

    That thing makes Nagesh seem smart.

    That thing makes me seem smart.

    Almost.... Almost

  • FoxDev

    @pjt33 said:

    the compiler doesn't even give a warning about the unreachable throw statement.

    It should do, though in VS warnings are normally only shown once after a code change/full rebuild.

     



  • @RaceProUK said:

    It should do, though in VS warnings are normally only shown once after a code change/full rebuild.

    Rebuilding the entire solution doesn't get me a warning for the unreachable throw statements. And it's not because the warning has been disabled, because I do see one for some unreachable code elsewhere in the project.


  • FoxDev

    @pjt33 said:

    @RaceProUK said:
    It should do, though in VS warnings are normally only shown once after a code change/full rebuild.
    Rebuilding the entire solution doesn't get me a warning for the unreachable throw statements. And it's not because the warning has been disabled, because I do see one for some unreachable code elsewhere in the project.

    Sounds like a compiler bug then, unless it's one of those corner cases where working out the program flow would stall the compiler indefinitely.

    I'm thinking it's the former.



  • VS2012 gives me CS0162 on the throw.



  • @morbiuswilters said:

    Spelled/Spelt are both correct, even in Proper American English, but "spelt" always makes me think of low-gluten hippie bread..

    Spelt contains gluten, so it wouldn't be a suitable grain for someone who can't (or thinks he can't) eat gluten.



  • @anotherusername said:

    @morbiuswilters said:
    Spelled/Spelt are both correct, even in Proper American English, but "spelt" always makes me think of low-gluten hippie bread..

    Spelt contains gluten, so it wouldn't be a suitable grain for someone who can't (or thinks he can't) eat gluten.

    I didn't say it was gluten-free, I said it was low-gluten. It's definitely used to make low-gluten breads for people who don't want gluten (AKA idiots) or who can eat a little gluten.



  • @morbiuswilters said:

    @anotherusername said:
    @morbiuswilters said:
    Spelled/Spelt are both correct, even in Proper American English, but "spelt" always makes me think of low-gluten hippie bread..

    Spelt contains gluten, so it wouldn't be a suitable grain for someone who can't (or thinks he can't) eat gluten.

    I didn't say it was gluten-free, I said it was low-gluten. It's definitely used to make low-gluten breads for people who don't want gluten (AKA idiots) or who can eat a little gluten.

    It's not that much lower in gluten. If it was, it wouldn't make good bread. However, spelt gluten is supposedly easier to digest than wheat gluten; not all glutens are created equal, and thus spelt is more suitable for people who think they shouldn't eat foods containing (wheat) gluten. People who can't eat gluten (those who genuinely have Coeliac disease) cannot eat spelt, because it contains gluten.



  • @anotherusername said:

    It's not that much lower in gluten. If it was, it wouldn't make good bread.

    I take it you haven't had spelt bread. Spelt bread is really shitty.

    @anotherusername said:

    People who can't eat gluten (those who genuinely have Coeliac disease) cannot eat spelt, because it contains gluten.

    Why do you keep stating this? This is twice now that you have replied as if I said people who can't eat gluten can eat spelt. Twice. Stop having a conversation in your head and join us here in the real world.



  • @morbiuswilters said:

    @anotherusername said:
    It's not that much lower in gluten. If it was, it wouldn't make good bread.

    I take it you haven't had spelt bread. Spelt bread is really shitty.

    I have, but it was freshly homemade and wasn't very shitty. I think you probably just had shitty store-bought health-food bread made from sawdust, flaxseed and almond milk.


    @morbiuswilters said:
    @anotherusername said:
    People who can't eat gluten (those who genuinely have Coeliac disease) cannot eat spelt, because it contains gluten.

    Why do you keep stating this? This is twice now that you have replied as if I said people who can't eat gluten can eat spelt. Twice. Stop having a conversation in your head and join us here in the real world.

    You said that people who are avoiding gluten can eat bread made from spelt because it's lower in gluten. That's incorrect. It's not why they can eat it. It has plenty of gluten, and they can eat it because they're not really allergic to gluten.

    Basically, saying that low-gluten spelt bread is okay for someone who's trying to avoid gluten is like saying that strawberries drizzled with honey are okay for someone who's trying to avoid high-fructose corn syrup.



  • @anotherusername said:

    I have, but it was freshly homemade and wasn't very shitty. I think you probably just had shitty store-bought health-food bread made from sawdust, flaxseed and almond milk.

    I've had plenty of fresh spelt bread. It's dense and it crumbles apart easily because it doesn't have enough gluten to make it "bready".

    @anotherusername said:

    You said that people who are avoiding gluten can eat bread made from spelt because it's lower in gluten.

    Where? Where did I say that??



  • @morbiuswilters said:

    @anotherusername said:
    You said that people who are avoiding gluten can eat bread made from spelt because it's lower in gluten.

    Where? Where did I say that??

    This is the comment I was referring to:

    "It's definitely used to make low-gluten breads for people who don't want gluten (AKA idiots) or who can eat a little gluten."

    Edit: I wasn't originally disagreeing with you exactly. My comment was more directed at the idiocy of people who think they're intolerant of gluten and then eat spelt bread because it's "low gluten". If they can eat spelt bread, it's not because it's low gluten; rather, it's because they're not allergic to gluten in the first place. They either have a wheat allergy that they've miscategorised as a gluten allergy, or they're imagining the whole thing.



  • @morbiuswilters said:

    @anotherusername said:
    You said that people who are avoiding gluten can eat bread made from spelt because it's lower in gluten.

    Where? Where did I say that??

    You said, essentially, that people who are avoiding some but not all gluten can eat it:@morbiuswilters said:
    It's definitely used to make low-gluten breads for people who don't want gluten (AKA idiots) or who can eat a little gluten.



  • @HardwareGeek said:

    You said, essentially, that people who are avoiding some but not all gluten can eat it:@morbiuswilters said:
    It's definitely used to make low-gluten breads for people who don't want gluten (AKA idiots) or who can eat a little gluten.

    Which is true. Gluten-intolerant people can't eat it, but people with only mild gluten sensitivities can and do.



  • @morbiuswilters said:

    @HardwareGeek said:
    You said, essentially, that people who are avoiding some but not all gluten can eat it:@morbiuswilters said:
    It's definitely used to make low-gluten breads for people who don't want gluten (AKA idiots) or who can eat a little gluten.

    Which is true. Gluten-intolerant people can't eat it, but people with only mild gluten sensitivities can and do.

    I don't believe in people with only mild gluten sensitivities. If wheat bothers their digestion and spelt does not, they should be blaming wheat and/or wheat gluten, not gluten.



  • @morbiuswilters said:

    @HardwareGeek said:
    You said, essentially, that people who are avoiding some but not all gluten can eat it:@morbiuswilters said:
    It's definitely used to make low-gluten breads for people who don't want gluten (AKA idiots) or who can eat a little gluten.

    Which is true. Gluten-intolerant people can't eat it, but people with only mild gluten sensitivities can and do.

    I did not, and do not, disagree. Whether "people with only mild gluten sensitivities" exist is a separate question, about which I have no information and, therefore, will not comment.



  • @anotherusername said:

    @morbiuswilters said:
    @HardwareGeek said:
    You said, essentially, that people who are avoiding some but not all gluten can eat it:@morbiuswilters said:
    It's definitely used to make low-gluten breads for people who don't want gluten (AKA idiots) or who can eat a little gluten.

    Which is true. Gluten-intolerant people can't eat it, but people with only mild gluten sensitivities can and do.

    I don't believe in people with only mild gluten sensitivities. If wheat bothers their digestion and spelt does not, they should be blaming wheat and/or wheat gluten, not gluten.


    I think most people don't actually know the difference between gluten and wheat. In their tiny uninformed brain, gluten == wheat.



  • @mikeTheLiar said:

    I think most people don't actually know the difference between gluten and wheat.
    I don't think most people have the slightest clue WTF gluten is. They just see packages of food that say "GLUTEN FREE!!!1!", so it must be bad.



  • @HardwareGeek said:

    @mikeTheLiar said:
    I think most people don't actually know the difference between gluten and wheat.
    I don't think most people have the slightest clue WTF gluten is. They just see packages of food that say "GLUTEN FREE!!!1!", so it must be bad.

    Somebody should test your theory by asking a bunch of random people on the street if they even know what gluten is, and then post a YouTube video of it.



  • @anotherusername said:

    @HardwareGeek said:
    @mikeTheLiar said:
    I think most people don't actually know the difference between gluten and wheat.
    I don't think most people have the slightest clue WTF gluten is. They just see packages of food that say "GLUTEN FREE!!!1!", so it must be bad.

    Somebody should test your theory by asking a bunch of random people on the street if they even know what gluten is, and then post a YouTube video of it.

    Everyone knows gluten is poison that was added to wheat by Monsanto in the 60s to turn people into mindless consumers to power the Military-Industrial Complex as it raped the world's beautiful cultures of their expressive voices and oppressed people of colour so they could hide the secret of generating infinite free energy from a glass of water and some Pez.


Log in to reply