AJAX outliners

cvs
Slava Pestov 2006-01-24 02:03:22 +00:00
parent c54b438523
commit b28ea890b7
18 changed files with 98 additions and 436 deletions

View File

@ -1,197 +1,35 @@
- need line and paragraph spacing
- update HTML stream
- help cross-referencing
- UI browser pane needs 'back' button
- if cell is rebound, and we allocate c objects, bang
- runtime primitives like fopen: check for null input
- -with combinators are awkward
- amd64 to do:
- alien calls
- port ffi to win64
- intrinsic char-slot set-char-slot for x86
- fix up the min thumb size hack
- the invalid recursion form case needs to be fixed, for inlines too
- code walker & exceptions
- signal handler should not lose stack pointers
- FIELD: char key_vector[32];
- FIELD: union { char b[20]; short s[10]; long l[5]; } data;
- MEMBER: long pad[24];
- C structs, enums, unions: use new-style string mode parsing
- ffi unicode strings: null char security hole
- utf16 string boxing
- [ [ dup call ] dup call ] infer hangs
- slice: if sequence or seq start is changed, abstraction violation
- out of memory error when printing global namespace
- delegating generic words with a non-standard picker
- code gc
- stream server can hang because of exception handler limitations
- better i/o scheduler
- if two tasks write to a unix stream, the buffer can overflow
- font problem: http://iarc1.ece.utexas.edu/~erg/font-bug.JPG
- implement 3.3 floor 4.7 ceiling 4.5 truncate
- make 3.4 bits>double cause an error like 3.4 bits>float does
- float>bits bits>double etc fail in gcc 4.0.3 with -fschedule-insns
- C{ 0/0. 0/0. } C{ 0/0. 0/0. } = . -> f when -ffast-math is not used on x86
- can't type C{ nan.0 nan.0 } or C{ nan nan } at the repl
- "contrib/math/prime.factor" run-file is too slow (~100 seconds)
- test-2integer>x-throws causes an infinite loop in bignum_multiply_unsigned()
- add some tests below to the unit tests
ALL TESTS BELOW FAIL ON x86 linux 32bit
- 10 [ tan tan tan ] compile-1 ! runs out of memory
- float not commutative bug (?)
: a 237241607 1516.925984289192 3036109462846 913470293/554864
max min * 994.5872660892654 306803761/112249 -216866846 + -
max 6073750751093 364.7737275664338 3629914314951 + max max
9630706289317 6275800738949 179761544 + + + 88005566/945
2358.939297157175 1365.124822588899 max max - 61906796
388692629/82301 342893943/210229 * min * 381.5493627025407
10548296/49539 996.7264162840083 * + - ;
- min/max inline bug
: math-dummy
1507049 1812.446640674088 2682190027553 7662348747253 max
max max 175956841558 9163603105116 100680937 max min min
67305963/106562 78534496 63.25709285387058 max + min
116934358/596083 124000630 27821944/48045 - + max
357331489/880112 1760057/587415 7297976710833 - * max
-113698191 1404.610575779506 51191522 * * -
1977.861343144055 -50892488 947579163/437404 * min * ;
- compiled vs interpreted output differs!
: math-dummy 692476975489 >fixnum ;
: math-dummy -248461184 float>bits ; FAILS
---RATIO---
Compiles VERY SLOWLY
: math-dummy
292025505/568715131 587196182/778552531 cos neg
133163510/474434699 >bignum 57689734/429093367 tan cos
585585439/262485063 neg ;
Compile fails
: math-dummy 41614997/15884070 392881821/294492125 + sin sin sin tan sin 830428019/886540270 * neg ;
---FLOAT---
Compile fails:
: math-dummy
0.5589927916549555 tan 2.261878253481278 + tan sin ;
SLOW compile
: math-dummy
1.550108042325469 3.888423982091886 - tan tan ;
Compile fails:
: math-dummy
2.522378181825594 tan 7.825249292551574 - cos
0.2875868408644093 + sin >bignum cos >float sin ;
x86 problems below
Compile failes:
[ 0.0 cos coth cot neg ]
[ C{ -740108126/802208755 246440723/614809409 } coth sin cot -22338167 - ]
[ 101637844 ]
Compiling G:374994
101637844 -32579884
[ -235345183 ]
Compiling G:359656
-235345183 33090273
[ 0 bits>float ]
Compiling G:455019
4.203895392974451e-45 110.8125
[ -1 float>bits ]
Compiling G:455338
1099286058 4
[ -15766735 double>bits ]
Compiling G:455023
4702233936300867587 4777205847159578624
[ -23841331 bits>double ]
Compiling G:455027
5.127236739868035e-270 5.097526873523571e-270
[ -251924354 1+ ]
Compiling G:455128
-251924353 16511103
[ -258114108 1- ]
Compiling G:455920
-258114109 10321347
[ 259957324 bitnot ]
Compiling G:455227
-259957325 8478131
[ -268435456 quadrant ]
Compiling G:455335
1 0
[ 620858855246776348355165240843829248 >fixnum ]
Compiling G:457023
-268435456 0
[ 268435455 neg ]
Compiling G:457031
-268435455 1
[ -60976708 next-power-of-2 ]
Compiling G:457308
1 8388608
[ -132458581 real ]
Compiling G:459251
-132458581 1759147
[ -200388566 floor ]
Compiling G:461226
-200388566 938026
2 ARGUEMENT INTEGER WORDS
[ 252475730 -1 * ]
Compiling G:452424
-252475730 15959726
[ -268435456 209630756 min ]
Compiling G:452492
-268435456 0
[ -258355397 -181752298 max ]
Compiling G:452699
-181752298 19574294
[ -14282409 -22156592 + ]
Compiling G:452838
-36439001 30669863
[ -48101335 0 - ]
Compiling G:454874
-48101335 19007529
[ -48174218 0 bitxor ]
Compiling G:561725
-48174218 18934646
[ -57534898 -1 bitand ]
Compiling G:562430
-57534898 9573966
[ 75915195 -268435456 bitor ]
Compiling G:563342
-192520261 8806331
[ -264174045 66395852 align ]
Compiling G:564824
-201187292 139300
- need line and paragraph spacing
- update HTML stream
- help cross-referencing
- UI browser pane needs 'back' button
- if cell is rebound, and we allocate c objects, bang
- runtime primitives like fopen: check for null input
- -with combinators are awkward
- amd64 to do:
- alien calls
- port ffi to win64
- intrinsic char-slot set-char-slot for x86
- fix up the min thumb size hack
- the invalid recursion form case needs to be fixed, for inlines too
- code walker & exceptions
- signal handler should not lose stack pointers
- FIELD: char key_vector[32];
- FIELD: union { char b[20]; short s[10]; long l[5]; } data;
- MEMBER: long pad[24];
- C structs, enums, unions: use new-style string mode parsing
- ffi unicode strings: null char security hole
- utf16 string boxing
- [ [ dup call ] dup call ] infer hangs
- slice: if sequence or seq start is changed, abstraction violation
- out of memory error when printing global namespace
- delegating generic words with a non-standard picker
- code gc
- stream server can hang because of exception handler limitations
- better i/o scheduler
- if two tasks write to a unix stream, the buffer can overflow
- font problem: http://iarc1.ece.utexas.edu/~erg/font-bug.JPG
- implement 3.3 floor 4.7 ceiling 4.5 truncate
- make 3.4 bits>double an error
- float>bits bits>double etc fail in gcc 4.0.3 with -fschedule-insns
- C{ 0/0. 0/0. } C{ 0/0. 0/0. } = . -> f when -ffast-math is not used on x86
- can't type C{ nan.0 nan.0 } or C{ nan nan } at the repl

