[Omake] Higher-order functions with "export transparency"?

Aleksey Nogin anogin at hrl.com
Thu Oct 25 12:16:26 PDT 2007


On 25.10.2007 11:10, Jason Hickey wrote:

> In old-0.9.9.x, private exports succeed iff the two (or more) contexts
> are in the same static scope, like "f" above.  That is, exporting from
> an inner static scope to an outer one is allowed.  Exporting private
> variables between unrelated static scopes fails (unless written
> explicitly).

I agree that this is the best semantics (and perhaps we'd even want to
implement a "strict" version, where an explicit export into an unrelated
scope is an error - if one want a variable to go into a parent scope,
then it either needs to be declared in that scope, or it should not be
declared private).

But what about HO functions that are themselves in an unrelated static
scope, but "need" (sort of) to be able to "transport" from different
parts of the same scope. Consider:

Sequence. =
    ...
    curry.foreach() =
       private.THIS = $(this)
       g(f) =
          export
          sequence-map($(THIS), $f)

A[] = 1 2 3
f(s) =
   A.foreach(i) =>
      s = $(add $s, $i)
      export s
   return $s

The issue here, of course, is not the second export (where we can be
explicit, if we had to), it's the first one. The simple rule of
"exporting from an inner static scope to an outer one is allowed" would
only help if we also allowed exporting from an inner static scope to an
outer one through an unrelated intermediary scope!

As I said at the end of my previous message, I am starting to suspect
that the real problem is that the foreach concept is simply _not_
expressible as a HO function - all our attempts to make it into a HO
function keep making us consider adding more and more features to the
language (curry, private exports, etc). I thing that Python got it
right, making the "for" iteration a built-in concept in the language
(_not_ a function call) and instead of adding a "foreach" method to an
object, they add an "__iter__" method to it, which only describes how to
get the elements out one by one, not how to actually iterate.

Aleksey

-- 
Aleksey Nogin, Research Scientist
Advanced Technologies Department, Information & System Sciences Lab
HRL Laboratories, LLC, Malibu, CA


More information about the OMake-Devel mailing list