Arc Forumnew | comments | leaders | submitlogin
1 point by bogomipz 6157 days ago | link | parent

What happens to arg in (defp sum^mul (arg) ... ) ?

Wouldn't it be better if the function was to be called like this?

  (sum^mul '(126 9) 90) => 1224
  (sum^mul 7 134) => 141
  (sum^mul 13) => 169


1 point by araujo 6157 days ago | link

I really had thought of getting something apparently cleaner , like the syntax you are proposing. At the end I decided it'd be better to preserve an 'argument' field to clearly indicate that it is a function-like definition and we need to pass an argument to it , something more like a spec:

   (sig 'sum^mul) => (arg)
Besides being a good visual indicator, it also plays a role inside the macro definition , this is the variable containing the value to be matched against the different patterns internally, so in this case, such a variable is actually needed too.

Pattern-matching operates over 'data structures' , that is why we need to pass lists (or another structure) to the function. I think there is no need to increase complexity on this, or probably creates confusion about it.

-----