[bitc-dev] lexical scoping and first class functions?

Greg Buchholz bitc at sleepingsquirrel.org
Mon Dec 5 19:23:44 EST 2005

A couple quick questions.  From the BitC spec...

    In contrast to ML, BitC syntax is designed to discourage currying.
  Currying encourages the formation of closures that capture non-global
  state. This requires dynamic storage allocation to instantiate these
  closures at runtime. Since there are applications of BitC in which
  dynamic allocation is prohibited, currying is an inappropriate idiom 
  for this language.

...with that in mind, what does the following program (forgive the
Scheme syntax) mean...

> (define foo
>   (lambda (n)
>     (lambda (x) (* n x))))

...When invoked, does it allocate a closure on the heap like in a
lexically scoped language?  Is BitC lexically scoped?  Is the example
completely invalid because of the dynamic allocation issue?  Is there
some malloc/free function calls that could be inserted to make it valid?
A more basic question is "Are functions first class values?"  Section
7.8 doesn't make that clear.  

    And on a side note, I assume the "lambda" keyword is for
semi-historical reasons.  Has any thought been given to changing it?
("fn" from Arc for example, or maybe eliminate the keyword altogether by
using square brackets or some-such.  [(a b c) (+ a (* b c))] maybe?)


Greg Buchholz

More information about the bitc-dev mailing list