Arc Forumnew | comments | leaders | submitlogin
2 points by Pauan 5101 days ago | link | parent

By the way, I just found this CL function:

http://www.lispworks.com/documentation/HyperSpec/Body/f_fn_l...

Which does something similar, but in a non-mutable way. It also requires some additional parsing, because it conflates the argument list and the body together. It's also using multi-value return. Assuming `function-lambda-expression` was available in Arc (but renamed to 'get-fn-attributes), the following two would be equivalent:

  ; function-lambda-expression
  (let '((nil arguments . body) environment) (get-fn-attributes foo) ...)

  ; message passing
  (let '(arguments body environment) foo ...)
Hurray, attribute destructuring! And, there are two more benefits to my approach:

1) Mutability. If we're destroying information hiding by making the information available in the first place, might as well make it mutable too, right? Better than adding in a `set-fn-attributes` function...

2) It makes it a lot easier if you only want to access one of the bits of information. Observe:

  (let body '((nil nil . body)) (get-fn-attributes foo) ...)

  (let body foo<-body ...)
As far as I can see, the only benefit to `get-fn-attributes` is if you want to use really short variable names:

  (let '((nil a . b) e) (get-fn-attributes foo) ...)

  (with (a foo<-arguments b foo<-body e foo<-environment) ...)
I generally prefer accessing data by key rather than by index. Seems more concise and robust to me.

On the other hand, lists are nice because they preserve their order, they're shorter and easier to create than tables, and they're less complex.

But, we're talking about the core here, so I'm gonna stick to tables for the core datatypes, until I see a better idea.

</dead horse beating>