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

[REBOL] QUOTE (useful but missing)

From: robbo1mark::aol::com at: 12-Dec-2001 5:05

here's an old Lisp / Scheme style function which is missing in REBOL but turns out to be pretty useful for delaying evaluation and defining words to evaluating expressions or in REBOL parlance paren!'s. here's the function definition, QUOTE: func ['value] [return :value] and here's some examples of it's use.
>> a: 7
== 7
>> quote a
== a above example same as lit-word! 'a no immediate benefit, however consider this,
>> a: quote (print "hello world")
== (print "hello world")
>> a
hello world
>> :a
== (print "hello world") In the above example we set the word 'a to an evaluating expression ie a paren! This is useful as these kind of paren!'s can in certain circumstances be used in place of a 'DOES function with an increase gain in speed of 40 to 50 percent, the speed gain of course is due to avoiding the function call. Note this is only useful in replacing functions without any arguments or local words. The notational tick ' for lit-words is really just shorthand for quote value, it would be nice if we could have extended literal notation for other types of values in REBOL 3.0. ie literal-paren! '() example
>> '(print "hello")
== (print "hello") hope you find this useful, cheers everybody, Mark Dickson