Hi everyone,
Slava told me today that with-datastack compiles, so I implemented a
feature that I've wanted for a while: the ability of code compiled
with the optimizing compiler to call arbitrary quotations. All you
have to do to make this infer is declare the stack effect of the
quotation that you're calling, at the call site. Using this, I made
lazy lists compile with the optimizing compiler, when they didn't
infer before. So, where persistent.deques used to implement its own
lists, and I was about to make my own lists for an algorithm in the
wrap vocabulary, I now use the existing list vocab. You could, for
example, implement a restricted version of case like this:
: case ( object alist -- )
at call( -- ) ;
And this compiles with the optimizing compiler! [ case ] infer => ((
object object -- )).
You can put an arbitrary stack effect in call( -- ), and it'll be
checked at runtime that the quotation actually takes and leaves the
right number of things. For example, call( x y z -- foo bar ) asserts
that the quotation takes three values and returns two. The
implementation of all this is totally trivial using with-datastack.
It's in the call vocabulary. (I'm not sure if that's the best name for
it.) This takes the place of assert-depth, as it's equivalent to call(
-- ). It also replaces most usages of with-datastack, if you were
using it with a fixed number of inputs and outputs. Enjoy!
Dan
------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk