Re: [stack] New release of Factor
stevan apter — 2004-05-27 23:54:31
> People seem to like screenshots
this people does - nice!
i see that you've implemented the concept of an object path. i
take that to be a list of names which can be used to retrieve a
value from a namespace. are namespaces first-class? what's the
value of partial path? &c.
i hope you bring the documentation up to speed.
----- Original Message -----
From: "Slava Pestov" <slava@...>
To: <concatenative@yahoogroups.com>
Sent: Thursday, May 27, 2004 3:52 PM
Subject: [stack] New release of Factor
> Hi everybody,
>
> There is a new release of Factor. For now its hosted at
> http://www.jedit.org/factor/, but soon it will move.
>
> Since the last release, there were a large number of bug fixes,
> optimizations, cleanups, and so on. The big new language feature is
> multiple vocabularies, for incrased code modularity and freedom in
> naming words without fear of clashes.
>
> There is one new addition to the very small set of available documentation:
>
> http://www.jedit.org/factor/intro.txt
>
> The compiler is disabled by default right now -- this will change in the
> next release. In the meantime, enter this as soon as the interpreter has
> started, for improved performance:
>
> compile-all
>
> The interpreter takes a while to load -- especially if the time to
> compile the library is taken into account. To solve this, I'm working on
> a "workspace" feature. Its basically a persistent store. Its in the very
> early stages right now and disabled by default. The idea is instead of
> re-parsing and re-compiling the entire Factor library on startup --
> which takes time -- one dumps a "workspace". What makes this interesting
> is that global variables and word definitions entered a the interactive
> interpreter are automatically saved. Most of the code is done, it just
> needs debugging and testing. Expect it to be more or less functional in
> the next release.
>
> Slava
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
stevan apter — 2004-05-28 00:04:15
question: in
http://www.jedit.org/factor/intro.txt you describe how
the programmer needs to trick his way around the forward-reference
problem (the "tree-contains" example): if g calls f and f calls g, then
the programmer must supply a dummy definition of f, then define g, then
redefine f. so my question is: why doesn't the interpreter automatically
do that when it encounters an undefined symbol? that is, enter the symbol
in the symbol table, give it a null value, and then proceed.
----- Original Message -----
From: "Slava Pestov" <slava@...>
To: <concatenative@yahoogroups.com>
Sent: Thursday, May 27, 2004 3:52 PM
Subject: [stack] New release of Factor
> Hi everybody,
>
> There is a new release of Factor. For now its hosted at
> http://www.jedit.org/factor/, but soon it will move.
>
> Since the last release, there were a large number of bug fixes,
> optimizations, cleanups, and so on. The big new language feature is
> multiple vocabularies, for incrased code modularity and freedom in
> naming words without fear of clashes.
>
> There is one new addition to the very small set of available documentation:
>
> http://www.jedit.org/factor/intro.txt
>
> The compiler is disabled by default right now -- this will change in the
> next release. In the meantime, enter this as soon as the interpreter has
> started, for improved performance:
>
> compile-all
>
> The interpreter takes a while to load -- especially if the time to
> compile the library is taken into account. To solve this, I'm working on
> a "workspace" feature. Its basically a persistent store. Its in the very
> early stages right now and disabled by default. The idea is instead of
> re-parsing and re-compiling the entire Factor library on startup --
> which takes time -- one dumps a "workspace". What makes this interesting
> is that global variables and word definitions entered a the interactive
> interpreter are automatically saved. Most of the code is done, it just
> needs debugging and testing. Expect it to be more or less functional in
> the next release.
>
> Slava
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
Slava Pestov — 2004-05-28 00:39:25
stevan apter wrote:
>this people does - nice!
>
>i see that you've implemented the concept of an object path. i
>take that to be a list of names which can be used to retrieve a
>value from a namespace. are namespaces first-class? what's the
>value of partial path? &c.
>
>
A namespace is not a hierarchy; it is a flat structure, mapping names to
values. Hierarchies are achieved by nesting namespaces; so really
there's no such thing as a "partial" path.
To clarify, object paths work by drilling down nested namespaces.
The object path [ ] corresponds to the global namespace.
The object path [ "vocabularies" ] is the namespace of vocabularies.
The object path [ "vocabularies" "builtins" ] is the builtin vocabulary.
The object path [ "vocabularies" "builtins" "ifte" ] is the word 'ifte'
from the builtins vocabulary.
Etc...
Object paths are only used for one thing so far; the hyperlinked
browsing of namespaces and code in the listener and HTTP server (latter
is broken right now). Each hyperlink's target is an object path.
I'm not sure what you mean by namespaces being first class; they're
objects like any other that you can pass around, and there are a number
of words for working with them. I think this means they're first class, no?
>i hope you bring the documentation up to speed.
>
>
I'm working on an online help system written in Factor itself. It will
be something Wiki-like. The main reason I haven't written much
documentation yet is I didn't want to switch formats half way through.
>question: in http://www.jedit.org/factor/intro.txt you describe how
>the programmer needs to trick his way around the forward-reference
>problem (the "tree-contains" example): if g calls f and f calls g, then
>the programmer must supply a dummy definition of f, then define g, then
>redefine f. so my question is: why doesn't the interpreter automatically
>do that when it encounters an undefined symbol? that is, enter the symbol
>in the symbol table, give it a null value, and then proceed.
>
It used to work this way back when there was only one symbol table. But
now, there is no longer such a thing as "the" symbol table.
Consider this hypothetical source file:
IN: vocab1
USE: vocab2
: some-word another-word ;
IN: vocab2
: another-word ;
If the interpreter did what you propose, it would enter a dummy
definition for 'another-word' *in the vocab1 vocabulary* while reading
the definition of "some-word". This is almost certainly not what the
developer wants; its better to signal an error than silently do the
wrong thing.
BTW, I'm sure there are people averse to trying Factor because it
depends on Sun's proprietary JRE. However, I am currently working on
getting it running with GCJ (sans GUI).
Slava
Slava Pestov — 2004-05-28 00:44:30
By the way, speaking of documentation, what kind of material would you
find most useful?
stevan apter — 2004-05-28 01:01:29
----- Original Message -----
From: "Slava Pestov" <slava@...>
To: <concatenative@yahoogroups.com>
Sent: Thursday, May 27, 2004 8:39 PM
Subject: Re: [stack] New release of Factor
> stevan apter wrote:
>
> >this people does - nice!
> >
> >i see that you've implemented the concept of an object path. i
> >take that to be a list of names which can be used to retrieve a
> >value from a namespace. are namespaces first-class? what's the
> >value of partial path? &c.
> >
> >
> A namespace is not a hierarchy; it is a flat structure, mapping names to
> values. Hierarchies are achieved by nesting namespaces; so really
> there's no such thing as a "partial" path.
>
> To clarify, object paths work by drilling down nested namespaces.
> The object path [ ] corresponds to the global namespace.
> The object path [ "vocabularies" ] is the namespace of vocabularies.
> The object path [ "vocabularies" "builtins" ] is the builtin vocabulary.
> The object path [ "vocabularies" "builtins" "ifte" ] is the word 'ifte'
> from the builtins vocabulary.
> Etc...
>
> Object paths are only used for one thing so far; the hyperlinked
> browsing of namespaces and code in the listener and HTTP server (latter
> is broken right now). Each hyperlink's target is an object path.
>
> I'm not sure what you mean by namespaces being first class; they're
> objects like any other that you can pass around, and there are a number
> of words for working with them. I think this means they're first class, no?
yes.
i see - and in fact you've answered my question with your example.
>
> >i hope you bring the documentation up to speed.
> >
> >
> I'm working on an online help system written in Factor itself. It will
> be something Wiki-like. The main reason I haven't written much
> documentation yet is I didn't want to switch formats half way through.
>
> >question: in http://www.jedit.org/factor/intro.txt you describe how
> >the programmer needs to trick his way around the forward-reference
> >problem (the "tree-contains" example): if g calls f and f calls g, then
> >the programmer must supply a dummy definition of f, then define g, then
> >redefine f. so my question is: why doesn't the interpreter automatically
> >do that when it encounters an undefined symbol? that is, enter the symbol
> >in the symbol table, give it a null value, and then proceed.
> >
> It used to work this way back when there was only one symbol table. But
> now, there is no longer such a thing as "the" symbol table.
>
> Consider this hypothetical source file:
>
> IN: vocab1
> USE: vocab2
>
> : some-word another-word ;
>
> IN: vocab2
>
> : another-word ;
>
> If the interpreter did what you propose, it would enter a dummy
> definition for 'another-word' *in the vocab1 vocabulary* while reading
> the definition of "some-word". This is almost certainly not what the
> developer wants; its better to signal an error than silently do the
> wrong thing.
i'll take your word for it, since i don't understand the scoping
rules for IN/USE. it just feels awkward.
>
> BTW, I'm sure there are people averse to trying Factor because it
> depends on Sun's proprietary JRE. However, I am currently working on
> getting it running with GCJ (sans GUI).
i don't think that should inhibit the curious.
a thought: it might be useful if you were to take one or two of
manfred's libraries and rewrite them in factor. at least, that's
been my approach with cK - the joy solution provides a reference
point.
>
> Slava
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
stevan apter — 2004-05-28 01:04:01
again, i suggest that you emulate manfred's work with joy: a reference
card, a tutorial, a set of libraries (code is documentation, right?).
speaking for myself (obviously), i detest hyperlinked help-systems
almost as much as talks designed around powerpoint slides.
----- Original Message -----
From: "Slava Pestov" <slava@...>
To: <concatenative@yahoogroups.com>
Sent: Thursday, May 27, 2004 8:44 PM
Subject: Re: [stack] New release of Factor
> By the way, speaking of documentation, what kind of material would you
> find most useful?
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
Chris Double — 2004-05-28 02:00:12
On Thu, 27 May 2004 20:39:25 -0400, "Slava Pestov" <
slava@...>
said:
> BTW, I'm sure there are people averse to trying Factor because it
> depends on Sun's proprietary JRE. However, I am currently working on
> getting it running with GCJ (sans GUI).
The 'console' version of Factor seems to run fine under IKVM, which is a
JVM that runs inside .NET (and mono). It is open source and free. So in
Linux you can run it with:
mono ikvm.exe -cp Factor.jar factor.FactorInterpreter
IKVM:
http://weblog.ikvm.net/
Mono:
http://www.go-mono.com/
Chris.
--
http://radio.weblogs.com/0102385
--
Chris Double
chris.double@...
Slava Pestov — 2004-05-28 03:29:27
stevan apter wrote:
> i'll take your word for it, since i don't understand the scoping
> rules for IN/USE. it just feels awkward.
Hmm... there aren't any scoping words really.
USE: is just like the *nix $PATH. When you type 'ls', it is searched for
in /usr/bin, then /bin, then /sbin, etc...
Similarly, when the parser encounters a token such as 'callcc0', it
searches the USE: vocabulary list in order for a definition of 'callcc0'.
Each occurrence of USE: in a source file adds the following vocabulary
name to the beginning of the list. Generally the order doesn't matter
though.
There is only one IN: vocabulary; subsequent IN: statements simply set
it to a new value. The IN: vocabulary is only used when defining words.
I hope it makes more sense now. It is basically a simpler implementation
of what FORTH calls wordlists.
Take a look at some of the *.factor files in Factor.jar (.jar files are
actually just zipped) to see how its used.
> a thought: it might be useful if you were to take one or two of
> manfred's libraries and rewrite them in factor. at least, that's
> been my approach with cK - the joy solution provides a reference
> point.
I've written a lot of code in Factor already, including:
- some very elegant list manipulation routines -- reversing, appending,
sorting, etc. See lists.factor.
- a number of combinators -- not as extensive as Manfred's set, but
unlike Joy, my combinators are implemented in the language itself.
- an http server -- this is broken right now and undocumented, but has
potential.
- an irc bot -- quite basic but easy to hack. see irc.factor
Slava
stevan apter — 2004-05-29 19:08:51
hi slava
here's a problem i'd like to see a solution for in factor. i've
seen it posed for languages which support coroutines. it's a two-
parter.
1. write a function pt which takes a tree (a nested list) and prints
the contents with appropriate indentation. for example, given
[1[2 3[[4 5 6][7 8]]9]] pt
1
2
3
4 5 6
7 8
9
2. define a combinator t2 which takes the function pt and a pair of
isomorphic trees and interleaves the printing:
[1[2 3[[4 5 6][7 8]]9]] [10[20 30[[40 50 60][70 80]]90]] [pt] t2
1
10
2
20
3
30
4 5 6
40 50 60
7 8
70 80
9
90
thanks!
sa
----- Original Message -----
From: "Slava Pestov" <slava@...>
To: <concatenative@yahoogroups.com>
Sent: Thursday, May 27, 2004 11:20 PM
Subject: Re: [stack] New release of Factor
> Hi,
>
> First of all, thanks for the questions and interest! I never thought
> anybody would care about this.
>
> Yes, Factor's continuations are modelled after Scheme. Two words are
> used to capture continuations:
>
> callcc0
> callcc1
>
> Both have stack effect ( quotation -- ). They capture a continuation
> right after the callcc call, push it on the stack, and call the
> quotation. The quotation is then supposed to store the continuation
> somewhere.
>
> The capture continuation is in fact a quotation as well, so you can call
> it with the 'call' primitive to restore execution.
>
> The difference between callcc0 and callcc1 is the nature of the captured
> continuation.
>
> callcc0 simply restores execution to the point of continuation capture.
> callcc1 restores execution and 'transfers' one parameter from the
> current data stack to the restored data stack.
>
> So callcc0 is like task switching, and callcc1 is like co-routines.
>
> A non-trivial example can be found in the listener implementation (the
> listener is the GUI interpreter). Continuations are used here because
> GUI is event-driven ("push"), while the top-level interpreter is "pull".
> I could just have written a new top-level interpreter with a "push"
> model, but reusing the exact same code is much nicer.
>
> When the top-level interpreter loop decides to read a line of input, it
> calls a number of words which eventually delegate to the listener-readln
> word.
>
> The two key words in the listener implementation are:
>
> : listener-readln* ( continuation -- line )
> "listener" get
> [ "factor.Cons" ]
> "factor.listener.FactorListener"
> "readLine" jinvoke ;
>
> : listener-readln ( -- line )
> reset-attrs [ listener-readln* suspend ] callcc1 ;
>
> There is a lot of low level noise in these definitions, but they key
> idea is that listener-readln captures the current continuation and calls
> listener-readln*, which passes it to the GUI code, which is really a
> thin layer over the Swing text pane. The GUI code is event-driven; so it
> simply stores the continuation in an instance variable.
>
> The "suspend" word clears all three stacks, effectively aborting the
> interpreter.
>
> Then later on when the ENTER event is received, the GUI pushes the input
> line on the stack and calls the continuation. Since the continuation was
> captured using callcc1, execution resumes at listener-readln, with the
> new line of text on the restored stack. The top level interpreter
> continues execution, completely unaware of what took place.
>
> The game I'm working on uses continuations extensively for various
> in-game events llike character interactions, waiting for user input, and
> even as a multitasking engine in the implementation of big explosions,
> that consist of multiple consecutive blasts.
>
> Note that continuations cannot be compiled, and probably never will be,
> due to limitations in the JVM. So they're not really suitable for use in
> tight loops and such.
>
> Chris Double wrote:
>
> >You mention on the Factor website that the language supports
> >continuations. Are there examples of usage? Are these continuations in
> >the Scheme call/cc sense?
> >
> >Chris.
> >
> >
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>