<html><body><div style="color:#000; background-color:#fff, font-family:arial, helvetica, sans-serif;font-size:12pt"><span>Small bikeshed here, but ilength seems akin to idup, where the 'i' means immutable.<br><br>I'm not against ilength, it's definitely understandable (hey, are we turning into Apple here?), but there is that possibility for confusion.<br><br>I have no better alternatives to offer however.<br><br>I agree it should be uint, and in that case, you should make this a noop when compiling on 32-bit systems.<br><br>-Steve<br class="yui-cursor"></span><div style="font-family: inherit; font-size: 12pt;"><br><div style="font-family: inherit; font-size: 12pt;"><font face="Arial" size="2"><div style="border: 1px solid rgb(204, 204, 204); line-height: 0pt; font-size: 0pt; margin: 5px 0px; padding: 0pt;" readonly="true" class="hr" contenteditable="false"></div><b><span style="font-weight: bold;">From:</span></b> David Simcha
 <dsimcha@gmail.com><br><b><span style="font-weight: bold;">To:</span></b> Discuss the phobos library for D <phobos@puremagic.com><br><b><span style="font-weight: bold;">Cc:</span></b> <br><b><span style="font-weight: bold;">Sent:</span></b> Thursday, February 17, 2011 8:59 AM<br><b><span style="font-weight: bold;">Subject:</span></b> [phobos] std.array.ilength<br></font><br> 
Hey guys,<br><br>Kagamin just came up with a simple but great idea to mitigate the pedantic nature of 64-bit to 32-bit integer conversions in cases where using size_t doesn't cut it.  Examples are storing arrays of indices into other arrays, where using size_t would be a colossal waste of space if it's safe to assume none of the arrays will be billions of elements long.<br><br>int ilength(T)(T[] arr) {<br>    assert(arr.length <= int.max);<br>    return cast(int) arr.length;<br>}<br><br>Usage:<br><br>int[] indices;<br>auto array = returnsArray();<br>indices ~= array.ilength;<br><br>This cuts down on the excessive verbosity of an explicit cast that's safe 99.999 % of the time and encourages sprinkling it into code even if for the foreseeable future it will be compiled in 32-bit mode.<br><br>Two questions:<br><br>1.  Is everyone ok with me adding this as a convenience function to std.array?<br>2.  int or uint?  I
 used int only b/c that was the example on the newsgroup, but I think uint makes more sense.<br><br>--David Simcha<br>_______________________________________________<br>phobos mailing list<br><a ymailto="mailto:phobos@puremagic.com" href="mailto:phobos@puremagic.com">phobos@puremagic.com</a><br>http://lists.puremagic.com/mailman/listinfo/phobos<br><br><br></div></div></div><br>

      </body></html>