]> gitweb.factorcode.org Git - factor.git/commitdiff
Working on Ruby.mn talk
authorSlava Pestov <slava@factorcode.org>
Tue, 29 Jan 2008 00:13:35 +0000 (18:13 -0600)
committerSlava Pestov <slava@factorcode.org>
Tue, 29 Jan 2008 00:13:35 +0000 (18:13 -0600)
15 files changed:
extra/calendar/calendar.factor
extra/calendar/model/model.factor [new file with mode: 0755]
extra/catalyst-talk/authors.txt [deleted file]
extra/catalyst-talk/catalyst-talk.factor [deleted file]
extra/catalyst-talk/deploy.factor [deleted file]
extra/catalyst-talk/summary.txt [deleted file]
extra/catalyst-talk/tags.txt [deleted file]
extra/lcd/lcd.factor [changed mode: 0644->0755]
extra/minneapolis-talk/authors.txt [new file with mode: 0644]
extra/minneapolis-talk/deploy.factor [new file with mode: 0755]
extra/minneapolis-talk/minneapolis-talk.factor [new file with mode: 0755]
extra/minneapolis-talk/minneapolis-talk.txt [new file with mode: 0755]
extra/minneapolis-talk/summary.txt [new file with mode: 0644]
extra/minneapolis-talk/tags.txt [new file with mode: 0644]
extra/ui/gadgets/labels/labels.factor

index 8c1c2fb3a649e853d56faa329fa09bce7d1670f2..a1fe0a55eaaa117f9a1ebd20cd79e1a817f045b0 100755 (executable)
@@ -333,16 +333,18 @@ M: integer year. ( n -- )
 M: timestamp year. ( timestamp -- )
     timestamp-year year. ;
 
-: pad-00 number>string 2 CHAR: 0 pad-left write ;
+: pad-00 number>string 2 CHAR: 0 pad-left ;
+
+: write-00 pad-00 write ;
 
 : (timestamp>string) ( timestamp -- )
     dup day-of-week day-abbreviations3 nth write ", " write
     dup timestamp-day number>string write bl
     dup timestamp-month month-abbreviations nth write bl
     dup timestamp-year number>string write bl
-    dup timestamp-hour pad-00 ":" write
-    dup timestamp-minute pad-00 ":" write
-    timestamp-second >fixnum pad-00 ;
+    dup timestamp-hour write-00 ":" write
+    dup timestamp-minute write-00 ":" write
+    timestamp-second >fixnum write-00 ;
 
 : timestamp>string ( timestamp -- str )
     [ (timestamp>string) ] string-out ;
@@ -357,11 +359,11 @@ M: timestamp year. ( timestamp -- )
 
 : (timestamp>rfc3339) ( timestamp -- )
     dup timestamp-year number>string write CHAR: - write1
-    dup timestamp-month pad-00 CHAR: - write1
-    dup timestamp-day pad-00 CHAR: T write1
-    dup timestamp-hour pad-00 CHAR: : write1
-    dup timestamp-minute pad-00 CHAR: : write1
-    timestamp-second >fixnum pad-00 CHAR: Z write1 ;
+    dup timestamp-month write-00 CHAR: - write1
+    dup timestamp-day write-00 CHAR: T write1
+    dup timestamp-hour write-00 CHAR: : write1
+    dup timestamp-minute write-00 CHAR: : write1
+    timestamp-second >fixnum write-00 CHAR: Z write1 ;
 
 : timestamp>rfc3339 ( timestamp -- str )
     >gmt [ (timestamp>rfc3339) ] string-out ;
@@ -390,8 +392,8 @@ M: timestamp year. ( timestamp -- )
         [ timestamp-month month-abbreviations nth write ] keep bl
         [ timestamp-day number>string 2 32 pad-left write ] keep bl
         dup now [ timestamp-year ] 2apply = [
-            [ timestamp-hour pad-00 ] keep ":" write
-            timestamp-minute pad-00
+            [ timestamp-hour write-00 ] keep ":" write
+            timestamp-minute write-00
         ] [
             timestamp-year number>string 5 32 pad-left write
         ] if
