Enumerated data types

mandel@forwiss.uni-passau.de (Luis Mandel)
Thu, 23 Aug 90 13:48:26 GMT

          From comp.compilers

Related articles
Enumerated data types mandel@forwiss.uni-passau.de (1990-08-23)
Re: Enumerated data types moss@cs.umass.edu (1990-08-24)
Re: Enumerated data types skrenta@amix.commodore.com (1990-08-15)
Re: Enumerated data types dik@cwi.nl (1990-08-24)
Re: Enumerated data types ok@goanna.cs.rmit.OZ.AU (1990-08-27)
Re: Enumerated data types jejones@microware.com (1990-08-27)
Re: Enumerated data types perelgut@turing.toronto.edu (1990-08-24)
[6 later articles]
| List of all articles for this month |

Newsgroups: comp.compilers
From: mandel@forwiss.uni-passau.de (Luis Mandel)
Keywords: C, Pascal, design
Organization: University of Passau, W-Germany
Date: Thu, 23 Aug 90 13:48:26 GMT

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:

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

        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]

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.