Okaml representation of values ​​- Atoms

I looked at the internal representation of some OCaml values. The representation of an empty array is atom(0), i.e. Block with tag=0and size=0. Empty arrays of floats are also represented atom(0).

Is there any OCaml value represented by atom c tag > 0? If not: for what purpose does the OCaml bytecode set contain instructions ATOM n?

+4
source share
1 answer

The> 0 tag is used for constructors with arguments, which makes them non-atoms. On the other hand, constructors without arguments are stored as int instead of blocks, so again not atoms. Therefore, I think atom (0) is not used. Besides...

How to create a constructor with an empty string?

# type t = A of int | B of { };;
Error: Syntax error

It seems that empty entries are not allowed. I can’t think of another way to create a block of size 0 with a tag other than creating such a block directly. But this will not use the ATOM statement.

+1
source

Source: https://habr.com/ru/post/1670932/


All Articles