[Nickle]Scoping rules for declarations

Barton C Massey nickle@keithp.com
Tue, 29 Jan 2002 16:40:02 -0800


Good question, and points up that we sometimes made
decisions to be more C-like than functional.  For mutually
recursive declarations you can write something like

  (int(int)) g;
  int function f(int x) {
    if (x > 0) return g(x-1);
    return 0;
  }
  g = (int func(int y) { return 1 + f(y); });

which will be properly statically and dynamically
typechecked and do what you want.  Of course this isn't
quite what you asked for, nor is it terribly clean.  We
could probably add a letrec-like syntax, e.g.

  letrec int function f(int x) {
    if (x > 0) return g(x-1);
    return 0;
  },
  int function g(int y) {
    return 1 + f(y);
  };

but I'm not very fond of this solution: it's not obvious to
me it's enough better to be worth complicating the language
for.  If we saw a lot of "pure-functional" Nickle code, or
someone proposed to write same, I'd probably change my mind.

As far as nested, I'm not sure what you're after.  The rules
for nested scope are the "obvious" static scoping rules...

Does this help, or should I say more?  Keith, have I missed
anything?

	Bart

In message <004801c1a921$ab3f93d0$6501a8c0@meurglysvii> you wrote:
> A question to nickle authors:
> 
> What are the scoping rules for nickle declarations: how can I
> get simultaneous, nested, and mutually recursive declarations?
> The man page is not very clear on this.
> 
> Thanks,
> Sergei
> 
> 
> 
> 
> _______________________________________________
> Nickle mailing list
> Nickle@keithp.com
> http://keithp.com/mailman/listinfo/nickle