Site Tools


quoting_hell

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

quoting_hell [2007/07/10 21:03] (current)
Line 1: Line 1:
 +======Quoting hell======
 +
 +=====What is quoting hell?======
 +//Quoting hell// is a catch-all term used to describe the edge places in 
 +ircII'​s quirky syntax where it is not at all obvious just how you'​re ​
 +supposed to make something work.  ​
 +
 +Of course you know by now that in the ircII language, data and code are 
 +fully interchangable. ​ When you want to run a piece of code later, the 
 +usual way to do this is to pass the code as a string argument to another
 +command that queues it up.
 +
 +Because arguments to functions are subject to $-expansion and \\-dequoting,​
 +sometimes you don't wan the $'s to be expanded at the time you queue up
 +the code (now), but rather when the code is executed (later). ​ Usually ​
 +you can do this by doubling up $'s and \'ing any characters that have special
 +meanings, such as semicolons.
 +
 +This is more of an art than a science, and the unpleasant situation of trying
 +to figure out just how many $'s you need to use to get that variable to expand
 +at just the right time is colloquially known as [[quoting hell]].
 +
 +=====Example:​=====
 +Let's say you want to output the time.  It is the $Z expando.
 + echo $Z
 +
 +Let's say you want to output the time in 2 minutes:
 + timer 120 echo $Z
 +Oops!  That doesn'​t work, because the language doesn'​t know that "echo $Z"
 +is code, and it expands all $'s now.  You can double up the $ to prevent
 +the expansion from happening until later
 + timer 120 echo $$Z
 +
 +Let's say you want to output the time in 2 minutes, but not if the client ​
 +is doing something like a [[wait]] or a [[redirect]].
 + timer 120 defer echo $$Z
 +Oops!  That doesn'​t work, because $Z would be expanded at the time that the
 +[[defer]] is run, which might be much earlier than the echo.  You can double
 +up the $'s again to prevent the expansion at defer-time:
 + timer 120 echo $$$$Z
 +
 +This is just a simple example of how crazy it can get.  This is //by no means//
 +the most obtuse example I could come up with.
 +
 +=====More coming later:=====
 +This document is very much a work-in-progress
  
quoting_hell.txt ยท Last modified: 2007/07/10 21:03 (external edit)