> Message: 1 > Date: Thu, 30 Apr 2009 16:02:03 -0500 > From: Doug Coleman <[email protected]> > Subject: Re: [Factor-talk] question about <=> > To: [email protected] > Message-ID: <[email protected]> > Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes > > Factor used to return -1, 0, and 1 but it's higher-level to return > symbols than magic numbers. There's an 'invert-comparison' word to > invert the +lt+ and +gt+ symbols. > I can appreciate the idea of not using magic numbers, although the [-1,0,1] set is a convention in Forth. Daniel Ehrenberg made a good point yesterday that arithmetic with +lt+ etc. will get caught as an error.
> Your code is calling quotations with arbitrary stack effects so it > should be inlined. Words that call this combinator can be compiled, > but the combinator itself doesn't compile and no error is thrown by > the compiler because this is a Factor idiom used everywhere. > I'll keep this in mind regarding inlines. I assume that inlines are also faster, but bulkier? > There's a word in the system vocabulary called 'exit' that quits > Factor and returns an integer to the shell. I'm not entirely sure if > this is Forth's EXIT or not. > No; in ANS-Forth (and Forth-83, etc.) the EXIT is used for exiting out of a function. This is typically done to clean up messy control structures. For example, when searching for something in a loop, when you find it you EXIT right then and there; the loop only completes if you don't find what you're looking for. This is both cleaner and more efficient than setting a flag inside of the loop and then checking that flag after the loop completes. With BEGIN-WHILE loops, this is straightforward. With DO loops, you have to do an UNLOOP prior to your EXIT to get the DO parameters off the return stack and re-expose the return address. ------------------------------------------------------------------------------ Register Now & Save for Velocity, the Web Performance & Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance & Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf _______________________________________________ Factor-talk mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/factor-talk
