Or Alternative #3:

$order/coupon-code/lookup-coupon-code(.)


Date: Tue, 10 Jan 2012 21:29:18 +0000
From: hren...@yahoo.de
To: general@developer.marklogic.com
Subject: Re: [MarkLogic Dev General] sequence type matching - bug (?)

Hi Ron,
 
thank you very much for illustrating the potential usefulness of function 
mapping!
 
Certainly this is a matter of personal taste, but just this remark: although 
the use of function mapping makes the code especially compact, I definitely 
prefer the FLWOR alternative (or the function step alternative), which makes 
looping explicit and thus avoids the risks of unintended looping and (worse) of 
unintended omission of processing. I think the code is safer and, yes, cleaner, 
if one remembers that function mapping depends on the repective parameter to be 
declared as a single item sequence type, which means that the function 
invocation cannot be recognized to be a mapping invocation: the parts producing 
the looping are separate, one being the invocation, one being the signature. I 
regard this as a kind of obscurity better to be avoided.
 
And the difference in code length is minimal:
 
alternative #1 (function mapping)
lookup-coupon-code ($order/coupon-code)
 
alternative #2 (FLWOR)
for $c in $order/coupon-code return looup-coupon-code($c)
 
Hans-Juergen
 
Ron wrote:
"Function mapping can actually be very handy, youshouldn't just automatically 
turn it off and forget
about it."
 
_______________________________________________
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general                         
                  
_______________________________________________
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to