Arc Forumnew | comments | leaders | submitlogin
2 points by rntz 5624 days ago | link | parent

filltbl isn't a macro, nor does it affect the global namespace. As written, it just creates a table if its first arg is nil. Of course, this is useless unless it returns that table... oops.

    (def filltbl (tbl keys vals)
      (or= tbl (table))
      (map (fn (k v) (= tbl.k v)) keys vals)
      tbl)
IMO, a more idiomatic way to represent this would be to use optional arguments, although that requires altering the argument order:

    (def filltbl (keys vals (o tbl (table)))
      (map (fn (k v) (= tbl.k v)) keys vals))
      tbl)


1 point by thaddeus 5624 days ago | link

yeah I tried passing nil in, and got nothing back, so I figured it was supposed to create the table - I should have seen that too.

-----

1 point by adm 5623 days ago | link

Can this be part of arc.arc?

-----

1 point by shader 5623 days ago | link

You could push it onto Anarki. Other than that, there isn't much you can do to get it into a public arc.arc. It seems that if a function isn't used in the forum code, pg doesn't include it in the official release.

-----