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

[REBOL] Re: Embedded Markup Considered Harmful [Oct. 02, 1997]

From: joel:neely:fedex at: 13-Oct-2002 11:04

Hi, Dick, Two thoughts, one a direct reply and one more deferred... [reffy--ulrich--net] wrote:
> I originally chirped in on the XML comments ... > > Seems that there should be an XML_Display... > > XML_Display (25 87 20) (date) > (2 2 ReshapeOf 4 Random 1000) (UCase "Hello World") > > <VECTOR LENGTH=4> > <VECTOR LENGTH=3> > <SCALAR DATATYPE="NUMERIC">25</SCALAR> > <SCALAR DATATYPE="NUMERIC">87</SCALAR> > <SCALAR DATATYPE="NUMERIC">20</SCALAR> > </VECTOR> > <STRING>Sun Oct 13 07:00:24 2002</STRING> > <ARRAY RANK=2 SHAPE=2,2> > <SCALAR DATATYPE="NUMERIC">12</SCALAR> > <SCALAR DATATYPE="NUMERIC">987</SCALAR> > <SCALAR DATATYPE="NUMERIC">82</SCALAR> > <SCALAR DATATYPE="NUMERIC">132</SCALAR> > </ARRAY> > <STRING>HELLO WORLD</STRING> > </VECTOR> >
1) The REBOL-to-XML issue seems simple; consider this fragment ... 8<---------- r2x: make object! [ buff: {} padl: 0 v: none emit: func [sb [string! block!]] [ insert insert insert/dup tail buff { } padl either block? sb [rejoin sb] [sb] newline ] render-item: func [v [any-type!] /local t] [ emit [{<} t: type? v {>} v {</} t {>}] ] v: none rule: [ any [ into [ ( emit {<block>} padl: padl + 1 ) rule ( padl: padl - 1 emit {</block>} ) ] | set v any-type! (render-item v) ] ] render: func [b [block!]] [ buff: copy {} padl: 0 parse/all reduce [b] rule buff ] ] 8<---------- ... which behaves as follows:
>> reffy: [
[ [25 87 20] [ 13-Oct-2002 [ [ [1 3 5] [2 4 6] ] [ "That's all, folks!" [ ] == [ [25 87 20] 13-Oct-2002 [[1 3 5] [2 4 6]] "That's all, folks!" ]
>> print r2x/render reffy
<block> <block> <integer>25</integer> <integer>87</integer> <integer>20</integer> </block> <date>13-Oct-2002</date> <block> <block> <integer>1</integer> <integer>3</integer> <integer>5</integer> </block> <block> <integer>2</integer> <integer>4</integer> <integer>6</integer> </block> </block> <string>That's all, folks!</string> </block> Adding "length" attribute/value data to the <block> tag is left as an exercise to the reader. (Mostly because it wasn't immediately obvious how to do so, as SET before INTO doesn't seem to do what I expected, and I didn't have time for another research project. Perhaps someone else on the list has a clue... ;-) 2) Back to the discussion of "arbitrary" choices in representation, it's not clear to me that the concept of "inherent" structure and representation has any meaning apart from convention. Take the case of a two-dimensional matrix. FORTRAN and C store such structures in orthogonal layouts (FORTRAN varies the left subscript most rapidly, and C varies the right subscript most rapidly), while both REBOL and Perl would use nested one-dimensional structures (REBOL blocks or Perl arrays). Even my use of language betrays me if I talk about rows and "columns" of the matrix, which terms imply some sort of typographic layout. As another example consider a REBOL block containing student data: e.g., an ID, a name, and a phone number for each student. One person might immediately think of something like this: [ [123 "Alex Ant" #555-1111] [234 "Betty Bee" #555-2222] [345 "Cliff Cricket" #555-3333] ... ] while another would think of this: [ [123 234 345 ...] ["Alex Ant" "Betty Bee" "Cliff Cricket" ...] [{555-1111} {555-2222} {555-3333} ...] ] and yet another would envision: [ "123" ["Alex Ant" [555 1111]] "234" ["Betty Bee" [555 2222]] "345" ["Cliff Cricket" [555 3333]] ... ] Clearly each of these serves *some* purposes well and others poorly; the choice ultimately is entangled with one's intended processing (or one's habits and assumptions). I'm not trying to beat a dead horse here, but rather just musing quasi-philosophically about the process by which we programmers make our design decisions, and how many of those decisions are so deeply unconscious that we aren't even aware that there are alternatives. EWD told a wonderful story about giving an individualized test where the student is presented with a problem and is expected to "think aloud" while designing a solution on the board in the professor's presence. The problem he described involves achieving a specified condition in a single pass across a one-dimensional array, where the obvious solution would sweep back-and-forth multiple times. He had been accustomed (over many uses of this problem) to seeing the students end up with some processing upon elements in "increasing" (left-to-right) positional order. He was surprised by a student from Israel, who developed an equally valid solution which swept the array in *decreasing* (right-to-left) positional order. He wondered how much growing up reading r-to-l Hebrew instead of a l-to-r European language influenced the way the student conceptualized the problem. Makes one wonder, doesn't it?! -jn- -- Intel's MMX commercials clearly demonstrate that they're "staying alive" by continuing to try to re-use ideas from the 70's! -- Anonymous joel>FIX>PUNCTUATION>dot>neely>at>fedex>dot>com