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

[REBOL] Re: One-Liners back in town!

From: atruter:labyrinth:au at: 24-Nov-2002 13:30

Hi to everyone on this thread. Great to see the discussion it is generating. A couple of thoughts (just opinion, so feel free to disagree ;) )
>> save/png %hello.png to-image layout [banner "Hello World!"] view layout >> [image %hello.png]
I believe the above, while a functional improvement over the original, is in fact two seperate "things" with the first being "create a png image", then, "display a png image". My philosphy with these one-liners would be to keep them as simple as possible from both a syntactic and functional point of view. I believe that: ; Create a PNG image save/png %hello.png to-image layout [banner "Hello World!"] is: 1) Easy to read and understand, even for non-REBOL gurus 2) Has one clear and unambiguous purpose / function 3) Uses the simplest / clearest syntax to achieve 2) 4) Does not try to artificially squeeze multiple lines into one To me: save/png %hello.png to-image layout [banner "Hello World!"] view layout [image %hello.png] is just: ; Create a PNG image save/png %hello.png to-image layout [banner "Hello World!"] ; Display a PNG image view layout [image %hello.png] with the comments and line breaks removed. view layout [image (img: to-image layout [banner "Hello World!"])] may "do more" in a single line, but could cause confusion. At the very least someone could ask, "Isn't that just a more complex way of doing" view layout [banner "Hello World!"] Looking at the "clock" one-liner view layout[origin 0 t: h1 87 rate 1 feel[engage: [t/text: now/time show t]]] I would be tempted to rip out everything not required to display the time (it's intended purpose) and replace the 87 with "00:00:00" to both pre- allocate the required size and avoid confusion (someone new to REBOL might ask, "What is that 87 and how was it derived", while the "00:00:00" (especially given it is in quotes) is I believe a bit more intuitive. I would also be loath to remove spaces between words and opening blocks (like layout[ ) as it makes the code look congested and it differs from REBOL source snippets presented elsewhere. My [minor] rewrite of the above would look like: view layout [t: h1 "00:00:00" rate 1 feel [engage: [t/text: now/time show t]]] coming in at 78 chars. Again, this is just my opinion and no offense is intended to any of the authors of any of the above. ;) Regards, Ashley