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. Why do I listen to my sleep coding self?

Why do I listen to my sleep coding self?

Scheduled Pinned Locked Moved The Lounge
csharpdesignquestion
41 Posts 20 Posters 0 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.
  • L Lost User

    0 times. I've wished that interfaces could contain static methods so that T.someFunction could exist for generics (constrained to that interface), but that's a completely separate issue. (that can't work in C# of course) How is "static virtual" even a reasonable concept? No instance = no vptr = no dynamic dispatch.

    S Offline
    S Offline
    SortaCore
    wrote on last edited by
    #31

    I once coded a class function in C++ that calls realloc() or malloc(), based on whether "this" points to null. It then deletes this and returns This.

    L 1 Reply Last reply
    0
    • S SortaCore

      I once coded a class function in C++ that calls realloc() or malloc(), based on whether "this" points to null. It then deletes this and returns This.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #32

      That's.. kind of dirty

      S 1 Reply Last reply
      0
      • L Lost User

        That's.. kind of dirty

        S Offline
        S Offline
        SortaCore
        wrote on last edited by
        #33

        Not only that, it calls _msize() on the this pointer and checks against another size parameter for the realloc. The last member in the class was a 0-byte array, for which the _msize() of the pointer minus size of other class members gave the array size.

        1 Reply Last reply
        0
        • OriginalGriffO OriginalGriff

          In bed last night, I dreamt a wonderful improvement to the design of some software I'm working on. It would clean it up, move the code into it's appropriate classes, make it all beautiful. So I have just coded it. Or at least, I coded 3/4 of it. That was the point when I thought "Hang on a moment, you can't have abstract static methods in C#". :doh: Bugger. Note to self: don't listen to me when I'm sleepy. Anyone else done this? Constructed a massive edifice of beautiful code in your mind, only to find when you have got sufficient caffeine in your system that it has a fatal, fundamental, flaw?

          Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)

          J Offline
          J Offline
          john morrison leon
          wrote on last edited by
          #34

          If you are going tp code in your sleep then choose a language that will better match your fantasies.

          F 1 Reply Last reply
          0
          • J JimmyRopes

            very different from current implementations[^] :-D

            **_Once you lose your pride the rest is easy.

            I would agree with you but then we both would be wrong._**
            The report of my death was an exaggeration - Mark Twain Simply Elegant Designs JimmyRopes Designs
            I'm on-line therefore I am. JimmyRopes

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

            Oh my, I've been Osmosian-rolled. :sigh:

            You'll never get very far if all you do is follow instructions.

            1 Reply Last reply
            0
            • J JimmyRopes

              very different from current implementations[^] :-D

              **_Once you lose your pride the rest is easy.

              I would agree with you but then we both would be wrong._**
              The report of my death was an exaggeration - Mark Twain Simply Elegant Designs JimmyRopes Designs
              I'm on-line therefore I am. JimmyRopes

              P Offline
              P Offline
              Paulo Zemek
              wrote on last edited by
              #36

              My anti-virus considered it as a trojan horse.

              1 Reply Last reply
              0
              • B BobJanova

                It's actually a reasonable concept if you allow static inheritance (i.e. static virtual in C# speak), and that's a really useful concept that is missing in C#. How many times have you had to create an instanced service class, even though it has no state (so should be static), because you can't have static members in an interface or virtual static members in a base class?

                P Offline
                P Offline
                patbob
                wrote on last edited by
                #37

                BobJanova wrote:

                static inheritance (i.e. static virtual in C# speak), and that's a really useful concept that is missing in C#

                Couldn't you use a singleton of some related class hierarchy that implements the "static" code?

                We can program with only 1's, but if all you've got are zeros, you've got nothing.

                B 1 Reply Last reply
                0
                • J john morrison leon

                  If you are going tp code in your sleep then choose a language that will better match your fantasies.

                  F Offline
                  F Offline
                  Frank Malcolm
                  wrote on last edited by
                  #38

                  As Gilbert & Sullivan put it (in Iolanthe), When you’re lying awake With a dismal headache, And repose is taboo’d by anxiety, I conceive you may use Any language you choose To indulge in, without impropriety;

                  1 Reply Last reply
                  0
                  • OriginalGriffO OriginalGriff

                    In bed last night, I dreamt a wonderful improvement to the design of some software I'm working on. It would clean it up, move the code into it's appropriate classes, make it all beautiful. So I have just coded it. Or at least, I coded 3/4 of it. That was the point when I thought "Hang on a moment, you can't have abstract static methods in C#". :doh: Bugger. Note to self: don't listen to me when I'm sleepy. Anyone else done this? Constructed a massive edifice of beautiful code in your mind, only to find when you have got sufficient caffeine in your system that it has a fatal, fundamental, flaw?

                    Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)

                    P Offline
                    P Offline
                    phil o
                    wrote on last edited by
                    #39

                    Far more often than I would like to :)

                    There are two kinds of people in the world: those who separate humankind in two distinct categories, and those who don't. "I have two hobbies: breasts." DSK

                    1 Reply Last reply
                    0
                    • OriginalGriffO OriginalGriff

                      In bed last night, I dreamt a wonderful improvement to the design of some software I'm working on. It would clean it up, move the code into it's appropriate classes, make it all beautiful. So I have just coded it. Or at least, I coded 3/4 of it. That was the point when I thought "Hang on a moment, you can't have abstract static methods in C#". :doh: Bugger. Note to self: don't listen to me when I'm sleepy. Anyone else done this? Constructed a massive edifice of beautiful code in your mind, only to find when you have got sufficient caffeine in your system that it has a fatal, fundamental, flaw?

                      Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)

                      C Offline
                      C Offline
                      Carsten Konig
                      wrote on last edited by
                      #40

                      if you need vacation/some time off ... well do what you want. I never really dreamed of something like this but I tend to think about "problems" while being close to sleep or exercising. In both cases those great ideas you have seems so good but turn out to be complete bullshit when thinking them through with enough oxygen in the right parts of my brain :D So the only advice I can give: better forget.

                      1 Reply Last reply
                      0
                      • P patbob

                        BobJanova wrote:

                        static inheritance (i.e. static virtual in C# speak), and that's a really useful concept that is missing in C#

                        Couldn't you use a singleton of some related class hierarchy that implements the "static" code?

                        We can program with only 1's, but if all you've got are zeros, you've got nothing.

                        B Offline
                        B Offline
                        BobJanova
                        wrote on last edited by
                        #41

                        Well sure, but that's obviously working around a language limitation. If you're making instances of classes that store no state, you should be using static inheritance instead, and the only reason we don't is that it's not supported.

                        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