View File

@ -1 +0,0 @@
/* liveUpdater.js originally written by Avi Bryant, author of Seaside (http://www.beta4.com/seaside2) Modifed by Chris Double to add LiveUpdaterPost and use ' instead of " for the id. */ function liveUpdaterUri(uri) { return liveUpdater(function() { return uri; }); } function liveUpdater(uriFunc) { var request = false; var regex = /<(\w+).*?id='(\w+)'.*?>((.|\n)*)<\/\1>/; if (window.XMLHttpRequest) { request = new XMLHttpRequest(); } function update() { if(request && request.readyState < 4) request.abort(); if(!window.XMLHttpRequest) request = new ActiveXObject("Microsoft.XMLHTTP"); request.onreadystatechange = processRequestChange; request.open("GET", uriFunc()); request.send(null); return false; } function processRequestChange() { if(request.readyState == 4) { var results = regex.exec(request.responseText); if(results) document.getElementById(results[2]).innerHTML = results[3]; } } return update; } function liveUpdaterPost(uriFunc) { var request = false; var regex = /<(\w+).*?id='(\w+)'.*?>((.|\n)*)<\/\1>/; if (window.XMLHttpRequest) { request = new XMLHttpRequest(); } function update(data) { if(request && request.readyState < 4) request.abort(); if(!window.XMLHttpRequest) request = new ActiveXObject("Microsoft.XMLHTTP"); request.onreadystatechange = processRequestChange; request.open("POST", uriFunc()); request.send(data); return false; } function processRequestChange() { if(request.readyState == 4) { var results = regex.exec(request.responseText); if(results) document.getElementById(results[2]).innerHTML = results[3]; } } return update; } function liveSearch(id, uri) { var updater = liveUpdaterPost((function() { return uri; })); var last = ""; var timeout = false; function update() { if (last != document.getElementById(id).value) updater("s=" + escape(document.getElementById(id).value)); } function start() { if (timeout) window.clearTimeout(timeout); timeout = window.setTimeout(update, 300); } if (navigator.userAgent.indexOf("Safari") > 0) document.getElementById(id).addEventListener("keydown",start,false); else if (navigator.product == "Gecko") document.getElementById(id).addEventListener("keypress",start,false); else document.getElementById(id).attachEvent("onkeydown",start); }

View File

@ -1,166 +0,0 @@
! Copyright (C) 2004 Chris Double.
!
! Redistribution and use in source and binary forms, with or without
! modification, are permitted provided that the following conditions are met:
!
! 1. Redistributions of source code must retain the above copyright notice,
! this list of conditions and the following disclaimer.
!
! 2. Redistributions in binary form must reproduce the above copyright notice,
! this list of conditions and the following disclaimer in the documentation
! and/or other materials provided with the distribution.
!
! THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
! DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
!
! cont-responder code for display forms and anchors that use XMLHttpRequest
! and the 'liveUpdater.js' code.
IN: live-updater
USE: kernel
USE: io
USE: strings
USE: html
USE: cont-responder
USE: namespaces
USE: lists
: get-live-updater-js* ( stream -- string )
#! Read all lines from the stream, creating a string of the result.
dup stream-readln dup [ % "\n" % get-live-updater-js* ] [ drop stream-close ] if ;
: get-live-updater-js ( filename -- string )
#! Return the liveUpdater javascript code as a string.
<file-reader> [ get-live-updater-js* ] "" make ;
: live-updater-url ( -- url )
#! Generate an URL to the liveUpdater.js code.
t [
[
"js/liveUpdater.js" get-live-updater-js write
] show
] register-continuation id>url ;
: include-live-updater-js ( -- )
#! Write out the HTML script to include the live updater
#! javascript code.
<script "JavaScript" =language live-updater-url =src script>
"" write
</script> ;
: write-live-anchor-tag ( text -- id )
#! Write out the HTML for the clickable anchor. This
#! will have no actionable HREF assigned to it. Instead
#! an onclick is set via DHTML later to make it run a
#! quotation on the server. The randomly generated id
#! for the anchor is returned.
<a get-random-id dup =id "#" =href a>
swap write
</a> ;
: register-live-anchor-quot ( div-id div-quot -- kid )
#! Register the 'quot' with the cont-responder so
#! that when it is run it will produce an HTML
#! fragment which is the output generated by calling
#! 'quot'. That HTML fragment will be wrapped in a
#! 'div' with the given id.
[
"div-quot" set
"div-id" set
] make-hash [
[
t "disable-initial-redirect?" set
[
<div "div-id" get =id div> "div-quot" get call </div>
] show
] bind
] cons t swap register-continuation ;
: write-live-anchor-script ( div-id div-quot anchor-id -- )
#! Write the javascript that will attach the onclick
#! event handler to the anchor with the 'anchor-id'. The
#! onclick, when clicked, will retrieve from the server
#! the HTML generated by the output of 'div-quot' wrapped
#! in a 'div' tag with the 'div-id'. That 'div' tag will
#! replace whatever HTML DOM object currently has that same
#! id.
<script "JavaScript" =language script>
"document.getElementById('" write
write
"').onclick=liveUpdaterUri('" write
register-live-anchor-quot id>url write
"');" write
</script> ;
: live-anchor ( id quot text -- )
#! Write out the HTML for an anchor that when clicked
#! will replace the DOM object on the current page with
#! the given 'id' with the result of the output of calling
#! 'quot'.
write-live-anchor-tag
write-live-anchor-script ;
: write-live-search-tag ( -- id )
#! Write out the HTML for the input box. This
#! will have no actionable keydown assigned to it. Instead
#! a keydown is set via DHTML later to make it run a
#! quotation on the server. The randomly generated id
#! for the input box is returned.
<input get-random-id dup =id "text" =type input/> ;
: register-live-search-quot ( div-id div-quot -- kid )
#! Register the 'quot' with the cont-responder so
#! that when it is run it will produce an HTML
#! fragment which is the output generated by calling
#! 'quot'. That HTML fragment will be wrapped in a
#! 'div' with the given id. The 'quot' is called with
#! a string on top of the stack. This is the input string
#! entered in the live search input box.
[
"div-quot" set
"div-id" set
] make-hash [
[
t "disable-initial-redirect?" set
#! Retrieve the search query value from the POST parameters.
[ "s" get ] bind
[
#! Don't need the URL as the 'show' won't be resumed.
drop
<div "div-id" get =id div> "div-quot" get call </div>
] show
] bind
] cons t swap register-continuation ;
: write-live-search-script ( div-id div-quot id-id -- )
#! Write the javascript that will attach the keydown handler
#! to the input box with the give id. Whenever a keydown is
#! received the 'div-quot' will be executed on the server,
#! with the input boxes text on top of the stack. The
#! output of the quot will be an HTML fragment, it is wrapped in
#! a 'div' with the id 'div-id' and will
#! replace whatever HTML DOM object currently has that same
#! id.
<script "JavaScript" =language script>
"liveSearch('" write
write
"', '" write
register-live-search-quot id>url write
"');" write
</script> ;
: live-search ( div-id div-quot -- )
#! Write an input text field. The keydown of this
#! text field will run 'div-quot' on the server with
#! the value of the text field on the stack. The output
#! of div-quot will replace the HTML DOM object with the
#! given id.
write-live-search-tag
write-live-search-script ;

View File

@ -9,7 +9,6 @@ USING: words kernel parser sequences io compiler ;
"cont-numbers-game"
"todo"
"todo-example"
"live-updater"
"eval-responder"
"live-updater-responder"
"cont-testing"

View File

@ -42,14 +42,14 @@ memory namespaces prettyprint sequences words xml ;
: vocab-list ( vocab -- )
#! Write out the HTML for the list of vocabularies. Make the currently
#! selected vocab be 'vocab'.
<select "vocab" =name "width: 200" =style "20" =size "document.forms.main.submit()" =onchange select>
<select "vocab" =name "width: 200px; " =style "20" =size "document.forms.main.submit()" =onchange select>
vocabs [ over swap option ] each drop
</select> ;
: word-list ( vocab word -- )
#! Write out the HTML for the list of words in a vocabulary. Make the 'word' item
#! the currently selected option.
<select "word" =name "width: 200" =style "20" =size "document.forms.main.submit()" =onchange select>
<select "word" =name "width: 200px; " =style "20" =size "document.forms.main.submit()" =onchange select>
swap words natural-sort
[ word-name over swap option ] each drop
</select> ;
@ -67,8 +67,8 @@ memory namespaces prettyprint sequences words xml ;
<th> "Documentation" write </th>
</tr>
<tr>
<td "top" =valign "width: 200" =style td> over vocab-list </td>
<td "top" =valign "width: 200" =style td> 2dup word-list </td>
<td "top" =valign "width: 200px;" =style td> over vocab-list </td>
<td "top" =valign "width: 200px;" =style td> 2dup word-list </td>
<td "top" =valign td> word-source </td>
</tr>
</table> ;

View File

@ -40,8 +40,7 @@ SYMBOL: post-refresh-get?
: get-random-id ( -- id )
#! Generate a random id to use for continuation URL's
[ 32 [ 9 random-int CHAR: 0 + , ] times ] "" make
string>number 36 >base ;
[ "ID" % 32 [ 9 random-int CHAR: 0 + , ] times ] "" make ;
SYMBOL: table

View File

@ -114,6 +114,8 @@ SYMBOL: html
: do-foo> write-attributes n> drop ">" write-html ;
: do-foo/> write-attributes n> drop "/>" write-html ;
: def-for-html-word-foo> ( name -- )
#! Return the name and code for the foo> patterned
#! word.
@ -128,17 +130,19 @@ SYMBOL: html
: <foo/> [ "<" % % "/>" % ] "" make ;
: do-<foo/> <foo/> write-html ;
: def-for-html-word-<foo/> ( name -- )
#! Return the name and code for the <foo/> patterned
#! word.
dup <foo/> swap [ do-<foo> ] cons html-word drop ;
dup <foo/> swap [ do-<foo/> ] cons html-word drop ;
: foo/> "/>" append ;
: def-for-html-word-foo/> ( name -- )
#! Return the name and code for the foo/> patterned
#! word.
foo/> [ do-foo> ] html-word define-close ;
foo/> [ do-foo/> ] html-word define-close ;
: define-closed-html-word ( name -- )
#! Given an HTML tag name, define the words for

View File

@ -153,8 +153,8 @@ M: html-stream stream-format ( str style stream -- )
<table>
<tr>
<td>
"replaceme" swap [
[ with-html-stream ] show-final
get-random-id dup >r swap [
with-html-stream
] curry "+" live-anchor
</td>
<td>
@ -163,7 +163,7 @@ M: html-stream stream-format ( str style stream -- )
</tr>
<tr>
<td> </td>
<td> <div "replaceme" =id div> </div>
<td r> =id td> </td>
</tr>
</table> ;
@ -194,7 +194,12 @@ M: html-stream stream-terpri [ <br/> ] with-stream* ;
"A:hover, A:hover { text-decoration: none; color: black; }" print
</style> ;
: xhtml-preamble
"<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>" print
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">" print ;
: html-document ( title quot -- )
xhtml-preamble
swap chars>entities dup
<html>
<head>

View File

@ -1,50 +1,21 @@
! Copyright (C) 2004 Chris Double.
!
! Redistribution and use in source and binary forms, with or without
! modification, are permitted provided that the following conditions are met:
!
! 1. Redistributions of source code must retain the above copyright notice,
! this list of conditions and the following disclaimer.
!
! 2. Redistributions in binary form must reproduce the above copyright notice,
! this list of conditions and the following disclaimer in the documentation
! and/or other materials provided with the distribution.
!
! THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
! DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
! See http://factorcode.org/license.txt for BSD license.
!
! cont-responder code for display forms and anchors that use XMLHttpRequest
! and the 'liveUpdater.js' code.
! cont-responder code for display forms and anchors that use
! XMLHttpRequest and the 'liveUpdater.js' code.
IN: live-updater
USING: kernel io strings html cont-responder namespaces lists ;
: get-live-updater-js* ( stream -- string )
#! Read all lines from the stream, creating a string of the result.
dup stream-readln dup [ % "\n" % get-live-updater-js* ] [ drop stream-close ] if ;
USING: cont-responder html io kernel lists namespaces strings
xml ;
: get-live-updater-js ( filename -- string )
#! Return the liveUpdater javascript code as a string.
"/contrib/httpd/liveUpdater.js" <resource-stream> contents ;
: live-updater-url ( -- url )
#! Generate an URL to the liveUpdater.js code.
t [
[ get-live-updater-js write ] show
] register-continuation id>url ;
: include-live-updater-js ( -- )
#! Write out the HTML script to include the live updater
#! javascript code.
<script "JavaScript" =language live-updater-url =src script>
"" write
<script "JavaScript" =language script>
get-live-updater-js write-html
</script> ;
: write-live-anchor-tag ( text -- id )
@ -53,9 +24,7 @@ USING: kernel io strings html cont-responder namespaces lists ;
#! an onclick is set via DHTML later to make it run a
#! quotation on the server. The randomly generated id
#! for the anchor is returned.
<a get-random-id dup =id "#" =href a>
swap write
</a> ;
<a get-random-id dup =id "#" =href a> swap write </a> ;
: register-live-anchor-quot ( div-id div-quot -- kid )
#! Register the 'quot' with the cont-responder so
@ -68,7 +37,7 @@ USING: kernel io strings html cont-responder namespaces lists ;
"div-id" set
] make-hash [
[
t "disable-initial-redirect?" set
"disable-initial-redirect?" on
[
<div "div-id" get =id div> "div-quot" get call </div>
] show
@ -84,11 +53,11 @@ USING: kernel io strings html cont-responder namespaces lists ;
#! replace whatever HTML DOM object currently has that same
#! id.
<script "JavaScript" =language script>
"document.getElementById('" write
write
"').onclick=liveUpdaterUri('" write
register-live-anchor-quot id>url write
"');" write
"document.getElementById('" write-html
write-html
"').onclick=liveUpdaterUri('" write-html
register-live-anchor-quot id>url write-html
"');" write-html
</script> ;
: live-anchor ( id quot text -- )
@ -120,7 +89,7 @@ USING: kernel io strings html cont-responder namespaces lists ;
"div-id" set
] make-hash [
[
t "disable-initial-redirect?" set
"disable-initial-redirect?" on
#! Retrieve the search query value from the POST parameters.
[ "s" get ] bind
[

View File

@ -61,7 +61,7 @@ ARTICLE: "method-combination" "Method combination"
"which stack item(s) the generic word dispatches upon,"
"which methods out of the set of applicable methods are called"
}
"The " { $link POSTPONE: GENERIC: } " parsing word creates a generic word using the " { $emphasis "simple method combination." } ". Most generic words that come up in practice use this method combination:"
"The " { $link POSTPONE: GENERIC: } " parsing word creates a generic word using the " { $emphasis "simple method combination" } ". Most generic words that come up in practice use this method combination:"
{ $subsection simple-combination }
"The " { $link POSTPONE: G: } " parsing word allows a different method combination to be specified:"
{ $subsection POSTPONE: G: }

View File

@ -29,7 +29,7 @@ M: word print-element { } swap execute ;
last-block off [ print-element ] with-style ;
: ($block) ( quot -- )
last-block [ [ terpri ] unless f ] change
last-block [ [ terpri ] unless t ] change
call
terpri
last-block on ; inline

View File

@ -434,6 +434,10 @@ sequences strings vectors words prettyprint ;
\ alien-float t "flushable" set-word-prop
\ set-alien-float [ [ float c-ptr integer ] [ ] ] "infer-effect" set-word-prop
\ alien-float [ [ c-ptr integer ] [ float ] ] "infer-effect" set-word-prop
\ alien-float t "flushable" set-word-prop
\ set-alien-double [ [ float c-ptr integer ] [ ] ] "infer-effect" set-word-prop
\ alien-double [ [ c-ptr integer ] [ float ] ] "infer-effect" set-word-prop
\ alien-double t "flushable" set-word-prop

View File

@ -6,5 +6,5 @@ HELP: (random-int) "( -- rand )"
HELP: random-int "( n -- rand )"
{ $values { "rand" "an integer between 0 and n" } }
{ $description "Outputs a pseudo-random integer in the interval " { $snippet "[0,n]" } "." }
{ $description "Outputs a pseudo-random integer in the interval " { $snippet "[0,n)" } "." }
{ $notes "As per the closed interval notation, the end-points are included in the interval." } ;

View File

@ -66,4 +66,4 @@ DEFER: PRIMITIVE: parsing
scan-word [ create-constructor ] keep
[ define-constructor ] [ ] ; parsing
: FORGET: scan use get hash-stack [ forget ] when* ; parsing
: FORGET: scan use get hash [ forget ] when* ; parsing

View File

@ -100,8 +100,10 @@ M: object error. ( error -- ) . ;
error-continuation get continuation-name hash-stack ;
: debug-help ( -- )
":s :r show stacks at time of error." print
":get ( var -- value ) inspects the error namestack." print
":s :r show stacks at time of error" print
":get ( var -- value ) accesses variables at time of error" print
":error starts the inspector with the error" print
":cc starts the inspector with the error continuation" print
flush ;
: flush-error-handler ( -- )

View File

@ -44,3 +44,9 @@ SYMBOL: inspector-stack
: go ( n -- ) inspector-slots get nth (inspect) ;
: up ( -- ) inspector-stack get dup pop* pop (inspect) ;
! Another feature.
IN: errors
: :error ( -- ) error get inspect ;
: :cc ( -- ) error-continuation get inspect ;

View File

@ -67,6 +67,7 @@ M: command-button gadget-help ( button -- string )
command-button-object dup word? [ synopsis ] [ summary ] if ;
"Describe object" [ drop t ] [ describe ] \ in-browser define-default-command
"Inspect object" [ drop t ] [ inspect ] \ in-listener define-command
"Describe commands" [ drop t ] [ applicable describe ] \ in-browser define-command
"Prettyprint" [ drop t ] [ . ] \ in-listener define-command
"Push on data stack" [ drop t ] [ ] \ in-listener define-command

View File

@ -60,8 +60,7 @@ DEFER: layout
TUPLE: pack align fill gap ;
: pref-dims ( gadget -- list )
gadget-children [ pref-dim ] map ;
: pref-dims ( gadget -- list ) [ pref-dim ] map ;
: orient ( gadget seq1 seq2 -- seq )
>r >r gadget-orientation r> r> [ pick set-axis ] 2map nip ;
@ -105,15 +104,18 @@ C: pack ( vector -- pack )
: <shelf> ( -- pack ) { 1 0 0 } <pack> ;
M: pack pref-dim ( pack -- dim )
: pack-pref-dim ( children gadget -- dim )
[
[
pref-dims [ max-dim ] keep
[ { 0 0 0 } [ v+ ] reduce ] keep length 1 - 0 max
] keep pack-gap n*v v+
>r [ max-dim ] keep
[ { 0 0 0 } [ v+ ] reduce ] keep length 1 - 0 max
r> pack-gap n*v v+
] keep gadget-orientation set-axis ;
M: pack layout* ( pack -- ) dup pref-dims packed-layout ;
M: pack pref-dim ( pack -- dim )
[ gadget-children pref-dims ] keep pack-pref-dim ;
M: pack layout* ( pack -- )
dup gadget-children pref-dims packed-layout ;
: fast-children-on ( dim axis gadgets -- i )
swapd [ rect-loc origin get v+ v- over v. ] binsearch nip ;