Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!ncar!ico!haddock!ima!esegue!compilers-sender From: mandel@forwiss.uni-passau.de (Luis Mandel) Newsgroups: comp.compilers Subject: Enumerated data types Keywords: C, Pascal, design Message-ID: <1990Aug23.134826.2865@forwiss.uni-passau.de> Date: 23 Aug 90 13:48:26 GMT Sender: compilers-sender@esegue.segue.boston.ma.us Reply-To: mandel@forwiss.uni-passau.de (Luis Mandel) Organization: University of Passau, W-Germany Lines: 48 Approved: compilers@esegue.segue.boston.ma.us Hello world, I'm studing types, in particular enumerated data types of programming languages. For example using Pascal enumerated data types, we can write the following: type car_colours = (red, blue, brown, black); and also we obtain pred, suc and ord as associated functions to the new data type: suc(red) = blue and so on. Then we can't define another enumerated data type that involves the tokens red, blue, brown or black, because of these functions pred and suc. For example, if it were possible to write type bike_colours = (orange, red, green, white); it were an ambiguity with suc(red) because there are two possibilities. The same is with functions pre and ord. Now my question is: anybody knows if there are languages that allows anything like car_colours = (red, blue, brown, black); bike_colours = (orange, red, green, white); and have these functions defined with an extra parameter, for example: suc (car_colour, red) = blue suc (bike_colour, red) = green Are there problems with this definition of enumerated data types? Could be there difficulties trying to specify the semantics of suc, pred and ord?, Any suggestion? Thanks in advance, Luis (mandel@forwiss.uni-passau.de) -- Luis Mandel mandel@forwiss.uni-passau.de [I'd think that if you always qualified your names, you might as well call them car_colour_red and bike_colour_red. -John] -- Send compilers articles to compilers@esegue.segue.boston.ma.us {ima | spdcc | world}!esegue. Meta-mail to compilers-request@esegue.