Curl macros introduction (part 4) - Printable Version +- Curl Global Community (https://communities.curl.com) +-- Forum: Blogs (https://communities.curl.com/forumdisplay.php?fid=17) +--- Forum: Tech blog (https://communities.curl.com/forumdisplay.php?fid=18) +---- Forum: Robert blog (https://communities.curl.com/forumdisplay.php?fid=20) +---- Thread: Curl macros introduction (part 4) (/showthread.php?tid=198) |
Curl macros introduction (part 4) - RobertShiplett - 08-10-2011 A Curl macro that accepts expressions: {ndashe } As you might guess, {ndashe } links Strings from two expressions with a so-called n-dash or Unicode UTF-8 code point 2013 which is the Curl char represented as '\u2013'. The changes are as follows: Code: {define-macro public {ndashe ?e1:expression , ?e2:expression} and if we now test with Code: {let public str1:String = "this", str2:String = "these"} what we will see is On the web page Curl Wrote:We ndashe'd THIS–THESE One subtle change was required: the "hyphen" could not be used in the macro because it cannot separate two expressions as it is itself used as an infix operator for a {subtract } expression. Even if it seemed cute to use the hyphen, most often the comma will be your best choice. But why would we want {ndashi } or {ndashe }? Wouldn't we want an {endash } macro to accept such curl source or text as we pass in? For that we will need patterns and the Curl {syntax-switch } macro. |