Arc Forumnew | comments | leaders | submitlogin
1 point by shader 5641 days ago | link | parent

As long as they use the same symbol table, putting them into the same sig, src, and fns tables makes logical sense.

Realistically, src should be defined for '= (presuming you could discriminate for global symbols), and all of them redefined for every assignment macro that uses the global symbol table.

Unfortunately, it can't work for all def* forms, because some of them save their functions to different tables. For example, defop saves its functions to the srvops* table, so adding those functions to the 'sig table could result in name collisions.

Is it possible to make temporary changes to variables/hash tables? Suppose I wanted '= to save the assignment code "(= place value)" to a table using place as the key, but I only want that change to be valid for the current scope. For example

  arc> (= a 42)
  42
  arc> src.a
  (= a 42)
  arc>(let b 16
        (= a b)
        src.a)
  (= a b)
  arc> src.a
  (= a 42)
Is that possible? The idea would be to do the same thing for def and mac so that you can know the current definition of any symbol.


1 point by CatDancer 5641 days ago | link

You could extend the compiler to save/restore information when a scope is introduced.

In your example though, at the end, 'a is set to 16, but you're reporting that its source is "(= a 42)". Is that what you want?

-----

1 point by shader 5641 days ago | link

whoops, good point. I was intending to make a a new local variable and redefine it using '= to a new value. In that case, the value of a would obviously be local, so redefining its source in the global table would obviously not make sense.

The problem with save/restore is that it isn't thread safe. Hmmm.

-----