rhombus-prototype icon indicating copy to clipboard operation
rhombus-prototype copied to clipboard

Quasicomment?

Open sorawee opened this issue 4 years ago • 6 comments

Not sure if it's a good idea, but sometimes I want to comment (a (b) c) out, but want to leave (b) uncommented. Currently, I would comment the whole thing (with #;) and then make another copy of (b). With quasicomment, inspired by quasiquote, I would be able to write:

#;(a #+(b) c)

or something like this.

(also not sure if this still makes sense in non S-exp land).

sorawee avatar Oct 05 '19 00:10 sorawee

Have you ever used this before in another language? I would be worried that I'd forget to uncomment, or forget that I did not comment out everything. Even now I find myself forgetting to uncomment some parts after commenting them out for debugging.

MarcKaufmann avatar Oct 18 '19 08:10 MarcKaufmann

It definitely shouldn't be the default method of commenting. There are situations where it would be useful, so as a separate form of comment it may be worth it.

AlexKnauth avatar Oct 18 '19 12:10 AlexKnauth

Add an use case for this kind of commenting:

For example:

(define testo
  (λ (x)
    (onceo
     (conde
      ((== 'tea x) succeed)
      ((== 'cup x) succeed)
      (else fail)))))

I'd like just to comment the onceo.

The effect is a bit like:

(define testo
  (λ (x)
    ;; (onceo
     (conde
      ((== 'tea x) succeed)
      ((== 'cup x) succeed)
      (else fail))
     ;; )
    ))

"paredit" can raise a sexp though, not comment.

chansey97 avatar Apr 21 '21 20:04 chansey97

For such cases usually I just do:

(define testo
  (λ (x)
    (values ;onceo
     (conde
      ((== 'tea x) succeed)
      ((== 'cup x) succeed)
      (else fail)))))

#; would in principle be better than ; but it breaks the indentation in DrRacket at least.

Metaxal avatar Apr 21 '21 20:04 Metaxal

@Metaxal It makes the code less readable imo.

The original purpose was just to comment, now a new construct values has been introduced.

chansey97 avatar Apr 21 '21 21:04 chansey97

values isn't a new construct, it defines a multiple value return (which in this case is a single value) and in this case acts as a no-op so that your indentation doesn't change. This approach would fail if onceo took more than one argument.

tgbugs avatar Apr 21 '21 21:04 tgbugs