Arc Forumnew | comments | leaders | submitlogin
2 points by akkartik 5142 days ago | link | parent

Hmm, here's an idea for lightweight namespacing. Let's create a second-class function:

  (def foo(a) :inner
    ...)
Now you can suppress the redefinition warning when a def redefines an inner.

That seems to help the problem of proliferating helper functions that fallintothis brought up (http://arclanguage.org/item?id=11996). It lets you keep helpers in the namespace without them getting in the way. And if you just don't want them polluting your namespace at all, I think you suffer from programmer's OCD :)



1 point by rocketnia 5142 days ago | link

If "a def redefines an inner," won't that still break whatever depended on that inner?

Maybe a def should shadow an inner? In my pursuits, I've been thinking about something vaguely like http://c2.com/cgi/wiki?HyperStaticGlobalEnvironment (which I got to from http://lambda-the-ultimate.org/node/3991), where definitions essentially replace the binding, leaving the previous binding intact for whatever closures captured it. I'd go farther than that: I'd have certain operations just replace the environment entirely by shadowing variables, etc., usually putting the old environment somewhere we can get to it again.

Also, in my mind closures in this hyper-static approach should automatically define any not-yet-defined free variable bindings they need as they're created. This approach requires the default kind of definition to be set!, so that the not-yet-defined bindings don't just get shadowed instead of defined. That means it's hardly a hyper-static philosophy at all; it's just an approach that use hyper-static capabilities where it needs to for namespacing (and in order to access them, there's likely to be boilerplate).

Sorry, this is sort of a ramble, I know. I don't have a lot of time right now to clean it up. ^_^;

-----

1 point by akkartik 5142 days ago | link

"If "a def redefines an inner," won't that still break whatever depended on that inner?"

Eep, you're right. I think I want something like this:

  > (= innerdef mac)
  > (innerdef foo() 3)
  > (def bar() (foo))
  > (bar)
  3
  > (def foo() 2)
  > (bar)
  3
Would that always work? It wouldn't let bar be defined before foo, which I still kinda care about. (http://arclanguage.org/item?id=12668) That's the problem with the hyperstatic idea as well (thanks for the link, btw.)

Or perhaps we should just have an explicit undef. Heh, I want to rename def back to defun just so undef is a rotation of defun.

-----