[nem-en] nested local fun with same name

Kamil Skalski kamil.skalski at gmail.com
Fri Mar 23 15:21:16 CET 2007


def f (....

is always redefinition of existing symbol as function, so:

2007/3/23, Dmitry Ivankov <divanorama at gmail.com>:
> What are the rules for local functions with the same name?
> 1) Can there be 2 functions at the same level? (seems that it's true)
> Like
> def f () {};
> ..
> def f () {smth};

Yes, only second is available at the end

> 2) Can we do "def x=..; def x = x + 1" with functions?
>  Like
> def f () {};
> def f () { f(); smth }; //for now it's infinite loop

Yes, it is correct behavior

> 3) Can we "def f (){} and f (x){} and g (){};"? Choosing function by number
> of arguments.

No - we do not support overloading of local function

>  4) Almost the same as 3, but with nested functions
> def f (x,y) {
>  def f (x) { f (x, y); } //it won't compile, but  def f = fun (x) { f (x,
> y); }  will work as supposed
>  if (x == 0)
>   y
>  else
>   f(x - 1) + y
> }
>
>

def f   always redefines symbol

> _______________________________________________
> https://nemerle.org/mailman/listinfo/devel-en
>
>


-- 
Kamil Skalski
http://nazgul.omega.pl



More information about the devel-en mailing list