Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Method chaining with short-circuit parameter evaluation

Method chaining with short-circuit parameter evaluation

Scheduled Pinned Locked Moved The Lounge
csharpc++phpcomdesign
59 Posts 38 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Chris Maunder

    I am testing several depths of properties in an object to make sure they are safe before I call them:

    Test.NotNull(myObject);
    if (myObject != null)
    {
    Test.NotNull(myObject.MyProperty);
    if (myObject.MyProperty != null)
    Test.IsPositive(myObject.MyProperty.Id);
    ...
    }

    I was thinking it would be really cool to be able to do

    Test.NotNull(myObject).NotNull(myObject.MyProperty).IsPositive(myObject.MyProperty.Id);

    but obviously if myObject == null then we have a runtime null ref error because, regardless of what the NotNull method returns as part of the chaining, myObject is still null. So this got me thinking: You can do

    if (myObject != null && myObject.MyProperty != null)

    because of short circuit boolean evaluation in C#, but I was wondering, with my fairly mainstream experience in languages, if there are languages out there that would allow chaining of methods with short circuit evaluation. Essentially you'd have to have the input parameter be resolved after the method was called in order to have the method be able to say "I don't need the input parameter, please just ignore it". Has anyone heard of this? Would it open up a World Of Pain when it comes to debugging? Would it be useful? Am I procrastinating? --- Update: and it turns out this leads into a great discussion of extension methods. See The Maybe Monad[^] and Chained null checks and the Maybe monad[^] for two ways of achieving this. Once you've done that, debate the correctness of extension methods that are able by design to operate on a null references. I will be over there looking for new, shiny, distracting things.

    cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

    D Offline
    D Offline
    Dalek Dave
    wrote on last edited by
    #2

    No Programming Questions in the lounge. I am going to have to report you to yourself. Please give yourself a good dressing down and wag an admonishing finger at yourself!

    --------------------------------- I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC Link[^]

    C 1 Reply Last reply
    0
    • C Chris Maunder

      I am testing several depths of properties in an object to make sure they are safe before I call them:

      Test.NotNull(myObject);
      if (myObject != null)
      {
      Test.NotNull(myObject.MyProperty);
      if (myObject.MyProperty != null)
      Test.IsPositive(myObject.MyProperty.Id);
      ...
      }

      I was thinking it would be really cool to be able to do

      Test.NotNull(myObject).NotNull(myObject.MyProperty).IsPositive(myObject.MyProperty.Id);

      but obviously if myObject == null then we have a runtime null ref error because, regardless of what the NotNull method returns as part of the chaining, myObject is still null. So this got me thinking: You can do

      if (myObject != null && myObject.MyProperty != null)

      because of short circuit boolean evaluation in C#, but I was wondering, with my fairly mainstream experience in languages, if there are languages out there that would allow chaining of methods with short circuit evaluation. Essentially you'd have to have the input parameter be resolved after the method was called in order to have the method be able to say "I don't need the input parameter, please just ignore it". Has anyone heard of this? Would it open up a World Of Pain when it comes to debugging? Would it be useful? Am I procrastinating? --- Update: and it turns out this leads into a great discussion of extension methods. See The Maybe Monad[^] and Chained null checks and the Maybe monad[^] for two ways of achieving this. Once you've done that, debate the correctness of extension methods that are able by design to operate on a null references. I will be over there looking for new, shiny, distracting things.

      cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #3

      Oooh! Oooh! Oooh! Use ON ERROR RESUME! :-D

      1 Reply Last reply
      0
      • C Chris Maunder

        I am testing several depths of properties in an object to make sure they are safe before I call them:

        Test.NotNull(myObject);
        if (myObject != null)
        {
        Test.NotNull(myObject.MyProperty);
        if (myObject.MyProperty != null)
        Test.IsPositive(myObject.MyProperty.Id);
        ...
        }

        I was thinking it would be really cool to be able to do

        Test.NotNull(myObject).NotNull(myObject.MyProperty).IsPositive(myObject.MyProperty.Id);

        but obviously if myObject == null then we have a runtime null ref error because, regardless of what the NotNull method returns as part of the chaining, myObject is still null. So this got me thinking: You can do

        if (myObject != null && myObject.MyProperty != null)

        because of short circuit boolean evaluation in C#, but I was wondering, with my fairly mainstream experience in languages, if there are languages out there that would allow chaining of methods with short circuit evaluation. Essentially you'd have to have the input parameter be resolved after the method was called in order to have the method be able to say "I don't need the input parameter, please just ignore it". Has anyone heard of this? Would it open up a World Of Pain when it comes to debugging? Would it be useful? Am I procrastinating? --- Update: and it turns out this leads into a great discussion of extension methods. See The Maybe Monad[^] and Chained null checks and the Maybe monad[^] for two ways of achieving this. Once you've done that, debate the correctness of extension methods that are able by design to operate on a null references. I will be over there looking for new, shiny, distracting things.

        cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

        M Offline
        M Offline
        Maximilien
        wrote on last edited by
        #4

        Chris Maunder wrote:

        Am I procrastinating?

        Yes.

        Nihil obstat

        1 Reply Last reply
        0
        • C Chris Maunder

          I am testing several depths of properties in an object to make sure they are safe before I call them:

          Test.NotNull(myObject);
          if (myObject != null)
          {
          Test.NotNull(myObject.MyProperty);
          if (myObject.MyProperty != null)
          Test.IsPositive(myObject.MyProperty.Id);
          ...
          }

          I was thinking it would be really cool to be able to do

          Test.NotNull(myObject).NotNull(myObject.MyProperty).IsPositive(myObject.MyProperty.Id);

          but obviously if myObject == null then we have a runtime null ref error because, regardless of what the NotNull method returns as part of the chaining, myObject is still null. So this got me thinking: You can do

          if (myObject != null && myObject.MyProperty != null)

          because of short circuit boolean evaluation in C#, but I was wondering, with my fairly mainstream experience in languages, if there are languages out there that would allow chaining of methods with short circuit evaluation. Essentially you'd have to have the input parameter be resolved after the method was called in order to have the method be able to say "I don't need the input parameter, please just ignore it". Has anyone heard of this? Would it open up a World Of Pain when it comes to debugging? Would it be useful? Am I procrastinating? --- Update: and it turns out this leads into a great discussion of extension methods. See The Maybe Monad[^] and Chained null checks and the Maybe monad[^] for two ways of achieving this. Once you've done that, debate the correctness of extension methods that are able by design to operate on a null references. I will be over there looking for new, shiny, distracting things.

          cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

          P Offline
          P Offline
          peterchen
          wrote on last edited by
          #5

          For years I wished for something like Flibber f = Bugger?.GetGoodShoboil()?.Libbl; to evaluate to null silently if either Bugger is or GetGoodShoboil Returns null. I dimly remember last time I voiced this here, I was told to not want this by the disciples of the Occasionally Useful Suggestion Of Demeter[^], as well as an apparently unrelated Sir Or Madam Chris Munder who suggested to not add more garbage to this wonderful, sleek new thing called C#.

          ORDER BY what user wants

          C 1 Reply Last reply
          0
          • D Dalek Dave

            No Programming Questions in the lounge. I am going to have to report you to yourself. Please give yourself a good dressing down and wag an admonishing finger at yourself!

            --------------------------------- I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC Link[^]

            C Offline
            C Offline
            Chris Maunder
            wrote on last edited by
            #6

            I would if it were a programming question. And, regardless of the attempt at humour, I am sad, deeply sad, that it was you who jumped on the "no programming questions" bandwagon. So I'm going to jump on my soapbox because it's a fantastic way to procrastinate further, and bemoan the lack of interesting technical discussion on the lounge where bad jokes and political rhetoric seem to be more accepted than discussion on the topics that we as developers hold dearest to our hearts. For shame, David. For shame.

            cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

            N D C 3 Replies Last reply
            0
            • C Chris Maunder

              I am testing several depths of properties in an object to make sure they are safe before I call them:

              Test.NotNull(myObject);
              if (myObject != null)
              {
              Test.NotNull(myObject.MyProperty);
              if (myObject.MyProperty != null)
              Test.IsPositive(myObject.MyProperty.Id);
              ...
              }

              I was thinking it would be really cool to be able to do

              Test.NotNull(myObject).NotNull(myObject.MyProperty).IsPositive(myObject.MyProperty.Id);

              but obviously if myObject == null then we have a runtime null ref error because, regardless of what the NotNull method returns as part of the chaining, myObject is still null. So this got me thinking: You can do

              if (myObject != null && myObject.MyProperty != null)

              because of short circuit boolean evaluation in C#, but I was wondering, with my fairly mainstream experience in languages, if there are languages out there that would allow chaining of methods with short circuit evaluation. Essentially you'd have to have the input parameter be resolved after the method was called in order to have the method be able to say "I don't need the input parameter, please just ignore it". Has anyone heard of this? Would it open up a World Of Pain when it comes to debugging? Would it be useful? Am I procrastinating? --- Update: and it turns out this leads into a great discussion of extension methods. See The Maybe Monad[^] and Chained null checks and the Maybe monad[^] for two ways of achieving this. Once you've done that, debate the correctness of extension methods that are able by design to operate on a null references. I will be over there looking for new, shiny, distracting things.

              cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

              G Offline
              G Offline
              gavindon
              wrote on last edited by
              #7

              Chris Maunder wrote:

              Am I procrastinating?

              I think this would get my vote...

              Beauty is in the eye of the beer-holder Be careful which toes you step on today, they might be connected to the foot that kicks your butt tomorrow. You can't scare me, I have children.

              1 Reply Last reply
              0
              • P peterchen

                For years I wished for something like Flibber f = Bugger?.GetGoodShoboil()?.Libbl; to evaluate to null silently if either Bugger is or GetGoodShoboil Returns null. I dimly remember last time I voiced this here, I was told to not want this by the disciples of the Occasionally Useful Suggestion Of Demeter[^], as well as an apparently unrelated Sir Or Madam Chris Munder who suggested to not add more garbage to this wonderful, sleek new thing called C#.

                ORDER BY what user wants

                C Offline
                C Offline
                Chris Maunder
                wrote on last edited by
                #8

                I was drunk. That suggestion is awesome and I recant.

                cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                P 1 Reply Last reply
                0
                • C Chris Maunder

                  I am testing several depths of properties in an object to make sure they are safe before I call them:

                  Test.NotNull(myObject);
                  if (myObject != null)
                  {
                  Test.NotNull(myObject.MyProperty);
                  if (myObject.MyProperty != null)
                  Test.IsPositive(myObject.MyProperty.Id);
                  ...
                  }

                  I was thinking it would be really cool to be able to do

                  Test.NotNull(myObject).NotNull(myObject.MyProperty).IsPositive(myObject.MyProperty.Id);

                  but obviously if myObject == null then we have a runtime null ref error because, regardless of what the NotNull method returns as part of the chaining, myObject is still null. So this got me thinking: You can do

                  if (myObject != null && myObject.MyProperty != null)

                  because of short circuit boolean evaluation in C#, but I was wondering, with my fairly mainstream experience in languages, if there are languages out there that would allow chaining of methods with short circuit evaluation. Essentially you'd have to have the input parameter be resolved after the method was called in order to have the method be able to say "I don't need the input parameter, please just ignore it". Has anyone heard of this? Would it open up a World Of Pain when it comes to debugging? Would it be useful? Am I procrastinating? --- Update: and it turns out this leads into a great discussion of extension methods. See The Maybe Monad[^] and Chained null checks and the Maybe monad[^] for two ways of achieving this. Once you've done that, debate the correctness of extension methods that are able by design to operate on a null references. I will be over there looking for new, shiny, distracting things.

                  cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                  E Offline
                  E Offline
                  Espen Harlinn
                  wrote on last edited by
                  #9

                  You can implement this using extension methods[^] ...

                  Espen Harlinn Principal Architect, Software - Goodtech Projects & Services AS Projects promoting programming in "natural language" are intrinsically doomed to fail. Edsger W.Dijkstra

                  L R 2 Replies Last reply
                  0
                  • C Chris Maunder

                    I am testing several depths of properties in an object to make sure they are safe before I call them:

                    Test.NotNull(myObject);
                    if (myObject != null)
                    {
                    Test.NotNull(myObject.MyProperty);
                    if (myObject.MyProperty != null)
                    Test.IsPositive(myObject.MyProperty.Id);
                    ...
                    }

                    I was thinking it would be really cool to be able to do

                    Test.NotNull(myObject).NotNull(myObject.MyProperty).IsPositive(myObject.MyProperty.Id);

                    but obviously if myObject == null then we have a runtime null ref error because, regardless of what the NotNull method returns as part of the chaining, myObject is still null. So this got me thinking: You can do

                    if (myObject != null && myObject.MyProperty != null)

                    because of short circuit boolean evaluation in C#, but I was wondering, with my fairly mainstream experience in languages, if there are languages out there that would allow chaining of methods with short circuit evaluation. Essentially you'd have to have the input parameter be resolved after the method was called in order to have the method be able to say "I don't need the input parameter, please just ignore it". Has anyone heard of this? Would it open up a World Of Pain when it comes to debugging? Would it be useful? Am I procrastinating? --- Update: and it turns out this leads into a great discussion of extension methods. See The Maybe Monad[^] and Chained null checks and the Maybe monad[^] for two ways of achieving this. Once you've done that, debate the correctness of extension methods that are able by design to operate on a null references. I will be over there looking for new, shiny, distracting things.

                    cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                    D Offline
                    D Offline
                    Dave Kreskowiak
                    wrote on last edited by
                    #10

                    Interesting. Today, you'd have to wrap it in a Try/Catch and eat the null reference exception if thrown. But, if you could do this, you would have to be able to tell the compiler you don't want the exception thrown and to just continue with the next statement. Hell, they added async/await keywords, why not add another one? I'm kind of thinking that this would complicate debugging a bit too.

                    A guide to posting questions on CodeProject[^]
                    Dave Kreskowiak

                    1 Reply Last reply
                    0
                    • C Chris Maunder

                      I would if it were a programming question. And, regardless of the attempt at humour, I am sad, deeply sad, that it was you who jumped on the "no programming questions" bandwagon. So I'm going to jump on my soapbox because it's a fantastic way to procrastinate further, and bemoan the lack of interesting technical discussion on the lounge where bad jokes and political rhetoric seem to be more accepted than discussion on the topics that we as developers hold dearest to our hearts. For shame, David. For shame.

                      cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                      N Offline
                      N Offline
                      NormDroid
                      wrote on last edited by
                      #11

                      If voting was available, I would of shot you a 5, but alas.....

                      Software Kinetics - Dependable Software news

                      S P 2 Replies Last reply
                      0
                      • C Chris Maunder

                        I would if it were a programming question. And, regardless of the attempt at humour, I am sad, deeply sad, that it was you who jumped on the "no programming questions" bandwagon. So I'm going to jump on my soapbox because it's a fantastic way to procrastinate further, and bemoan the lack of interesting technical discussion on the lounge where bad jokes and political rhetoric seem to be more accepted than discussion on the topics that we as developers hold dearest to our hearts. For shame, David. For shame.

                        cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                        D Offline
                        D Offline
                        Dalek Dave
                        wrote on last edited by
                        #12

                        Do Not Procrastinate Today! Wait until tomorrow and have a whole day of it. Until then, stare at this picture[^] of a cat.

                        --------------------------------- I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC Link[^]

                        1 Reply Last reply
                        0
                        • C Chris Maunder

                          I was drunk. That suggestion is awesome and I recant.

                          cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                          P Offline
                          P Offline
                          peterchen
                          wrote on last edited by
                          #13

                          Chris Maunder wrote:

                          I was drunk.

                          You always say that :cool:

                          ORDER BY what user wants

                          D N 2 Replies Last reply
                          0
                          • C Chris Maunder

                            I am testing several depths of properties in an object to make sure they are safe before I call them:

                            Test.NotNull(myObject);
                            if (myObject != null)
                            {
                            Test.NotNull(myObject.MyProperty);
                            if (myObject.MyProperty != null)
                            Test.IsPositive(myObject.MyProperty.Id);
                            ...
                            }

                            I was thinking it would be really cool to be able to do

                            Test.NotNull(myObject).NotNull(myObject.MyProperty).IsPositive(myObject.MyProperty.Id);

                            but obviously if myObject == null then we have a runtime null ref error because, regardless of what the NotNull method returns as part of the chaining, myObject is still null. So this got me thinking: You can do

                            if (myObject != null && myObject.MyProperty != null)

                            because of short circuit boolean evaluation in C#, but I was wondering, with my fairly mainstream experience in languages, if there are languages out there that would allow chaining of methods with short circuit evaluation. Essentially you'd have to have the input parameter be resolved after the method was called in order to have the method be able to say "I don't need the input parameter, please just ignore it". Has anyone heard of this? Would it open up a World Of Pain when it comes to debugging? Would it be useful? Am I procrastinating? --- Update: and it turns out this leads into a great discussion of extension methods. See The Maybe Monad[^] and Chained null checks and the Maybe monad[^] for two ways of achieving this. Once you've done that, debate the correctness of extension methods that are able by design to operate on a null references. I will be over there looking for new, shiny, distracting things.

                            cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                            E Offline
                            E Offline
                            Ennis Ray Lynch Jr
                            wrote on last edited by
                            #14

                            The null object pattern.

                            public class Customer{}
                            public class NullCustomer : Customer{}

                            Then instead of assigning a customer reference to null you assign it to the null customer, etc. Then you can do all of your work without null checks. There are some instances where this works really, really, well. However, if you are chaining functions it is probably some sort of workflow so there maybe another solution that issue.

                            Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost "All users always want Excel" --Ennis Lynch

                            1 Reply Last reply
                            0
                            • P peterchen

                              Chris Maunder wrote:

                              I was drunk.

                              You always say that :cool:

                              ORDER BY what user wants

                              D Offline
                              D Offline
                              Dalek Dave
                              wrote on last edited by
                              #15

                              He's always drunk.

                              --------------------------------- I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC Link[^]

                              1 Reply Last reply
                              0
                              • P peterchen

                                Chris Maunder wrote:

                                I was drunk.

                                You always say that :cool:

                                ORDER BY what user wants

                                N Offline
                                N Offline
                                Nagy Vilmos
                                wrote on last edited by
                                #16

                                No. I always say that.


                                Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

                                D J 2 Replies Last reply
                                0
                                • C Chris Maunder

                                  I would if it were a programming question. And, regardless of the attempt at humour, I am sad, deeply sad, that it was you who jumped on the "no programming questions" bandwagon. So I'm going to jump on my soapbox because it's a fantastic way to procrastinate further, and bemoan the lack of interesting technical discussion on the lounge where bad jokes and political rhetoric seem to be more accepted than discussion on the topics that we as developers hold dearest to our hearts. For shame, David. For shame.

                                  cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                                  C Offline
                                  C Offline
                                  Corporal Agarn
                                  wrote on last edited by
                                  #17

                                  I think you should ban him! :laugh: ;P

                                  1 Reply Last reply
                                  0
                                  • N Nagy Vilmos

                                    No. I always say that.


                                    Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

                                    D Offline
                                    D Offline
                                    Dalek Dave
                                    wrote on last edited by
                                    #18

                                    You're always drunk!

                                    --------------------------------- I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC Link[^]

                                    N 1 Reply Last reply
                                    0
                                    • D Dalek Dave

                                      You're always drunk!

                                      --------------------------------- I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC Link[^]

                                      N Offline
                                      N Offline
                                      Nagy Vilmos
                                      wrote on last edited by
                                      #19

                                      I may well be tonight.


                                      Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

                                      1 Reply Last reply
                                      0
                                      • N NormDroid

                                        If voting was available, I would of shot you a 5, but alas.....

                                        Software Kinetics - Dependable Software news

                                        S Offline
                                        S Offline
                                        Shelby Robertson
                                        wrote on last edited by
                                        #20

                                        Norm .net wrote:

                                        If voting was available, I would of shot you a 5, but alas.....

                                        Seconded.

                                        CPallini wrote:

                                        You cannot argue with agile people so just take the extreme approach and shoot him. :Smile:

                                        1 Reply Last reply
                                        0
                                        • C Chris Maunder

                                          I am testing several depths of properties in an object to make sure they are safe before I call them:

                                          Test.NotNull(myObject);
                                          if (myObject != null)
                                          {
                                          Test.NotNull(myObject.MyProperty);
                                          if (myObject.MyProperty != null)
                                          Test.IsPositive(myObject.MyProperty.Id);
                                          ...
                                          }

                                          I was thinking it would be really cool to be able to do

                                          Test.NotNull(myObject).NotNull(myObject.MyProperty).IsPositive(myObject.MyProperty.Id);

                                          but obviously if myObject == null then we have a runtime null ref error because, regardless of what the NotNull method returns as part of the chaining, myObject is still null. So this got me thinking: You can do

                                          if (myObject != null && myObject.MyProperty != null)

                                          because of short circuit boolean evaluation in C#, but I was wondering, with my fairly mainstream experience in languages, if there are languages out there that would allow chaining of methods with short circuit evaluation. Essentially you'd have to have the input parameter be resolved after the method was called in order to have the method be able to say "I don't need the input parameter, please just ignore it". Has anyone heard of this? Would it open up a World Of Pain when it comes to debugging? Would it be useful? Am I procrastinating? --- Update: and it turns out this leads into a great discussion of extension methods. See The Maybe Monad[^] and Chained null checks and the Maybe monad[^] for two ways of achieving this. Once you've done that, debate the correctness of extension methods that are able by design to operate on a null references. I will be over there looking for new, shiny, distracting things.

                                          cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                                          P Offline
                                          P Offline
                                          Pete OHanlon
                                          wrote on last edited by
                                          #21

                                          There is a way that you could do this, but it would be much more trouble than it was worth, and it would definitely open up a whole world of hurt. Effectively, what would need to be implemented is an IL rewriter to manage and rewrite the chain internally. Then you could create a fluid interface that would need to be recognised as the item that needs rewriting.

                                          *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

                                          "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                                          CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

                                          C 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups