Author Login
Post Reply
I am wondering about whether it is better to use closures or functions
in scripts, and whether there are extant "best idioms".
Take for example drawing the von Koch Snowflake -- basic recursive
fractal curve, so uses recursion for implementation (well there are
other ways but recursive is probably the easiest). Using closures you
get:
def smallestLine = 1.0
def vonKochCurve
vonKochCurve = { g -> . . . }
etc, etc. Using functions, you have to use the binding because of the
(in my view) inconsistent and counter-intuitive scope rules:
smallestLine = 1.0
def vonKochCurve ( g ) { . . . }
I guess the question is what do people consider the better coding style
and why?
Thanks.
--
Russel.
====================================================
Dr Russel Winder Partner
Concertant LLP t: +44 20 7585 2200, +44 20 7193 9203
41 Buckmaster Road, f: +44 8700 516 084
London SW11 1EN, UK. m: +44 7770 465 077

Attachment:
signature.asc (zipped)