racket / redex

Other
89 stars 35 forks source link

[RFC] merge [some|all] of unstable/gui/redex into redex #150

Open pnwamk opened 6 years ago

pnwamk commented 6 years ago

I personally constantly use the following definitions from unstable/gui/redex when using redex:

binary-rw
prefix-rw
postfix-rw
function-rw
constant-rw
bracket-rw
set-cons-rw

Is there any desire to merge some/all of unstable/gui/redex into redex proper? Or is there a different approach that should be used towards making better high-level abstractions that aid in rewriting?

rfindler commented 6 years ago

I like the api of all of those.

Do they actually work when there are multiple lines involved? I think getting that right is tricky, so if there is any doubt at all, I'd prefer a dynamic check that raises an error when the arguments span multiple lines (and then, in a separate pass, we can work out what to do and what new keyword arguments should be added to help control the options in those cases)

pnwamk commented 6 years ago

Oops -- I left off splice-rw which is also a simple/useful one IMHO.

pnwamk commented 6 years ago

Through some quick experimentation (i.e. I haven't checked the code) I did not seem to get any errors with multi-line input on any of those forms (but for a few, not raising an error seemed like the expected behavior to me):

Do the following error on multi-line input?
-------------------------------------------
binary-rw   - no
prefix-rw   - no (okay?)
postfix-rw  - no
function-rw - no (okay?)
constant-rw - no (okay?)
bracket-rw  - no (okay?)
set-cons-rw - no
splice-rw   - no
rfindler commented 6 years ago

No, that's not what I'm saying. I'm not saying that they will raise errors. I'm saying that there is no one-best right behavior for multi-line inputs and so I would prefer to not be constrained with backward-incompatible changes that fix these functions.

As for splice-rw, that one seems strange. I do not understand what the docs mean.

pnwamk commented 6 years ago

I see -- that makes sense.

splice-rw drops the leading symbol and the parens from the form, e.g. if could be used to typeset (typeof Γ ⊢ e : τ) as Γ ⊢ e : τ

rfindler commented 6 years ago

It replaces them with ""?

pnwamk commented 6 years ago

Um... I could be mistaken but it looks to me like it literally just drops them from the lw:

(define (splice-rw)
  (compound-rw 'splice-rw
    (lambda (lws)
      (drop-right (drop lws 2) 1))))

(that code from here)

rfindler commented 6 years ago

Oh, that's just wrong, then.