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=2.4 required=5.0 tests=BAYES_50,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,62a0e3de4e2ff2c7,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-03-18 11:46:14 PST Path: bga.com!news.sprintlink.net!howland.reston.ans.net!spool.mu.edu!uwm.edu!lll-winken.llnl.gov!winken.llnl.gov!woodruff From: woodruff@tanana.llnl.gov Newsgroups: comp.lang.ada Subject: Tagged type: how to know which specific type Date: 18 Mar 1995 19:43:34 GMT Organization: Lawrence Livermore National Lab Distribution: world Message-ID: Reply-To: woodruff1@llnl.gov NNTP-Posting-Host: tanana.llnl.gov Date: 1995-03-18T19:43:34+00:00 List-Id: I've been puzzling for some time about the proper use of tagged types when I wish to have information about what type of object I'm modeling, without having the object itself. In the olden days using a discriminated record type I would have an easy solution because the discriminant itself was a visible type, and I could use a value of that type to give information about a record instance. Let me pose a problem that I think illustrates my puzzle; I've had excellent advice from my c.l.a friends in the past and I hope that will happen again! Suppose my discourse is about vehicles and their fuels; I'll just talk about the fuel here: Type fuel is tagged Type Diesel is new fuel with Type Gasoline is new fuel ..... So if I want to put fuel in my car, how can I be sure I get the right stuff? Naively I imagine going to the pump, reading the label on the pump, and dispensing fuel iff the pump has gasoline. How do I ask the pump what kind it has without dispensing (more formally, what kind of answer will I get if I ask that question of the pump)? I don't want to take some fuel if it's the wrong kind, and I sure don't want to pour the generic stuff into my car, and depend on the car to raise an exception if it's not gasoline. To go even further, suppose I'm in the filling station business. The OSHA has just made a new regulation: for every chemical I have in inventory, I'm required to have a document - the Material Safety Data Sheet - that carries emergency information about toxicity etc. So now I call the official printer and ask for copies of the MSDS for gasoline. How do I say which MSDS I want? It seems if I hope to use the language to assure that my model is correct, that I must send some gasoline to the printing plant(!) -- John Woodruff Lawrence Livermore National Lab 510 422 4661