Bill Allombert on Wed, 31 May 2006 17:43:14 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: What happened to 'local'?


On Wed, May 31, 2006 at 05:18:42PM +0200, Karim Belabas wrote:
> 
> What makes you think it has disappeared ?
> 
>   (17:14) gp > test(x)={local(a);a=x+1;return(a)}
>   (17:14) gp > test(12)
>   %1 = 13
>   (17:14) gp > a
>   %2 = a
> 
> Btw the braces are not necessary for 1-liners:
> 
>   test(x) = local(a);a=x+1;return(a)
> 
> would work just as well.

This is true but I would like to deprecate this construct and require
the braces unless the body is a single expression like in:

test(x) = x^2+1

So I would urge 2.3 users to get ready to the fact that 2.5 might not
accept 'test(x) = local(a);a=x+1;return(a)' as valid.

Allowing the contrust 'test(x) = local(a);a=x+1;return(a)' has several
nasty side-effect (line breaks significant, subfunctions body are
ambiguous) and make parsing the grammar significantly harder. 

Cheers,
Bill.