What is the implementation of sets used in pascal?

别说谁变了你拦得住时间么 提交于 2019-12-01 21:38:32

According to this explanation, Pascal internally represents sets as bit strings. However, the article apparently does not refer to a specific implementation of Pascal. In this documentation, it is also stated that bitstrings are used for representation. More precisely, this documentation explicitly mentions 32 bytes for storage of a set.

The Free Pascal language documentation is the "reference" guide, the rtl is the runtime guide. Compiler options and directives are in the programmers guide, see the $pack* links below.

Sets are bitfields, differing in size depending on options. (e.g.$packset and $packenum ), to maximum size of 256 bits, 32 bytes (this is an old TP limit).

IIRC in (obj)FPC mode, sets grow with wordsize, and in Delphi mode with byte sized granularity, but that is a bit x86 centric. The size=3 bytes is however not possible, and will be rounded up to 4.

The lower bound is always 0, so a set of 8..10 is 2 bytes (0..15) even though it can only hold 3 values (8,9,10).

Besides this there is also a little endian vs big endian issue. On big endian systems you can't access set fields alternately bytewise and wordwise. Afaik FPC mostly accesses them wordwise, but it is a while I ago that I last checked that.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!