diff --git a/extra/calendar/model/model.factor b/extra/calendar/model/model.factor
new file mode 100755 (executable)
index 0000000..d07f4b4
--- /dev/null
@@ -0,0 +1,15 @@
+! Copyright (C) 2008 Slava Pestov\r
+! See http://factorcode.org/license.txt for BSD license.\r
+USING: calendar namespaces models threads ;\r
+IN: calendar.model\r
+\r
+SYMBOL: time\r
+\r
+: (time-thread) ( -- )\r
+    now time get set-model\r
+    1000 sleep (time-thread) ;\r
+\r
+: time-thread ( -- ) [ (time-thread) ] in-thread ;\r
+\r
+f <model> time set-global\r
+time-thread\r
diff --git a/extra/catalyst-talk/authors.txt b/extra/catalyst-talk/authors.txt
deleted file mode 100644 (file)
index 1901f27..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Slava Pestov
diff --git a/extra/catalyst-talk/catalyst-talk.factor b/extra/catalyst-talk/catalyst-talk.factor
deleted file mode 100644 (file)
index f76ef4d..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-USING: slides help.markup math arrays hashtables namespaces
-sequences kernel sequences parser ;
-IN: catalyst-talk
-
-: catalyst-slides
-{
-    { $slide "What is Factor?"
-        "Originally scripting for a Java game"
-        "Language dev more fun than game dev"
-        "Start with ideas which were mostly dead"
-        "Throw in features from crazy languages"
-        "Develop practical libraries and tools"
-    }
-    { $slide "Factor: a stack language"
-        "Implicit parameter passing"
-        { "Each " { $emphasis "word" } " is a function call" }
-        { $code ": sq dup * ;" }
-        { $code "2 3 + sq ." }
-        "Minimal syntax and semantics = easy meta-programming"
-        { "Related languages: Forth, Joy, PostScript" }
-    }
-    { $slide "Factor: a functional language"
-        { { $emphasis "Quotations" } " can be passed around, constructed..." }
-        { $code "[ sq 3 + ]" }
-        { { $emphasis "Combinators" } " are words which take quotations, eg " { $link if } }
-        { "For FP buffs: " { $link each } ", " { $link map } ", " { $link reduce } ", " { $link accumulate } ", " { $link interleave } ", " { $link subset } }
-        { $code "{ 42 69 666 } [ sq 3 + ] map ." }
-    }
-    { $slide "Factor: an object-oriented language"
-        { "Everything is an " { $emphasis "object" } }
-        { "An object is an instance of a " { $emphasis "class" } }
-        "Methods"
-        "Generic words"
-        "For CLOS buffs: we allow custom method combination, classes are objects too, there's a MOP"
-    }
-    
-    STRIP-TEASE:
-        $slide "Primary school geometry recap"
-        { $code
-            "GENERIC: area ( shape -- meters^2 )"
-            "TUPLE: square dimension ;"
-            "M: square area square-dimension sq ;"
-            "TUPLE: circle radius ;"
-            "M: circle area circle-radius sq pi * ;"
-            "TUPLE: rectangle width height ;"
-            "M: rectangle area"
-            "    dup rectangle-width"
-            "    swap rectangle-height"
-            "    * ;"
-        }
-    ;
-
-    { $slide "Geometry example"
-        { $code "10 <square> area ." }
-        { $code "18 <circle> area ." }
-        { $code "20 40 <rectangle> area ." }
-    }
-!    { $slide "Factor: a meta language"
-!        "Writing code which writes code"
-!        "Extensible parser: define new syntax"
-!        "Compiler transforms"
-!        "Here's an inefficient word:"
-!        { $code
-!            ": fib ( x -- y )"
-!            "    dup 1 > ["
-!            "        1 - dup fib swap 1 - fib +"
-!            "    ] when ;"
-!        }
-!    }
-!    { $slide "Memoization"
-!        { { $link POSTPONE: : } " is just another word" }
-!        "What if we could define a word which caches its results?"
-!        { "The " { $vocab-link "memoize" } " library provides such a feature" }
-!        { "Just change " { $link POSTPONE: : } " to " { $link POSTPONE: MEMO: } }
-!        { $code
-!            "MEMO: fib ( x -- y )"
-!            "    dup 1 > ["
-!            "        1 - dup fib swap 1 - fib +"
-!            "    ] when ;"
-!        }
-!    }
-    { $slide "Factor: a tool-building language"
-        "Tools are not monolithic, but are themselves just sets of words"
-        "Examples: parser, compiler, etc"
-        "Parser: turns strings into objects"
-        { $code "\"1\" <file-reader> contents parse" }
-        "Prettyprinter: turns objects into strings"
-        { $code "\"2\" <file-writer> [ . ] with-stream" }
-    }
-    { $slide "Factor: an interactive language"
-        { "Let's hack " { $vocab-link "tetris" } }
-        "Editor integration"
-        { $code "\\ tetrominoes edit" }
-        "Inspector"
-        { $code "\\ tetrominoes get inspect" }
-    }
-    { $slide "C library interface"
-        "No need to write C glue code!"
-        "Callbacks from C to Factor"
-        "Factor can be embedded in C apps"
-        { "Example: " { $vocab-link "ogg.vorbis" } }
-        { "Other bindings: OpenGL, OpenAL, X11, Win32, Cocoa, OpenSSL, memory mapped files, ..." }
-    }
-    { $slide "Native libraries"
-        "XML, HTTP, SMTP, Unicode, calendar, ..."
-        "Lazy lists, pattern matching, packed arrays, ..."
-    }
-    { $slide "Factor: a fun language"
-        { "Let's play "
-        { $vocab-link "space-invaders" }
-        }
-        { $url "http://factorcode.org" }
-        { $url "http://factor-language.blogspot.com" }
-        "irc.freenode.net #concatenative"
-        "Have fun!"
-    }
-} ;
-
-: catalyst-talk catalyst-slides slides-window ;
-
-MAIN: catalyst-talk
diff --git a/extra/catalyst-talk/deploy.factor b/extra/catalyst-talk/deploy.factor
deleted file mode 100755 (executable)
index 2f7f79d..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-USING: tools.deploy.config ;
-V{
-    { deploy-ui? t }
-    { deploy-io 1 }
-    { deploy-reflection 1 }
-    { deploy-compiler? t }
-    { deploy-math? t }
-    { deploy-word-props? f }
-    { deploy-c-types? f }
-    { "stop-after-last-window?" t }
-    { deploy-name "Catalyst Talk" }
-}
diff --git a/extra/catalyst-talk/summary.txt b/extra/catalyst-talk/summary.txt
deleted file mode 100644 (file)
index f2efe74..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Slides for a talk at Catalyst IT NZ, July 2007
diff --git a/extra/catalyst-talk/tags.txt b/extra/catalyst-talk/tags.txt
deleted file mode 100644 (file)
index cb5fc20..0000000
+++ /dev/null
@@ -1 +0,0 @@
-demos
old mode 100644 (file)
new mode 100755 (executable)
index 192e405..605ac4c
@@ -1,19 +1,19 @@
 USING: sequences kernel math io ;
 IN: lcd
 
