Arc Forumnew | comments | leaders | submitlogin
1 point by almkglor 5923 days ago | link | parent

Someone still has to write the function 'matrix, and it still has to look like that.


2 points by jivestgarden 5922 days ago | link

It´s not so difficult as it looks: is is just a function that returns a function that returns a function. If you are used to object orientation, think of matrix as instansiation, m as an object, and the returned setter as a method. With the arc abbreviations, you could also write (m.settersym val 0 0) rather than having to modify =, but personally I would like to have some setter macro to make the syntax more natural (By the way: this is exactly how you would do a matrix implmentation in C++, only with templates in stead of macros)

-----

2 points by almkglor 5922 days ago | link

I am concerned about how it looks, which is my main objection to this.

-----

1 point by nex3 5922 days ago | link

You could always define a macro to abstract out the nastiness...

-----

1 point by almkglor 5922 days ago | link

^^ Again, somebody has to write the nastiness ^^. The main difficulty really is the fact that you have a polymorphic function that dispatches based on number of parameters as well as their contents.

Although I suppose you could actually use --warning-blatant-self-proclamation-- my p-m: macro:

  (p-m:def matrix
    (,(s (is s settersym)))
      writerfunction
    (i j)
      (readerfunction i j)
    x (err "argument error"))

-----