[Info-vax] C limitations, was: Re: VMS process communication
Arne Vajhøj
arne at vajhoej.dk
Mon Mar 27 19:13:07 EDT 2023
On 3/27/2023 6:46 PM, Arne Vajhøj wrote:
> On 3/27/2023 6:16 PM, Johnny Billquist wrote:
>> On 2023-03-27 14:27, Simon Clubley wrote:
>>> enums are integers, not a type.
>>
>> Not sure I consider the enum thing to be much of a deal. Unless we
>> compare to Ada, which is the only language I've seen which really do
>> enums properly as its own type.
>
> Java enums are also very much non-int.
And some languages require some "arm twisting"
to make enums work like integers.
VMS Pascal:
program enumchk(input,output);
type
direction = (north, south, west, east);
color = (red, green, blue, yellow);
material = (wood, iron, concrete);
var
d : direction;
c : color;
m : material;
begin
d := west;
c := green;
m := (ord(d) div ord(c))::material;
writeln(m);
end.
and C#:
using System;
namespace EnumChk
{
enum Direction { North, South, West, East }
enum Color { Red, Green, Blue, Yello }
enum Material { Wood, Iron, Concrete }
public class Program
{
public static void Main(string[] args)
{
Direction d = Direction.West;
Color c = Color.Green;
Material m = (Material)((int)d / (int)c);
Console.WriteLine(m);
Console.ReadKey();
}
}
}
both write concrete (different case), but one could
argue that the programmer asked for it.
Arne
More information about the Info-vax
mailing list