2009/12/7 <[email protected]>:
> Hi folks,
>
> Here is a proposal for a Cajita auditor for purely functional values:
>
> 1. All transitively frozen JSON values are functional.
Some values that are not representable in JSON but that are probably functional:
NaN, +/-Infinity, undefined, Dates.
> 2. All function values are born frozen, so they are functional *as values*.
So functional code can't call functions, but can pass function objects around?
> 3. The compiler can conservatively annotate certain functions as
> purely functional. This will miss some cases, but again, this is
> conservative. Perhaps we can add some annotation for programmers to
> ask the compiler to treat failure to verify as an error, like:
>
> var f = /*...@functional*/ function(x, y) { ... };
>
> 4. At runtime, any frozen data structure containing only functional
> values as described above can pass a functional auditor, and the
> decision can be memoized on the value.
> Does this work?
What is the definition of functional? That evaluating it has no side effect?
Functions capture the lexical environment in which they're defined and
capture "this", so it's not pure, as the "purely" in "purely
functional" above might suggest.
> Ihab
>
> --
> Ihab A.B. Awad, Palo Alto, CA
>