Dan Sugalski <[EMAIL PROTECTED]> wrote:

> Since PIR behaviour is ours to define, it can do whatever we want.
> I'm inclined to rule that a plain

>     bar()

> is equivalent to:

>     current_namespace::bar()

> and as such the PIR compiler should look up the function by name in
> the current namespace and then invoke it.

Ok. So this "bar" is overridable by putting another Sub object into the
"bar" slot of the namespace, I presume...

> Since invoking a sub in the current file's also useful and something
> we do (I'm making heavy use of it. It's nice :) I can see having
> alternate syntax for it. Perhaps:

>     :bar()

> looks for the bar sub in the current namespace in the current file
> and invokes it, skipping any sort of by-name lookup or runtime sub
> overriding.

... while this one would reflect the current static behavior of subs
defined in the current namespace, which translates just to a constant
table lookup:

   set_p_pc  Px, the_sub_PMC_named_bar

> (And yeah, I suggest this even though it'd mean rewriting some of my
> compiler's codegen code)

> Any semantics past these (simple lookup by name, and simple
> compiletime lookup) should be delegated to the individual language
> compilers, and they can emit code to do whatever oddball things they
> may need to do, though I'm not sure there's a whole lot more that'd
> need to be done for most languages. (Especially since namespaces are
> supposed to be lexically and dynamically overridable, as well as
> layered, but that's all a separate thing)

Currently a C< bar() > function call shortcut emits:

  Px = find_name "bar"

when "bar" isn't known in the current namespace, which looks into
lexicals, globals, and builtins in that order.

> -- Dan

leo

Reply via email to