Re: [Factor-talk] Specializing new?
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`` or using ``new`` or ``boa`` in a word: : ( field -- no-news ) do-something-to-field no-news boa ; Hope that helps, John. On Fri, Aug 19, 2016 at 12:49 PM, fede swrote: > 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
[Factor-talk] Specializing new?
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
Re: [Factor-talk] database integration - foreign keys ?
Thank you. It works. Am Thu, 18 Aug 2016 08:54:46 -0700 schrieb John Benediktsson: > If you look through the tests in > ``basis/db/tuples/tuples-tests.factor`` you can see some uses of > foreign keys: > > https://github.com/factor/factor/blob/master/basis/db/tuples/tuples-tests.factor > > annotation-schema-foreign-key > annotation-schema-foreign-key-not-null > annotation-schema-cascade > annotation-schema-restrict > > The annotation tuple has a foreign key to the paste table through > ``paste-id`` with various use-cases tested. > > I'm not sure if we have any good documentation for it (couldn't find > in my cursory glance), sorry about that. > > Best, > John. > > > > > > On Thu, Aug 18, 2016 at 8:48 AM, Georg Simon > wrote: > > > Is there a database type for foreign keys ? > > Or how can I use foreign keys ? > > > > > > -- > > ___ > > 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