[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: Language War (Re: "C" Manual)



On Mon, 7 Jan 2002 11:27:10 -0500, dman <dsh8290@rit.edu> wrote:

[snip]
> When you say that, in C, something is an 'int', is it possible to have
> a bit pattern there that is not a valid 'int'?  No.  'int' describes
> the set of all valid values and every possible bit pattern you can
> stick there is a valid int.  In many cases when you write 'int' in
> your code (for example the java.util.Vector.getElement() method) you
> don't really want all the valid values that 'int' describes, but
> merely a subset of them (0<=i<length).  The problem is that today's
> programming languages don't provide a mechanism to express this so
> programmers approximate it with types that describe supersets of the
> set they want.  (this explains why I dislike java and its type system
> so much; for C it is acceptable because C excels at the low-level
> problems it was intended to solve)

FYI:  There are modern languages where you can define limimited range
numerical types.  Ada is one such language:

   type Tri_State is range 0 .. 2;

   or

   subtype Tri_State is Integer range 0 .. 2;


-- 
Eric G. Miller <egm2@jps.net>



Reply to: