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

[REBOL] Re: On mutability and sameness

From: joel:neely:fedex at: 20-Jun-2001 2:44

Hi, Mark, Just two remarks... [Robbo1Mark--aol--com] wrote:
> REBOL AS IT'S OWN META-LANGUAGE > > I've read recently from Jeff & Joel, and other's > in the previously, that REBOL is it's own meta-language. > > This is bunk! or at least only partially true. >
I've never said that "REBOL is its own meta-language". I accept full responsibility (for good or ill ;-) for any of my utterances, but prefer not to have ideas attributed to me unless I've actually said (and believe) them.
> Consider this model of REBOL addition... > > >> add: func [ x y ] [ + x y ] > >> add 1 2 > == 3 > > Fine so far, however how do you define the '+ in > the function body? >
Here's the majority of it ... bitstring: func [n [integer!] /local bv bt] [ bt: copy "" bv: 1 until [ append bt either 0 < (n and bv) [#"1"] [#"0"] any [ error? try [bv: bv + bv] n < bv ] ] bt ] add1: func [a [char!] b [char!] c [char!]] [ select [ "000" [#"0" #"0"] "001" [#"1" #"0"] "010" [#"1" #"0"] "011" [#"0" #"1"] "100" [#"1" #"0"] "101" [#"0" #"1"] "110" [#"0" #"1"] "111" [#"1" #"1"] ] to-string reduce [a b c] ] add2: func [aa [string!] bb [string!] /local cc a b s c] [ s: c: #"0" cc: copy "" while [(length? aa) < (length? bb)] [append aa #"0"] while [(length? bb) < (length? aa)] [append bb #"0"] until [ set [s c] add1 first aa first bb c append cc s aa: next aa tail? bb: next bb ] if c = #"1" [append cc c] cc ] adder: func [a [integer!] b [integer!]] [ head reverse add2 bitstring a bitstring b ] ... which behaves as
>> adder 2 2 == "100" >> adder 2 20 == "10110" >> adder 15 200 == "11010111"
Since REBOL is implemented on binary computers, one must understand binary in order to have a complete understanding of REBOL. Therefore translating the output of ADDER back to decimal is, of course, totally unnecessary. The final details of handling negatives and overflows are, as the saying goes, "left as an exercise to the reader". Have fun! ;-) -jn- ------------------------------------------------------------ Programming languages: compact, powerful, simple ... Pick any two! joel'dot'neely'at'fedex'dot'com