Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Forming, Mold and serialing datatypes

From: btiffin::rogers::com at: 3-Aug-2007 23:57

Hi list, First cut at a quick reference table of various conversions applied to R2 datatypes. It's rough, it's a little broken, but I'm looking for feedback regarding what to add/remove, and perhaps a professional opinion on the typesetting. If you run it, it'll create %allomorph.pdf I'll tweak things before publishing, but you see, I'm sneakily playing off my perception of the rebol personality trait of not letting something this crappy be released. :) I'm note sure why the second and third tables have no spacers between the rows...I have more of Gabriele's docs to read through. Like how to put proper table headings in place...how to multi-page the table...etc... Gabriele; I noticed this from Sep-2006 regarding your announcement about pdf maker 2.
>> I'm looking for some volunteer to write the user documentation.
If you are still looking, I'll volunteer. (But as you can see, I've got some learning to do). Cheers, Brian Oh, if you want, this can be snagged from http://peoplecards.ca/rebol/allomorph.r and the output is at http://peoplecards.ca/rebol/allomorph.pdf REBOL [ Title: "Datatypes as strings"] Author: "Brian Tiffin" Date: 03-Aug-2007 Name: "PDF of datatypes" Version: 0.9.0 File: %allomorph.r Owner: "REBOL Community" Rights: "Copyright (c) 2007, Brian Tiffin" Needs: none Tabs: 4 Usage: "Evaluation create %allomorph.pdf" Purpose: "Table of various string forms" Comment: "Uses v2 of pdf-maker.r. pdf-maker ROCKS" History: [ 03-Aug-2007 0.9.0 btiffin "First cut, coyote ugly" Language: 'en Type: 'script Content: none ] pages: [ [; page 1 textbox [ center font Helvetica-Bold 12.7 "REBOL datatype!" p space 10 center font Helvetica 4.23 0.0.200 {Various string! convserions} p table [] [ decor [box line width 0 xbl ybl xtr - xbl ytr - ybl] bottom margin 1 stretch 1 shrink 1 [ [ width 22 center font Times-Bold 4.23 0.0.0 "type?"] [ width 35 center font Times-Bold 4.23 "Source"] ;[ width 30 center font Times-Bold 4.23 "value"] [ width 35 center font Times-Bold 4.23 "to string!"] [ width 35 center font Times-Bold 4.23 "form"] [ width 35 center font Times-Bold 4.23 "mold"] [ width 35 center font Times-Bold 4.23 "mold/all"] ] foreach [datatype code value] reduce [ 'action! {:add} :add 'binary! {#{414243}} #{414243} ;'binary! {2#{01000001 01000010 01000011}} ; 2#{01000001 01000010 01000011} 'binary! {64#{QUJD}} 64#{QUJD} ;'bitset! {charset "ABC"} charset "ABC" 'block! {[1 A 2 B 3 C]} [1 A 2 B 3 C] 'char! {#"A"} #"A" 'date! {01-feb-2003} 01-feb-2003 'date! {01/02/03} 01/02/03 'decimal! {1'000'000.00100} 1'000'000.00100 ;'decimal! {2222222222222222.2} 2222222222222222.2 'email! {luke-rebol.com} luke-rebol.com 'error! {disarm make error! "ABC"} disarm make error! "ABC" ;'event! {make event! [Can't]} make event! [Can't] 'file! {%/abc/abc.abc} %/abc/abc.abc 'function! {make function! [a /local abc][]} make function! [a /local abc][] 'get-word! {to get-word! 'abc} to get-word! 'abc 'hash! {to hash! [a b c]} to hash! [a b c] 'image! {to image! [1x1 255.255.255 128]} make image! [1x1 255.255.255 128] 'integer! {1} 1 'integer! {222222222222} 222222222222 'issue! {#ABC} #ABC 'library! {load/library %/lib/libc.so.6} load/library %libc.so.6 'list! {make list! [a b c]} make list! [a b c] 'lit-path! {to lit-path! 'a/b/c} to lit-path! 'a/b/c 'lit-word! {to lit-word! 'abc} to lit-word! 'abc 'logic! {true} true 'logic! {to logic! 0} to logic! 0 'logic! {yes} yes 'logic! {off} off ] [ [ [width 22 right padding 2 left padding 2 font Times-Bold 4.23 0.0.0 left align form datatype] [width 35 center code] ;[width 30 center value] [width 35 center to string! :value] [width 35 center form :value] [width 35 center mold :value] [width 35 center mold/all :value] ] ] ] ] ] [; page 2 textbox [ center font Helvetica-Bold 12.7 "REBOL datatype!" p space 10 center font Helvetica 4.23 0.0.200 {Various string! convserions} p table [] [ decor [box line width 0 xbl ybl xtr - xbl ytr - ybl] bottom margin 1 stretch 1 shrink 1 [ [ width 22 center font Times-Bold 4.23 0.0.0 "type?"] [ width 35 center font Times-Bold 4.23 "Source"] ;[ width 30 center font Times-Bold 4.23 "value"] [ width 35 center font Times-Bold 4.23 "to string!"] [ width 35 center font Times-Bold 4.23 "form"] [ width 35 center font Times-Bold 4.23 "mold"] [ width 35 center font Times-Bold 4.23 "mold/all"] ] foreach [datatype code value] reduce [ 'money! {$1.23} $1.23 'money! {Cdn$1.2345} Cdn$1.2345 'native! {:print} :print 'none! {none} none {DON'T} {first [none]} first [none] 'none! {first [#[none]]} first [#[none]] ; 'number! 'object! {context [abc: none]} context [abc: none] 'op {:+} :+ 'pair! {123456789x1 * 987654321} 123456789x1 * 987654321 'paren! {to paren! [123 + 123]} to paren! [123 + 123] 'path! {'a/b/c} 'a/b/c ;'port! {open console://} open console:// 'refinement! {/abc} /abc ;'routine! {make routine! [] lib "abc"} ; make routine! [] lib "abc" ;'series {to series! [a b c]} to series! [a b c] 'set-path! {to set-path! [a b c]} to set-path! [a b c] 'set-word! {to set-word! 'abc} to set-word! 'abc 'string! {"abc"} "abc" 'struct! {make struct! [abc [int]] [0]} make struct! [abc [int]] [0] ;; symbol will cause a crash. ;; Invalid data type during recycle ;'symbol! {make symbol! 'abc} make symbol! 'abc 'tag! {<abc xyz=123>} <abc xyz=123> 'time! {01:23} 01:23 'tuple! {1.2.3.4.5.6} 1.2.3.4.5.6 ;; will need get/any for this ;'unset! {unset abc} unset abc 'url! {abc:123} abc:123 'word! {'abc} 'abc ] [ [ [width 22 right padding 2 left padding 2 font Times-Bold 4.23 0.0.0 left align form datatype] [width 35 center code] ;[width 30 center value] [width 35 center to string! :value] [width 35 center form :value] [width 35 center mold :value] [width 35 center mold/all :value] ] ] ] vspace 3 table [] [ decor [box line width 0 xbl ybl xtr - xbl ytr - ybl] bottom margin 1 stretch 1 shrink 1 foreach [datatype code value] reduce [ 'binary! {2#{01000001 01000010 01000011}} 2#{01000001 01000010 01000011} 'bitset! {charset "ABC"} charset "ABC" 'decimal! {2222222222222222.2} 2222222222222222.2 ;'event! {make event! [Can't]} make event! [Can't] ; 'number! ;'port! {open console://} open console:// ;'routine! {make routine! [] lib "abc"} ; make routine! [] lib "abc" ;'series {to series! [a b c]} to series! [a b c] ;; will need get/any for this ; 'unset! {unset 'abc} unset 'abc ] [ [ top padding 1 bottom padding 1 [width 35 center font Times-Bold 4.23 0.0.0 "type?"] [width 162 right padding 2 left padding 2 font Times-Bold 4.23 0.0.0 left align form datatype] ][ [width 35 center font Times-Bold 4.23 "Source"] [width 162 center code] ][ [width 35 center font Times-Bold 4.23 "to string!"] [width 162 center to string! :value] ][ [width 35 center font Times-Bold 4.23 "form"] [width 162 center form :value] ][ [width 35 center font Times-Bold 4.23 "mold"] [width 162 center mold :value] ][ [width 35 center font Times-Bold 4.23 "mold/all"] [width 162 center mold/all :value] ] ] ] ] ] ] unless value? 'layout-pdf [ ;do %pdf-maker2.r do read http://www.colellachiara.com/soft/PDFM2/pdf-maker.r ] write/binary %allomorph.pdf layout-pdf pages comment {
>> help datatype!
Found these words: action! datatype! action! any-block! datatype! any-block! any-function! datatype! any-function! any-string! datatype! any-string! any-type! datatype! any-type! any-word! datatype! any-word! binary! datatype! binary! bitset! datatype! bitset! block! datatype! block! char! datatype! char! datatype! datatype! datatype! date! datatype! date! decimal! datatype! decimal! email! datatype! email! error! datatype! error! event! datatype! event! file! datatype! file! function! datatype! function! get-word! datatype! get-word! hash! datatype! hash! image! datatype! image! integer! datatype! integer! issue! datatype! issue! library! datatype! library! list! datatype! list! lit-path! datatype! lit-path! lit-word! datatype! lit-word! logic! datatype! logic! money! datatype! money! native! datatype! native! none! datatype! none! number! datatype! number! object! datatype! object! op! datatype! op! pair! datatype! pair! paren! datatype! paren! path! datatype! path! port! datatype! port! refinement! datatype! refinement! routine! datatype! routine! series! datatype! series! set-path! datatype! set-path! set-word! datatype! set-word! string! datatype! string! struct! datatype! struct! symbol! datatype! symbol! tag! datatype! tag! time! datatype! time! tuple! datatype! tuple! unset! datatype! unset! url! datatype! url! word! datatype! word! }