Hi all, In the next few days I'm going to merge some changes which eliminate the overloading of integers as sequences. The rationale for this change is that having integers be sequences is too error-prone. For instance, if you accidentally write '{ 1 2 } 10000 append' instead of '{ 1 2 } 10000 suffix' you'll end up creating an array with 10002 elements. It is easy to see how simple typos can lead to out of memory errors, hangs, etc. This change will potentially require a lot of code to be updated (I've spent most of the day updating core/ basis/ and extra/ and I'm not done yet). However it is the first incompatible change of such magnitude in quite some time, and there won't be any others in the near future after this, giving users time to settle down.
So to be precise, code such as the following will now be an error: 10 [ ... ] each You should use iota now, which creates a new virtual sequence: 10 iota [ ... ] each Note that 'iota' is already in Factor as of a few months ago, so you can start updating code at any time. If you want you can also use the integer-specific iteration combinators in the math vocabulary (each-integer, all-integers?, etc). These are also already present in the library, and have been for quite some time. Note that thanks to the compiler's SCCP and escape analysis optimizations, 'iota [ ... ] each' and '[ ... ] each-integer' compile down to the exact same code, so don't pick one or the other based on performance considerations. Most code should probably prefer to use 'each'; 'each-integer' only exists to implement 'each', after all. The 'replicate' combinator which used to take a sequence (including an integer) will now take integers only. That is, this will no longer work: "hello" [ 5 ] { } replicate-as . => { 5 5 5 5 5 } Now you'll have to write something like "hello" length [ 5 ] { } replicate-as . => { 5 5 5 5 5 } This is because replicate is most often used with a length, not a sequence of elements -- using it with a real sequence is not very useful since it discards elements prior to calling the quotation. As an aside, while updating library code I've noticed a few places this idiom was used: dup length [ ... ] 2each dup length [ ... ] 2map This no longer works, but for a while now we've had replacement combinators which call the quotation, passing it an element together with an index: [ ... ] each-index [ ... ] map-index I'll post another message when the changes are merged. To clarify, I haven't pushed anything yet, and in the latest binaries and GIT sources, integers still supports sequence operations. Not for long, though. Slava ------------------------------------------------------------------------------ Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev _______________________________________________ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk