You can learn a lot by using ``optimized.`` from ``compiler.tree.debugger``.
You can see it does convert the literal ``2`` to a float and then use ``float+``: IN: scratchpad [ { float } declare 2 + 10 * ] optimized. [ 2.0 float+ 10.0 float* ] You can also look at the "typed" variation: TYPED: plus1 ( a: float -- b: float ) { float } declare 1 + ; IN: scratchpad \ plus1 optimized. [ >float ( typed plus1 ) ] The float coercion goes away if the compiler knows that a float is on the stack: IN: scratchpad [ { float } declare plus1 ] optimized. [ ( typed plus1 ) ] But, the way "typed" works, is it defines an outer word that converts / checks the inputs and then calls an inner word that assumes the inputs to be the types specified. You can right-click on ``( typed plus1 )`` and then push it to the stack and call ``optimized.`` on it, or you can declare it as inline (for the sake of introspection or otherwise): TYPED: plus1 ( a: float -- b: float ) { float } declare 1 + ; inline IN: scratchpad \ plus1 optimized. [ >float 1.0 float+ ] If the input is a float, the coercion goes away also here: IN: scratchpad [ { float } declare plus1 ] optimized. [ 1.0 float+ ] Hope that helps. Best, John. P.S., I think 32-bit libudis86.dll exists somewhere, and I know 32-bit libudis86 is supported on other OS's. On Thu, Nov 24, 2016 at 1:45 PM, Alexander Ilin <ajs...@yandex.ru> wrote: > Hello! > > In the docs of the `declare` word it says: > > The optimizer cannot do anything with the below code: > `2 + 10 *` > However, if we declare that the top of the stack is a float, then type > checks and generic dispatch are eliminated, and the compiler can use unsafe > intrinsics: > `{ float } declare 2 + 10 *` > > I wanted to ask: does declaring the types of parameters using the TYPED: > word have the same effect on the optimizer (with the difference, of course, > that it actually adds the type tests as necessary) or not? In other words, > do these two mechanisms play well together? Would it be beneficial or > completely superfluous to do this: > > TYPED: +1 ( a: float -- b: float ) > { float } declare 1 + ; > > PS: I'm asking here, because there still is no x86 variant of the > libudis86.dll at the Factor FTP, there is only the x64 version. > > ---=====--- > Александр > > ------------------------------------------------------------ > ------------------ > _______________________________________________ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk >
------------------------------------------------------------------------------
_______________________________________________ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk