Arc Forumnew | comments | leaders | submitlogin
3 points by almkglor 5836 days ago | link | parent

Then use 'eval :

  (ontable k v h
    (eval `(= ,k ,v)))
Note that this does not copy to the current environment, just the global environment. So if you're doing something like this:

  (let foo 42
    (= h (table 'foo 1)) ; Anarki only
    (ontable k v h
      (eval `(= ,k ,v)))
    foo)
Then the 'foo you access is the local one, but the one written by 'eval is the global.


3 points by absz 5836 days ago | link

Careful! You're evaluating the value of v here, which can break:

  arc> (ontable k v (table 'var 'a)
         (eval `(= ,k ,v)))
  Error: "reference to undefined identifier: __a"
You need to quote the value of v here to prevent it from being evaluated; when you do so, you get

  arc> (ontable k v (table 'var 'a)
         (eval `(= ,k ',v)))
  #hash((var . a))
  arc> var
  a
And then the body of he loop is the same as the body of my assign function from http://arclanguage.org/item?id=6918.

-----

1 point by almkglor 5836 days ago | link

This is correct ^^

-----

2 points by zhtw 5836 days ago | link

> Note that this does not copy to the current environment, just the global environment.

Yeah, I'm aware of that. But it's a good point anyway, thanks.

-----