(and don't hang when this happends!)\r
- >lower, >upper for strings\r
- telnetd should use multitasking\r
-- telnetd error handling\r
- accept multi-line input in listener\r
-- telnetd: send errors on socket\r
\r
+ docs:\r
\r
\r
+ misc:\r
\r
-- worddef>list ==> word-parameter\r
- alist -vs- assoc terminology\r
-- unique,\r
- dissolve builtins vocabulary\r
-- ifte* combinator\r
- 'cascading' styles\r
- jedit ==> jedit-word, jedit takes a file name\r
- some way to run httpd from command line\r
2drop
] ifte ; interpret-only
+: ifte* ( cond true false -- )
+ #! If the condition is not f, execute the 'true' quotation,
+ #! with the condition on the stack. Otherwise, pop the
+ #! condition and execute the 'false' quotation.
+ pick [ drop call ] [ nip nip call ] ifte ;
+ inline interpret-only
+
: interleave ( X list -- )
#! Evaluate each element of the list with X on top of the
#! stack. When done, X is popped off the stack.
#! Parse command line arguments.
parse-switches run-files ;
-: init-toplevel ( -- )
- [ "top-level-continuation" set ] callcc0 ;
-
: (word-of-the-day) ( -- word )
vocabs random-element words dup [
random-element
word-of-the-day
room.
- init-toplevel
-
- [
- interpreter-loop
- ] [
- [
- default-error-handler
- "top-level-continuation" get call
- ] when*
- ] catch ;
+ interpreter-loop ;
2dup = [
2drop f ! Don't say that a word uses itself
] [
- worddef>list tree-contains?
+ word-parameter tree-contains?
] ifte ;
: usages-in-vocab ( of vocab -- usages )
USE: arithmetic
USE: combinators
USE: continuations
+USE: errors
USE: kernel
USE: lists
USE: logic
: exit ( -- )
"quit-flag" on ;
+: eval-catch ( str -- )
+ [ eval ] [ default-error-handler ] catch ;
+
: interpret ( -- )
print-prompt read dup [
- dup history+ eval
+ dup history+ eval-catch
] [
drop exit
] ifte ;
#! Append an object to the currently constructing list.
"list-buffer" cons@ ;
+: unique, ( obj -- )
+ #! Append an object to the currently constructing list, only
+ #! if the object does not already occur in the list.
+ "list-buffer" unique@ ;
+
: list, ( list -- )
#! Append each element to the currently constructing list.
[ , ] each ;
: compiled>compound ( word -- def )
#! Convert a compiled word definition into the compound
#! definition which compiles to it.
- dup worddef>list <compound> ;
+ dup word-parameter <compound> ;
: decompile ( word -- )
#! Decompiles a word; from now on, it will be interpreted
: defined? ( obj -- ? )
dup word? [ worddef ] [ drop f ] ifte ;
-: worddef>list ( worddef -- list )
+: word-parameter ( worddef -- list )
worddef interpreter swap
[ "factor.FactorInterpreter" ] "factor.FactorWordDefinition"
"toList" jinvoke ;
dup [ dup car comment? [ cdr skip-docs ] when ] when ;
: compound>list ( worddef -- list )
- worddef>list dup [ skip-docs ] when ;
+ word-parameter dup [ skip-docs ] when ;
: define-compound ( word def -- )
#! Define a compound word at runtime.
! Various features not supported by native Factor.
: comment? drop f ;
-: worddef>list word-parameter ;
: word ( -- word )
global [ "last-word" get ] bind ;