<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 11 Mar 2013, at 14:32, Daniel Gaspary wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="font-family: monospace; ">In my case the enum has near 600 elements.<br><br>TMyEnum = (me1, me2...);<br><br>The set though would never be used to contain more than 256.<br><br>TMySet = set of TMyEnum;<br><br>Is it not viable to modify the compiler to compile the code and raise<br>an exception if I try to add more than 256 elements to the set ?<br></span></span></blockquote></div><br><div>A set is basically a bitpacked array of boolean. Element X is set to true if you add X to the set, and to false if you remove it again. That means that if you have a set with 600 possible values, you need at least 600 bits, regardless of how many elements are inside it.</div><div><br></div><div>The above also shows an alternative to sets in that case: you can use a bitpacked array[TMyEnum] of boolean instead. Of course, then you can't use the regular set operators.</div><div><br></div><div><br></div><div>Jonas</div></body></html>