From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,19d0849c68914783 X-Google-Attributes: gid103376,public From: Thom Brooke Subject: Re: Design problem using Multiple Dispatch or Redispatch (long) Date: 2000/03/15 Message-ID: <38CEEF82.1DD70BED@yahoo.com>#1/1 X-Deja-AN: 597612841 Content-Transfer-Encoding: 7bit References: <38CDAA56.36B9E1C1@yahoo.com> <38ce8f82@eeyore.callnetuk.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 953086032 158.252.164.50 (Tue, 14 Mar 2000 18:07:12 PST) Organization: EarthLink Inc. -- http://www.EarthLink.net MIME-Version: 1.0 NNTP-Posting-Date: Tue, 14 Mar 2000 18:07:12 PST Newsgroups: comp.lang.ada Date: 2000-03-15T00:00:00+00:00 List-Id: Nick Roberts wrote: > > First, you define an access-to-procedure type as follows: > > type Command_Executor is procedure (Command: Root_Command_Type'Class; > Processor: > Root_Processor_Type'Class); > > Now - and this is the key bit - you define two types which classify your > commands and processors: > > type Command_Category is (...); > type Processor_Category is (...); > > And functions that will categorise a command or processor: > > function Category (Command: in Root_Command_Type) return > Command_Category; > function Category (Processor: in Root_Processor_Type) return > Processor_Category; > > Now you declare an array which relates categories to executors: > > Executor: constant array (Command_Category, > Processor_Category) of > Command_Executor := > (Elbow_Bending => > Teenagers => Execute_Bend_Elbow_On_Teenager'Access, > Twentysomethings => > Execute_Bend_Elbow_On_Twentysomething'Access, > ... > Ancient_Crinklies => null); > ...); > > Null access values are used to indicate which kinds of command cannot be > executed by which kinds of processor. Note how commands and processors can > be added without necessarily having to change this lookup table (provided > they fit into existing categories). I've made the array constant, so the > addition of a new category could prompt substantial recompilation: if this > might be a problem, you might want to consider using a variable table, with > some kind of dynamic 'registration' method for populating it. > > -- > Nick Roberts > http://www.adapower.com/lab/adaos I was looking at something like this. Although it was more Processor-centric, in that each Processor would define its own Command/Execution association table. Command "categorization" would have been more by a "chain-of-responsibility" pattern. Unfortunately, each Command really is unique, so each one has distinct Execute for each supporting processor. Thanks. I'll give this a try. -- -- Thom Brooke -- Cut out "_CUT_OUT" to get my real email address.