-: lcd-digit ( digit row -- str )
-    {
-        "  _       _  _       _   _   _   _   _  "
-        " | |  |   _| _| |_| |_  |_    | |_| |_| "     
-        " |_|  |  |_  _|   |  _| |_|   | |_|   | "
+: lcd-digit ( row digit -- str )
+    dup CHAR: : = [ drop 10 ] [ CHAR: 0 - ] if swap {
+        "  _       _  _       _   _   _   _   _      "
+        " | |  |   _| _| |_| |_  |_    | |_| |_|  *  "
+        " |_|  |  |_  _|   |  _| |_|   | |_|   |  *  "
     } nth >r 4 * dup 4 + r> subseq ;
 
-: lcd-row ( num row -- )
-    swap [ CHAR: 0 - swap lcd-digit write ] with each ;
+: lcd-row ( num row -- string )
+    [ swap lcd-digit ] curry { } map-as concat ;
 
-: lcd ( digit-str -- )
-    3 [ lcd-row nl ] with each ;
+: lcd ( digit-str -- string )
+    3 [ lcd-row ] with map "\n" join ;
 
-: lcd-demo ( -- ) "31337" lcd ;
+: lcd-demo ( -- ) "31337" lcd print ;
 
 MAIN: lcd-demo
diff --git a/extra/minneapolis-talk/authors.txt b/extra/minneapolis-talk/authors.txt
new file mode 100644 (file)
index 0000000..1901f27
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
diff --git a/extra/minneapolis-talk/deploy.factor b/extra/minneapolis-talk/deploy.factor
new file mode 100755 (executable)
index 0000000..2f7f79d
--- /dev/null
@@ -0,0 +1,12 @@
+USING: tools.deploy.config ;
+V{
+    { deploy-ui? t }
+    { deploy-io 1 }
+    { deploy-reflection 1 }
+    { deploy-compiler? t }
+    { deploy-math? t }
+    { deploy-word-props? f }
+    { deploy-c-types? f }
+    { "stop-after-last-window?" t }
+    { deploy-name "Catalyst Talk" }
+}
diff --git a/extra/minneapolis-talk/minneapolis-talk.factor b/extra/minneapolis-talk/minneapolis-talk.factor
new file mode 100755 (executable)
index 0000000..1494517
--- /dev/null
@@ -0,0 +1,149 @@
+USING: slides help.markup math arrays hashtables namespaces
+sequences kernel sequences parser ;
+IN: minneapolis-talk
+
+: minneapolis-slides
+{
+    { $slide "What is Factor?"
+        "Dynamically typed, stack language"
+        "Have our cake and eat it too"
+        "Research -vs- production"
+        "High level -vs- performance"
+        "Interactive -vs- stand-alone apps"
+    }
+    { $slide "The view from 10,000 feet"
+        "Influenced by Forth, Lisp, Joy, Smalltalk, even Java..."
+        "Vocabularies: modules"
+        "Words: named functions, classes, variables"
+        "Combinators: higher-order functions"
+        "Quotations: anonymous functions"
+        "Other concepts are familiar: classes, objects, etc"
+    }
+    { $slide "Stack-based programming"
+        { "Most languages are " { $emphasis "applicative" } }
+        "Words pop inputs from the stack and push outputs on the stack"
+        "Literals are pushed on the stack"
+        { $code "{ 1 2 } { 7 } append reverse sum ." }
+        "With the stack you can omit unnecessary names"
+        "You can still name things: lexical/dynamic variables, sequences, associations, objects, ..."
+    }
+    { $slide "Functional programming"
+        "A quotation is a sequence of literals and words"
+        "Combinators replace imperative-style loops"
+        "A simple example:"
+        { $code "10 [ \"Hello world\" print ] times" }
+        { "Partial application: " { $link curry } }
+        { $code "{ 3 1 3 3 7 } [ 5 + ] map ." }
+        { $code "{ 3 1 3 3 7 } 5 [ + ] curry map ." }
+    }
+    { $slide "Word definitions"
+        { $code ": name ( inputs -- outputs ) definition ;" }
+        "Stack effect comments document stack inputs and outputs."
+        "Example from previous slide:"
+        { $code ": add-each ( seq n -- newseq ) [ + ] curry map ;" }
+        { $code "{ 3 1 3 3 7 } add-each ." }
+        "Copy and paste factoring"
+    }
+    { $slide "Object-oriented programming"
+        "Define a tuple class and a constructor:"
+        { $code
+            "TUPLE: person name address ;"
+            "C: <person> person"
+        }
+        "Create an instance:"
+        { $code "\"Cosmo Kramer\" \"100 Blah blah St, New York\" <person>" }
+        "We can inspect it and edit it"
+        "We can reshape the class:"
+        { $code "TUPLE: person name address age phone-number ;" }
+        { $code "TUPLE: person name address phone-number age ;" }
+    }
+    STRIP-TEASE:
+        $slide "Primary school geometry recap"
+        { $code
+            "TUPLE: square dimension ;"
+            "TUPLE: circle radius ;"
+            "TUPLE: rectangle width height ;"
+            ""
+            "GENERIC: area ( shape -- meters^2 )"
+            "M: square area square-dimension sq ;"
+            "M: circle area circle-radius sq pi * ;"
+            "M: rectangle area"
+            "    { rectangle-width rectangle-height } get-slots * ;"
+        }
+    ;
+
+    { $slide "Geometry example"
+        { $code "10 <square> area ." }
+        { $code "18 <circle> area ." }
+        { $code "20 40 <rectangle> area ." }
+    }
+    { $slide "Factor: a meta language"
+        "Here's fibonacci:"
+        { $code
+            ": fib ( x -- y )"
+            "    dup 1 > ["
+            "        1 - dup fib swap 1 - fib +"
+            "    ] when ;"
+        }
+        "It is slow:"
+        { $code
+            "20 [ fib ] map ."
+        }
+        "Let's profile it!"
+    }
+    { $slide "Memoization"
+        { { $link POSTPONE: : } " is just another word" }
+        "What if we could define a word which caches its results?"
+        { "The " { $vocab-link "memoize" } " library provides such a feature" }
+        { "Just change " { $link POSTPONE: : } " to " { $link POSTPONE: MEMO: } }
+        { $code
+            "MEMO: fib ( x -- y )"
+            "    dup 1 > ["
+            "        1 - dup fib swap 1 - fib +"
+            "    ] when ;"
+        }
+        "It is faster:"
+        { $code
+            "20 [ fib ] map ."
+        }
+    }
+    { $slide "The Factor UI"
+        "Written in Factor"
+        "Renders with OpenGL"
+        "Backends for Windows, X11, Cocoa"
+        "You can call Windows, X11, Cocoa APIs directly too"
+        "OpenGL 2.1 shaders, OpenAL 3D audio..."
+    }
+    { $slide "Implementation"
+        "Very small C core"
+        "Non-optimizing compiler"
+        "Optimizing compiler"
+        "Generational garbage collector"
+        "Non-blocking I/O"
+    }
+    { $slide "Live coding demo"
+        
+    }
+    { $slide "C library interface"
+        "Efficient"
+        "No need to write C code"
+        "Supports floats, structs, unions, ..."
+        "Function pointers, callbacks"
+    }
+    { $slide "Live coding demo"
+        
+    }
+    { $slide "Community"
+        "Factor development began in 2003"
+        "About a dozen contributors"
+        "Handful of \"core contributors\""
+        { "Web site: " { $url "http://factorcode.org" } }
+        "IRC: #concatenative on irc.freenode.net"
+        "Mailing list: factor-talk@lists.sf.net"
+        { "Let's play " { $vocab-link "space-invaders" } }
+    }
+} ;
+
+: minneapolis-talk minneapolis-slides slides-window ;
+
+MAIN: minneapolis-talk
diff --git a/extra/minneapolis-talk/minneapolis-talk.txt b/extra/minneapolis-talk/minneapolis-talk.txt
new file mode 100755 (executable)
index 0000000..5310acc
--- /dev/null
@@ -0,0 +1,116 @@
+- how to create a small module\r
+- editor integration\r
+- presentations\r
+- module system\r
+- copy and paste factoring, inverse\r
+- help system\r
+- tetris\r
+- memoization\r
+- editing inspector demo\r
+- dynamic scope, lexical scope\r
+\r
+Factor: contradictions?\r
+-----------------------\r
+\r
+Have our cake and eat it too\r
+\r
+Research -vs- practical\r
+High level -vs- fast\r
+Interactive -vs- deployment\r
+\r
+Factor from 10,000 feet\r
+-----------------------\r
+\r
+word: named function\r
+vocabulary: module\r
+quotation: anonymous function\r
+classes, objects, etc.\r
+\r
+The stack\r
+---------\r
+\r
+- Stack -vs- applicative\r
+- Pass by reference, dynamically typed\r
+- Stack languages: you can omit names where they're not needed\r
+- More compositional style\r
+- If you need to name things for clarity, you can:\r
+  lexical vars, dynamic vars, sequences, assocs, objects...\r
+\r
+Functional programming\r
+----------------------\r
+\r
+Quotations\r
+Curry\r
+Continuations\r
+\r
+Object-oriented programming\r
+---------------------------\r
+\r
+Generic words: sort of like open classes\r
+Tuple reshaping\r
+Editing inspector\r
+\r
+Meta programming\r
+----------------\r
+\r
+Simple, orthogonal core\r
+\r
+Why use a stack at all?\r
+-----------------------\r
+\r
+Nice idioms: 10 days ago\r
+Copy and paste factoring\r
+Easy meta-programming\r
+Sequence operations correspond to functional operations:\r
+- curry is adding at the front\r
+- compose is append\r
+\r
+UI\r
+--\r
+\r
+Written in Factor\r
+renders with OpenGL\r
+Windows, X11, Cocoa backends\r
+You can call Windows, X11, Cocoa APIs directly\r
+OpenGL 2.1 shaders, OpenAL 3D audio...\r
+\r
+Tools\r
+-----\r
+\r
+Edit\r
+Usages\r
+Profiler\r
+Easy to make your own tools\r
+\r
+Implementation\r
+--------------\r
+\r
+Two compilers\r
+Generational garbage collector\r
+Non-blocking I/O\r
+\r
+Hands on\r
+--------\r
+\r
+Community\r
+---------\r
+\r
+Factor started in 2003\r
+About a dozen contributors\r
+Handful of "core contributors"\r
+Web site: http://factorcode.org\r
+IRC: #concatenative on irc.freenode.net\r
+Mailing list: factor-talk@lists.sf.net\r
+\r
+C library interface\r
+-------------------\r
+\r
+Efficient\r
+No need to write C code\r
+Supports floats, structs, unions, ...\r
+Function pointers, callbacks\r
+Here is an example\r
+\r
+TerminateProcess\r
+\r
+process-handle TerminateProcess\r
diff --git a/extra/minneapolis-talk/summary.txt b/extra/minneapolis-talk/summary.txt
new file mode 100644 (file)
index 0000000..f2efe74
--- /dev/null
@@ -0,0 +1 @@
+Slides for a talk at Catalyst IT NZ, July 2007
diff --git a/extra/minneapolis-talk/tags.txt b/extra/minneapolis-talk/tags.txt
new file mode 100644 (file)
index 0000000..cb5fc20
--- /dev/null
@@ -0,0 +1 @@
+demos
index 2ac0240ed1bb2c8fb6e090826c76b674aaad6635..5e5801dd02aaa9d188bd17e8d4aa1582548e2f7d 100755 (executable)
@@ -40,7 +40,7 @@ M: label gadget-text* label-string % ;
 TUPLE: label-control ;
 
 M: label-control model-changed
-    swap model-value over set-label-text relayout ;
+    swap model-value over set-label-string relayout ;
 
 : <label-control> ( model -- gadget )
     "" <label> label-control construct-control ;