Well, when you specify ``M: no-news``, you are telling the system to
dispatch off an instance of the ``no-news`` class.

So this works as you expect in your example:

    IN: scratchpad T{ no-news } new .
    T{ no-news f "same one" }

That's because ``no-news`` is a tuple-class:

    IN: scratchpad no-news tuple-class? .
    t

But not a ``no-news``:

    IN: scratchpad no-news no-news? .
    f

Why are you trying to override ``new``? Typically we just provide
constructor words, either automatically generating with ``C: <no-news>
no-news`` or using ``new`` or ``boa`` in a ``<no-news>`` word:

    : <no-news> ( field -- no-news )
        do-something-to-field no-news boa ;

Hope that helps,

John.


On Fri, Aug 19, 2016 at 12:49 PM, fede s <elfeder...@yahoo.com.ar> wrote:

> Hi
>
> I see "new" is a generic word, with the regular behavior set as a method
> for object.
> I tried specializing it on other tuple class, but it didn't work.
>
>    TUPLE: no-news field ;
>    : same-one ( -- t ) T{ no-news f "same one" } ;
>   M: no-news new  drop same-one ;
>
> I expect this:
>
>   no-news new
>   ==>T{ no-news f "same one" }
>
> But i got this:
>   no-news new
>   ==>T{ no-news f f }
>
>   USE: generic
>    \ new order
>   ==> { tuple-class no-news }
>
>   no-news \ new lookup-method
>   ==> M\ no-news new
>
> I think there's something wrong here?
>
> ------------------------------------------------------------
> ------------------
>
> _______________________________________________
> 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

Reply via email to