X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSub%2FQuote.pm;h=d067e2a2e1a68c42471e4d59534614f0296ff801;hb=9c8204612cac46da05778bf98efa6b45ae91c62b;hp=8567d786a544d4f0f29ccdde7f80dea85f641e0e;hpb=0689a5ab016832be48d8e1b724f42a31ac8a0947;p=gitmo%2FMoo.git diff --git a/lib/Sub/Quote.pm b/lib/Sub/Quote.pm index 8567d78..d067e2a 100644 --- a/lib/Sub/Quote.pm +++ b/lib/Sub/Quote.pm @@ -220,3 +220,34 @@ arguments. Generates a snippet of code which is suitable to be used as a prelude for L. The keys are the names of the variables and the values are (duh) the values. Note that references work as values. + +=head1 CAVEATS + +Much of this is just string-based code-generation, and as a result, a few caveats +apply. + +=head2 return + +Calling C from a quote_sub'ed sub will not likely do what you intend. +Instead of returning from the code you defined in C, it will return +from the overall function it is composited into. + +So when you pass in: + + quote_sub q{ return 1 if $condition; $morecode } + +It might turn up in the intended context as follows: + + sub foo { + + + do { + return 1 if $condition; + $morecode + }; + + + } + +Which will obviously return from foo, when all you meant to do was return from +the code context in quote_sub and proceed with running important code b.