Arc Forumnew | comments | leaders | submitlogin
1 point by fallintothis 5445 days ago | link | parent

Rather random thing to comment on after 2 weeks, I know. I was just reading this and noticed that your redef macro isn't really doing much: safeset doesn't get called by = unless you happen to make a defset to that effect, which seems unlikely.

  arc> (def f (x) (+ x 1))
  #<procedure: f>
  arc> (= f [+ _ 2])       ; no redef warning
  #<procedure: f>
  arc> (def f (x) (+ x 3)) ; redef warning
  *** redefining f
  #<procedure: f>

  arc> (defset blah (x)
         (w/uniq g
           (list (list g x)
                 x
                 `(fn (val) (safeset ,x val)))))
  #<procedure>
  arc> (= x 100)
  100
  arc> (= x 200)        ; no redef warning
  200
  arc> (= (blah x) 300) ; redef warning
  *** redefining x
  300
Still an interesting idea to selectively silence safeset, though.


1 point by akkartik 5443 days ago | link

Ah, that's embarrassing :)

So all I need is this then without any change to safeset:

  (mac redef(f args . body) `(= ,f (fn ,args ,@body)))

-----

1 point by fallintothis 5443 days ago | link

Right. So then after-exec becomes (keeping the presumably-intended variable capture)

  (mac after-exec (fnname args . body)
    `(let old ,fnname
       (redef ,fnname ,args
         (let result (old ,@args)
           ,@body
           result))))
And your uses of redef when you aren't redefining a function should be changed to = (e.g., in shadow).

It might still be cool to toggle safeset warnings. With Arc's single namespace, it's annoying to

  (load "foo.arc")
just to have it spit out redefinition warnings. But silencing safeset isn't really the answer to that problem.

-----

1 point by akkartik 5443 days ago | link

Yes. When I updated anarki I decided to just do

  (= redef =) ; how pretty!
It seems plausible to want redefs to look different from defs.

Disabling these warnings on reload is useful, but a separate use case. I tend to ignore them on reload, but I don't want to see them when I startup lest I start ignoring them altogether.

-----