Hi Pinku,

Factor has pretty advanced capabilities for dealing with word lookup.
The default image has about a thousand vocabularies with 22 thousand
words total, and if you load everything from basis and extra there's
even more, so we've evolved some nice features for dealing with this
complexity in a controlled manner.

On Fri, Oct 9, 2009 at 11:03 AM, Pinku Surana <[email protected]> wrote:
> In an attempt to learn Factor, I'm using it as a query language for
> memcached. A client can send a Factor script to a memcached server to
> execute complex operations locally, thus avoiding expensive remote calls.
> However, I've got a few questions. Forgive me if I get the terminology
> wrong.
> 1) How do I control the visibility of words in a vocabulary? I want some
> words to be public and the rest to be private.

Wrap the private words in <PRIVATE ... PRIVATE>.

> 2) I use just a few words from lots of vocabularies. Is there a way to make
> a direct reference to a word without polluting my namespace with everything
> from that vocabulary? For example, "io.encodings.ascii.ascii" to refer to
> the word ascii.

FROM: io.encodings.ascii => ascii ;

> 3) I'd like to use the words "get" and "set" to operate on memcached, but it
> collides with the same words in the namespaces vocabulary. Is there a
> general way to deal with these inevitable name collisions?

Suppose both namespaces and memcached define a word named 'get'. So you do

USING: namespaces memcached ;

blahblah get

But this fails to load! It will say "More than one vocabulary defines
a word named 'get'". At this point, you need to edit your source file
to disambiguate the word usage. Either using FROM: to pick the one you
want,

USING: namespaces memcached ;
FROM: memcached => get set ;

If you do this, any reference to 'get' or 'set' in the source file
will refer to the words in the memcached vocabulary.

You can also use qualified naming. Eg, if you mostly use words from
memcached but need to call things from namespaces too,

USING: memcached ;
QUALIFIED-WITH: namespaces n

blahblah get
blahblah n:get

Note that the relative order of vocabularies in a USING: list doesn't
matter. If there is a word clash, neither one takes precedence, you
have to resolve the ambiguity with FROM: or qualification. This is a
good thing, for various reasons.

More details are in the documentation:

http://docs.factorcode.org/content/article-word-search.html

Slava

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to