I updated "re-factor" to work with the latest Factor which changes stack effect
declarations to be single parentheses.
If you want it to work with your version, change accessors.maybe from "( object
quot: ( -- x ) -- value )" to "(( object quot: ( -- x ) -- value ))".
Best,
John.
On Sunday, December 11, 2011 at 12:13 AM, CW Alston wrote:
> Greetings, Factorials -
> I've been working through mrjbq7's re-factor utilities, particularly a pet
> interest of mine, ternary search trees.
> Thrilled to see an implementation in Factor, but I can't get the code to
> compile. Here's the error I get with
> USE: ternary-search-trees in the listener:
> ----
> resource:work/ternary-search-trees/ternary-search-trees.factor
>
> 9: <<
> 12: >>
> ^
> The word define-maybe cannot be executed because it failed to compile
>
> The input quotations to “if” don't match their expected effects
> Input Expected
> Got
> [ ~quotation~ ~quotation~ make define-inline ] (( ..a -- ..b )) (( x x -- ))
> [ 2drop ] (( ..a --
> ..b )) (( x -- ))
>
> ----
>
> 'define-maybe' is in the required file, accessors.maybe -- I planted all code
> in the 'work' directory of factor.
> The untouched code there reads:
> -----
> USING: accessors arrays kernel make quotations sequences
> slots words ;
>
> IN: accessors.maybe
>
> : maybe-word ( name -- word )
> "maybe-" prepend "accessors" create ;
>
> : define-maybe ( name -- )
> dup maybe-word dup deferred? [
> [
> over setter-word \ drop 2array >quotation
> [ keep ] curry , \ compose ,
> swap reader-word [ dup ] swap 1quotation compose
> [ [ nip ] ] compose , \ dip , \ if* ,
> ] [ ] make ( object quot: ( -- x ) -- value ) define-inline
> ] [ 2drop ] if ;
>
> : define-maybe-accessors ( class -- )
> "slots" word-prop [
> dup read-only>> [ drop ] [ name>> define-maybe ] if
> ] each ;
>
> -----
>
> I just can't untangle the stack effects in 'define-maybe' to see where the
> stack is disrupted. Any insights from folks
> better initiated? Note that:
> ---
> 9: <<
> 12: >>
> ^
> ---
>
> in the error output (lines 9-12) points to:
> ---
> <<
> TUPLE: tree-node ch value exists lt eq gt ;
> tree-node define-maybe-accessors
> >>
>
> ---
> in file 'ternary-search-trees.factor' .
>
> Thanks, all, and keep up the good work,
> CW Alston
> --
> ~ Memento Amori
> ------------------------------------------------------------------------------
> Learn Windows Azure Live! Tuesday, Dec 13, 2011
> Microsoft is holding a special Learn Windows Azure training event for
> developers. It will provide a great way to learn Windows Azure and what it
> provides. You can attend the event by watching it streamed LIVE online.
> Learn more at http://p.sf.net/sfu/ms-windowsazure
>
> _______________________________________________
> Factor-talk mailing list
> [email protected] (mailto:[email protected])
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>
------------------------------------------------------------------------------
Learn Windows Azure Live! Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for
developers. It will provide a great way to learn Windows Azure and what it
provides. You can attend the event by watching it streamed LIVE online.
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk