]> gitweb.factorcode.org Git - factor.git/commitdiff
Modules now support definition protocol
authorslava <slava@factorcode.org>
Sat, 11 Nov 2006 03:49:03 +0000 (03:49 +0000)
committerslava <slava@factorcode.org>
Sat, 11 Nov 2006 03:49:03 +0000 (03:49 +0000)
TODO.FACTOR.txt
doc/handbook/cookbook.facts
library/help/topics.factor
library/modules.factor
library/modules.facts
library/syntax/parse-syntax.factor
library/tools/definitions.factor
library/ui/tools/operations.factor

index f8d4537243c3aa38cb74cc85b7b76557cc2732cc..2f38aa4a391b46f7d8ab08f2ea55635368d1b3f8 100644 (file)
@@ -1,18 +1,12 @@
-- sometimes fep when closing window
-- windows rollover broken again
-- compile error after reloading library/math/float.factor
-- move window while factor is busy: mouse gets messed up!
++ 0.87:
 
-+ ui:
-
-- docs: don't pass volatile aliens to callbacks
+- cocoa: move window while factor is busy: mouse gets messed up!
 - live search: timer delay would be nice
 - menu should stay up if mouse button released
 - roundoff is still not quite right with tracks
 - grid displays quickly now, but constructing large amounts of gadgets
   is slow: eg, 10000 [ dup number>string ] map describe
 - completion is not ideal: eg, C+e "buttons"
-- some way of intercepting all gestures
 - slider needs to be modelized
 - better help result ranking
 - help search looks funny
 - graphical crossref tool
 - ui browser: show currently selected vocab & words
 - auto-update browser and help when sources reload
+- amd64 structs-by-value bug
+- intrinsic fixnum>float float>fixnum
+- mac intel: struct returns from objc methods
+- faster apropos
+- infer which variables are read, written in a quotation
+- compiled call traces
+- if listener is busy open a new listener when doing listener operations
+
++ ui:
+
+- some way of intercepting all gestures
 - how do we refer to command shortcuts in the docs?
 - fix top level window positioning
 - editor:
@@ -32,7 +37,6 @@
 
 + module system:
 
-- modules should support definition protocol
 - track a list of assets loaded from each module's file
 - C types should be words
   - TYPEDEF: float { ... } { ... } ;   ==> \ float T{ c-type ... } "c-type" swp
@@ -46,8 +50,6 @@
 - %allot-bignum-signed-2 is broken on both platforms
 - cross-word type inference
 - callback scheduling issue
-- amd64 structs-by-value bug
-- intrinsic fixnum>float float>fixnum
 - we may be able to remove the dlsym primitive
 - [ [ dup call ] dup call ] infer hangs
 - stdcall callbacks
   recursive
 - ppc64 backend
 - arm backend
-- mac intel: struct returns from objc methods
 - float= doesn't consider nans equal
 - C functions returning structs by value
-- infer which variables are read, written in a quotation
 - compiled continuations
-- compiled call traces
 
 + prettyprinter:
 
 
 + misc:
 
-- faster apropos
 - growable data heap
 - minor GC takes too long now, we should card mark code heap
 - buffer-ptr should be an alien
 - swap nappend ==> nappend
-- gdb triggers 'mutliple i/o ops on port' error
+- gdb triggers 'multiple i/o ops on port' error
 - incremental GC
 - UDP
 - slice: if sequence or seq start is changed, abstraction violation
index ba511e2e2f5637c3ab21acd6f8177ebc7522878f..99fc9ca4b0b8528f9fdc3168a1267d13fc6dce4a 100644 (file)
@@ -212,8 +212,6 @@ ARTICLE: "cookbook-io" "I/O cookbook"
 ARTICLE: "cookbook-philosophy" "Factor philosophy"
 "Factor is a high-level language with automatic memory management, runtime type checking, and strong typing. Factor code should be as simple as possible, but not simpler. If you are coming to Factor from another programming language, one of your first observations might me related to the amount of code you " { $emphasis "don't" } " have to write."
 $terpri
-"One of Factor's goals is to implement as much of itself as possible in Factor, including the compiler and as much as possible of the runtime. One consequence is that Factor does not prevent you from shooting yourself in the foot; if you need to, you can drop down and manually allocate memory, perform pointer arithmetic, write inline assembly code, and do much worse. Usually there is no reason to, but the need can arise, for example when interfacing with C libraries."
-$terpri
 "If you try to write Factor word definitions which are longer than a couple of lines, you will find it hard to keep track of the stack contents. Well-written Factor code is " { $emphasis "factored" } " into short definitions, where each definition is easy to test interactively, and has a clear purpose. Well-chosen word names are critical, and having a thesaurus on hand really helps."
 $terpri
 "If you run into problems with stack shuffling, take a deep breath and a step back, and reconsider the problem. A much simpler solution is waiting right around the corner, a natural solution which requires far less stack shuffling and far less code. As a last resort, if no simple solution exists, consider defining a domain-specific language."
@@ -222,4 +220,8 @@ $terpri
 $terpri
 "In addition to writing short definitions and testing them interactively, a great habit to get into is writing unit tests. Factor provides good support for unit testing; see " { $link "testing-modules" } "."
 $terpri
-"The Factor core consists of the development environment together with a minimal library to host it. Additional functionality which other languages integrate is often a separate module in Factor; see " { $link "modules" } "." ;
+"The Factor core consists of the development environment together with a minimal library to host it. Additional functionality which other languages integrate is often a separate module in Factor; see " { $link "modules" } "."
+$terpri
+"Factor tries to implement as much of itself as possible, because this improves simplicity and performance. One consequence is that Factor gives you the option of using low-level features not usually associated with high-level languages, such manual memory management, pointer arithmetic, and inline assembly code."
+$terpri
+"Unsafe features are tucked away so that you will not invoke them by accident, or have to use them to solve conventional programming problems. However when the need arises, unsafe features are invaluable, for example you might have to do some pointer arithmetic when interfacing directly with C libraries." ;
index c78968b5fdd6ec639093edfda4583293c3603799..5691ee28daf354544d867db67c5cd65ebefdf4a4 100644 (file)
@@ -97,5 +97,3 @@ M: word-link synopsis*
 
 M: word-link definition
     link-name "help" word-prop t ;
-
-M: word-link see (see) ;
index c2b5454c9ba207b4652f34c83c186f3f40cf1dd4..a11db9952fb76ee92a7fb3ede4a99e3c00632632 100644 (file)
@@ -2,11 +2,12 @@
 ! See http://factorcode.org/license.txt for BSD license.
 IN: modules
 USING: hashtables io kernel namespaces parser sequences
-test words strings arrays math help ;
+test words strings arrays math help prettyprint-internals
+definitions ;
 
 SYMBOL: modules
 
-TUPLE: module name files tests main help ;
+TUPLE: module name loc files tests help main ;
 
 : module-def ( name -- path )
     "resource:" over ".factor" append3
@@ -16,15 +17,6 @@ TUPLE: module name files tests main help ;
         drop "resource:" swap "/load.factor" append3
     ] if ;
 
-: prefix-paths ( name seq -- newseq )
-    [ path+ "resource:" swap append ] map-with ;
-
-C: module ( name files tests help -- module )
-    [ set-module-help ] keep
-    [ >r >r over r> prefix-paths r> set-module-tests ] keep
-    [ >r dupd prefix-paths r> set-module-files ] keep
-    [ set-module-name ] keep ;
-
 M: module <=> [ module-name ] 2apply <=> ;
 
 : module modules get [ module-name = ] find-with nip ;
@@ -38,27 +30,43 @@ M: module <=> [ module-name ] 2apply <=> ;
 : require ( name -- )
     dup module [ drop ] [ load-module ] if do-parse-hook ;
 
-: process-files ( seq -- newseq )
+: process-files ( name seq -- newseq )
     [ dup string? [ [ t ] 2array ] when ] map
     [ second call ] subset
-    0 <column> >array ;
+    0 <column> >array
+    [ path+ "resource:" swap append ] map-with ;
+
+: module-files* ( module -- seq )
+    dup module-name swap module-files process-files ;
+
+: module-tests* ( module -- seq )
+    dup module-name swap module-tests process-files ;
 
 : remove-module ( name -- )
     module [ modules get delete ] when* ;
 
-: provide ( name hash -- )
-    over remove-module [
-        +files+ get process-files
-        +tests+ get process-files
-        +help+ get
-    ] bind <module>
-    [ module-files run-files ] keep
+: alist>module ( name loc hash -- module )
+    alist>hash [
+        +files+ get +tests+ get +help+ get
+    ] bind f <module> ;
+
+: module>alist ( module -- hash )
+    [
+        +files+ over module-files 2array ,
+        +tests+ over module-tests 2array ,
+        +help+ swap module-help 2array ,
+    ] { } make ;
+
+: provide ( name loc hash -- )
+    pick remove-module
+    alist>module
+    [ module-files* run-files ] keep
     modules get push ;
 
-: test-module ( name -- ) module module-tests run-tests ;
+: test-module ( name -- ) module module-tests* run-tests ;
 
 : test-modules ( -- )
-    modules get [ module-tests ] map concat run-tests ;
+    modules get [ module-tests* ] map concat run-tests ;
 
 : modules. ( -- )
     modules get natural-sort
@@ -68,7 +76,7 @@ M: module <=> [ module-name ] 2apply <=> ;
     dup module-name module-def source-modified? [
         module-name load-module
     ] [
-        module-files [ source-modified? ] subset run-files
+        module-files* [ source-modified? ] subset run-files
     ] if ;
 
 : reload-modules ( -- )
