comp.lang.ada
 help / color / mirror / Atom feed
From: woodruff@tanana.llnl.gov
Subject: Tagged type: how to know which specific type
Date: 18 Mar 1995 19:43:34 GMT
Date: 1995-03-18T19:43:34+00:00	[thread overview]
Message-ID: <WOODRUFF.95Mar18114334@tanana.llnl.gov> (raw)

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 <whatever>
  Type Diesel is new fuel with <whatever>
  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



             reply	other threads:[~1995-03-18 19:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-03-18 19:43 woodruff [this message]
1995-03-19 22:27 ` Tagged type: how to know which specific type Robert Dewar
1995-03-21 14:38 ` Tucker Taft
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox