Why is an int in OCaml only 31 bits?

后端 未结 5 907
感情败类
感情败类 2020-12-12 12:53

Haven\'t seen this \"feature\" anywhere else. I know that the 32nd bit is used for garbage collection. But why is it that way only for ints and not for the other basic types

5条回答
  •  执念已碎
    2020-12-12 12:56

    Why is an int in OCaml only 31 bits?

    Basically, to get the best possible performance on the Coq theorem prover where the dominant operation is pattern matching and the dominant data types are variant types. The best data representation was found to be a uniform representation using tags to distinguish pointers from unboxed data.

    But why is it that way only for ints and not for the other basic types?

    Not only int. Other types such as char and enums use the same tagged representation.

提交回复
热议问题