@@ -87,3 +95,9 @@ M: module <=> [ module-name ] 2apply <=> ;
 
 : modules-help ( -- seq )
     modules get [ module-help ] map [ ] subset ;
+
+M: module synopsis* \ PROVIDE: pprint-word module-name text ;
+
+M: module definition module>alist t ;
+
+M: module where* module-loc ;
index f14b22a5233404197e232e40c5403af5f41acc00..1533b93b4925ba019d1654c5f99a442136eb8eec 100644 (file)
@@ -1,10 +1,6 @@
 IN: modules
 USING: help io parser ;
 
-HELP: prefix-paths
-{ $values { "name" "a module name string" } { "seq" "a sequence of strings" } { "newseq" "a new sequence of path name strings" } }
-{ $description "Prepend the location of the module named " { $snippet "name" } " to every file name in " { $snippet "seq" } "." } ;
-
 HELP: module-def
 { $values { "name" "a module name string" } { "path" "a path name string" } }
 { $description "Outputs the location of the module definition file. This word looks for the module definition in two locations:"
@@ -32,7 +28,7 @@ $terpri
 { $notes "Module definitions should use the " { $link POSTPONE: REQUIRES: } " parsing word instead. In the listener, the " { $link require } " word might be more useful since it recompiles new words after loading the module." } ;
 
 HELP: provide
-{ $values { "name" "a string" } { "hash" "a hashtable" } }
+{ $values { "name" "a string" } { "hash" "a hashtable" } { "loc" "a pair holding a path name and line number" } }
 { $description "Registers a module definition and loads its source files. The possible hashtable keys are documented in the " { $link POSTPONE: PROVIDE: } " word. Usually instead of calling this word, module definitions use the parsing word " { $link POSTPONE: PROVIDE: } " instead." } ;
 
 HELP: test-module
index df8ba28e081ca8b2fc7bf6050c2e8e96712eafcc..3d83bd8c0b2e1fbfb91d3c059c7c753ae66f0142 100644 (file)
@@ -72,8 +72,7 @@ DEFER: !PRIMITIVE: parsing
 
 : !FORGET: scan use get hash-stack [ forget ] when* ; parsing
 
-: !PROVIDE:
-    scan [ alist>hash provide ] f ; parsing
+: !PROVIDE: scan location [ provide ] f ; parsing
 
 : !REQUIRES:
     string-mode on [
index 649c88561dd5ea880d26f3603e074408076c55c1..a524fcdb005e685fe12f073f7944589123f06c62 100644 (file)
@@ -92,7 +92,7 @@ M: word declarations.
         ] if newline
     ] with-pprint ;
 
-M: method-spec see (see) ;
+M: object see (see) ;
 
 GENERIC: see-class* ( word -- )
 
index cd54073ea82d2733a6850f7ef81b3d5e82a56082..3f16a1047cad5f5a9e762e65a46d5220bf6be2be 100644 (file)
@@ -31,6 +31,12 @@ M: operation invoke-command ( target operation -- )
     { +listener+ t }
 } define-operation
 
+[ drop t ] H{
+    { +name+ "Prettyprint" }
+    { +quot+ [ . ] }
+    { +listener+ t }
+} define-operation
+
 [ drop t ] H{
     { +name+ "Push" }
     { +quot+ [ ] }
@@ -76,6 +82,11 @@ M: operation invoke-command ( target operation -- )
     { +quot+ [ help-gadget call-tool ] }
 } define-operation
 
+[ word? ] H{
+    { +name+ "Edit documentation" }
+    { +quot+ [ <link> edit ] }
+} define-operation
+
 [ word? ] H{
     { +name+ "Usage" }
     { +keyboard+ T{ key-down f { A+ } "u" } }
@@ -129,7 +140,7 @@ M: operation invoke-command ( target operation -- )
     { +quot+ [ vocab-link-name forget-vocab ] }
 } define-operation
 
-! Module
+! Modules
 [ module? ] H{
     { +name+ "Run" }
     { +quot+ [ module-name run-module ] }
@@ -141,12 +152,23 @@ M: operation invoke-command ( target operation -- )
     { +quot+ [ module-help [ help-gadget call-tool ] when* ] }
 } define-operation
 
+[ module? ] H{
+    { +name+ "Edit" }
+    { +quot+ [ edit ] }
+} define-operation
+
 [ module? ] H{
     { +name+ "Reload" }
     { +quot+ [ reload-module ] }
     { +listener+ t }
 } define-operation
 
+[ module? ] H{
+    { +name+ "See" }
+    { +quot+ [ see ] }
+    { +listener+ t }
+} define-operation
+
 ! Link
 [ link? ] H{
     { +default+ t }