Not sure, I opened an issue about it to look at when someone has time...

On Wed, Oct 30, 2013 at 3:24 PM, OwnWaterloo <[email protected]> wrote:

> I'm new to Factor and don't know how to minimize the code while get
> the similar behaviour. Sorry for that.
> But thanks to the expressiveness and good libraries of Factor the code
> won't be too long, I hope...
>
> Firstly, the primary goal is to normalize some unicode string.
> Formating the result will make it more clear. And I also want to learn
> the "Fried quotations".
> So I use the three vocabularies:
>
>   IN: scratchpad USING: unicode.normalize formatting fry ;
>   Loading resource:basis/formatting/formatting.factor
>   Loading resource:basis/formatting/formatting-docs.factor
>
> Then the implement it with correct stack effect declaration in "execute(" :
>
>   IN: scratchpad : normalizations ( str -- norm )
>    '[ _ swap execute( x -- x ) ] ! correct stack effect declaration
>    { nfc nfd nfkc nfkd } swap map ! normalize str with four methods
>    [ >array [ "U+%04X" sprintf ] map ] map ; ! make it more clear
>
> It gives me the expected results except the last two(but it maybe not
> important to this question):
>
>   IN: scratchpad "Factor" normalizations .
>   {
>       { "U+0046" "U+0061" "U+0063" "U+0074" "U+006F" "U+0072" }
>       { "U+0046" "U+0061" "U+0063" "U+0074" "U+006F" "U+0072" }
>       { "U+0046" "U+0061" "U+0063" "U+0074" "U+006F" "U+0072" }
>       { "U+0046" "U+0061" "U+0063" "U+0074" "U+006F" "U+0072" }
>   }
>   IN: scratchpad "\xF1" normalizations .
>   {
>       { "U+00F1" }
>       { "U+006E" "U+0303" }
>       { "U+00F1" }
>       { "U+006E" "U+0303" }
>   }
>   IN: scratchpad "\x6E\u000303" normalizations .
>   {
>       { "U+00F1" }
>       { "U+006E" "U+0303" }
>       { "U+00F1" }
>       { "U+006E" "U+0303" }
>   }
>   IN: scratchpad "\u01D160" normalizations .
>   {
>       { "U+1D158" "U+1D165" "U+1D16E" }
>       { "U+1D158" "U+1D165" "U+1D16E" }
>       { "U+1D158" "U+1D165" "U+1D16E" }
>       { "U+1D158" "U+1D165" "U+1D16E" }
>   }
>   IN: scratchpad "\u01D158\u01D165\u01D16E" normalizations .
>   {
>       { "U+1D158" "U+1D165" "U+1D16E" }
>       { "U+1D158" "U+1D165" "U+1D16E" }
>       { "U+1D158" "U+1D165" "U+1D16E" }
>       { "U+1D158" "U+1D165" "U+1D16E" }
>   }
>
> But with the wrong stack effect declaration(actually I use the wrong
> declaration first and the correct one latter during the study):
>
>   IN: scratchpad : normalizations ( str -- norm )
>    '[ _ swap execute( -- ) ] ! wrong stack effect declaration
>    { nfc nfd nfkc nfkd } swap map
>    [ >array [ "U+%04X" sprintf ] map ] map ;
>
> The first case will pass:
>
>   IN: scratchpad "Factor" normalizations .
>   {
>       { "U+0046" "U+0061" "U+0063" "U+0074" "U+006F" "U+0072" }
>       { "U+0046" "U+0061" "U+0063" "U+0074" "U+006F" "U+0072" }
>       { "U+0046" "U+0061" "U+0063" "U+0074" "U+006F" "U+0072" }
>       { "U+0046" "U+0061" "U+0063" "U+0074" "U+006F" "U+0072" }
>   }
>
> And the rest will get an error:
>
>   IN: scratchpad "\xF1" normalizations .
>   Quotation's stack effect does not match call site
>   quot      [ \ nfc execute ]
>   call-site ( -- )
>
>   Type :help for debugging help.
>
> The same thing will happen in "\x6E\u000303" "\u01D160"
> "\u01D158\u01D165\u01D16E".
>
> I promise that I will not depend on this behaviour and will use the
> correct stack effect declaration in real code.
> I'm just curious that why "execute(" will check it in some cases but
> won't in others?
>
> Thanks!
>
>
> ------------------------------------------------------------------------------
> Android is increasing in popularity, but the open development platform that
> developers love is also attractive to malware creators. Download this white
> paper to learn more about secure code signing practices that can help keep
> Android apps secure.
> http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
> _______________________________________________
> Factor-talk mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to