Loading ...
Sorry, an error occurred while loading the content.
 

exercise 2.76

Expand Messages
  • Myron Wu
    I was wondering what other people got for this question. I m pretty sure for the first question, either data-directed or message-passing would be suited for a
    Message 1 of 4 , Aug 20, 2005
      I was wondering what other people got for this question. I'm pretty
      sure for the first question, either data-directed or message-passing
      would be suited for a system that has types being added often...
      unless maybe the deciding factor is whether or not you need generic
      procedures of more than one argument like the footnote says at the
      bottom of page 187.

      But what about the second question where new operations are added most
      often? At first it looks like the answer's the same, either
      data-directed or message-passing. But you might make an argument for
      explicit dispatch if very very few data types are being added and you
      want to organize your code in terms of functionality rather than
      types?
    • John Berthels
      ... Perhaps. But a potential problem is that should a new type be added in the future, you ve got all those explicit ops to go and edit, so I d say that
      Message 2 of 4 , Aug 21, 2005
        > But what about the second question where new operations are added most
        > often? At first it looks like the answer's the same, either
        > data-directed or message-passing. But you might make an argument for
        > explicit dispatch if very very few data types are being added and you
        > want to organize your code in terms of functionality rather than
        > types?

        Perhaps. But a potential problem is that should a new type be added in
        the future, you've got all those explicit ops to go and edit, so I'd
        say that explicit dispatch isn't a good idea in this case.

        The dispatch code is repeated code. All the approaches require
        boilerplate of some kind, but the explicit dispatch requires repeated
        code which contains the list of types. My alarm bells would start to
        ring once I'd typed out that list twice.

        Hmm...why don't I get the same worry about repeating the operation
        names in the data-directed or message passing cases? Perhaps its
        because that these types need to declare somehow what they can do?

        jb
        --
        john@...
      • Myron Wu
        ... Alright that s what I thought too. It s just that the way they asked the questions made it sound like there might be different answers to em. I guess
        Message 3 of 4 , Aug 21, 2005
          > Perhaps. But a potential problem is that should a new type be added in
          > the future, you've got all those explicit ops to go and edit, so I'd
          > say that explicit dispatch isn't a good idea in this case.

          Alright that's what I thought too. It's just that the way they asked
          the questions made it sound like there might be different answers to
          'em. I guess the implication is that data-directed or message-passing
          are more suitable for extensible systems instead.
        • John Berthels
          ... Thats the way I read it, certainly. jb -- john@berthels.co.uk
          Message 4 of 4 , Aug 21, 2005
            On 8/21/05, Myron Wu <myronwu@...> wrote:
            > Alright that's what I thought too. It's just that the way they asked
            > the questions made it sound like there might be different answers to
            > 'em. I guess the implication is that data-directed or message-passing
            > are more suitable for extensible systems instead.

            Thats the way I read it, certainly.

            jb
            --
            john@...
          Your message has been successfully submitted and would be delivered to recipients shortly.