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

Assuming the only case we care about is function name aliases, I've pushed out the following simpler version to my repo (https://github.com/akkartik/arc/commit/fe21a3456fc7e69fc6ec1...)

  (mac alias(f g)
    `(= ,f (fn args
             (apply ,g args))))
For example, compare using =:

  > (= be iso)
  > (be 3 3)
  t
  > (= iso +)
  > (be 3 3)
  t ; didn't get new iso
..with alias:

  > (alias be iso)
  > (be 3 3)
  t
  > (= iso +)
  > (be 3 3)
  6 ; got new iso
So now I have two questions:

a) Do we need to handle rhs being anything more complex than just a symbol?

b) Neither your late nor my simplified version seem to work with macros. Is it possible to get alias work with macros?



2 points by rocketnia 4870 days ago | link

I was going to call that '=late. ^_^ There are still other cases where a global function can end up stored somewhere it doesn't stay up-to-date with the variable binding, like storing it as a behavior in a data sructure or using (compare ...). But I don't expect to need anything more brief than 'late, actually.

It's funny, I hadn't settled on the name 'late until I posted it here, and before that point I was thinking of it as 'alias. ^_^ I wanted to avoid confusion with Racket's aliases, so I changed it at the last second.

macros?

Macros generally aren't hackable anyway, right? I don't have any ideas to change that.... Well, except these I guess. :-p

a) Change the whole language over to fexprs. This is probably the most elegant way to make things hackable, but it'll probably be inefficient without a convoluted partial evaluation infrastructure (ensuring things are free of side effects, and headaches like that ^_^ ).

b) Record which macros are expanded every time a command is evaluated, and re-run commands whenever their macros change. Running commands out of order and multiple times would be pretty confusing. (I bet there'd be ways to manage it, but I for one would forget to use them at the REPL.) It would also be easy to fall into an infinite loop by trying to redefine a macro using a command that actually uses that macro.

-----