Arc Forumnew | comments | leaders | submitlogin
html2.arc (github.com)
2 points by evanrmurphy 5068 days ago | 4 comments


2 points by waterhouse 5068 days ago | link

Looking over this quickly, question: You use a variable, html-nestlev, inside a closure as a sort of hidden global variable, and use it to indicate the depth of quoting... What happens when an error or ctrl-C happens in between an (html-openq) and (html-closeq)? That might be worth handling. You might try Racket's parameters, or have a function that resets the thing.

Also, you ask in a comment: "way to warn not on stdout?" If stderr suffices for this, you might like this:

  (mac to-stderr body
    `(w/stdout (stderr) ,@body))
which "warn" should probably really be defined with. And if you might like to redirect stderr somewhere (like a log file), I recommend you add these lines to ac.scm, near "xdef call-w/stdout" and "call-w/stdin":

  (xdef call-w/stderr ;why wasn't this included?
        (lambda (port thunk)
          (parameterize ((current-error-port port)) (thunk))))
And then use this:

  (mac w/stderr (x . body)
    `(call-w/stderr ,x (fn () ,@body)))

-----

1 point by evanrmurphy 5068 days ago | link

Thanks. I started to use your to-stderr when I noticed this similar function in arc.arc:

  (def ero args
    (w/stdout (stderr) 
      (each a args 
        (write a)
        (writec #\space))
      (writec #\newline))
    (car args))
I'll probably use it instead just to keep this lib's dependencies to the arc3.1 core. I agree it would make sense to have call-w/stderr in ac.scm, though.

> You use a variable, html-nestlev, inside a closure as a sort of hidden global variable, and use it to indicate the depth of quoting... What happens when an error or ctrl-C happens in between an (html-openq) and (html-closeq)? That might be worth handling. You might try Racket's parameters, or have a function that resets the thing.

Really good point. Need to think about this more, as I'm feeling doubtful about that whole part of the program relating to nested quotation.

Update: For those just tuning in and looking for the variable html-nestlev in the source, it's been renamed to nestlev.

-----

2 points by aw 5068 days ago | link

I wonder if warn should print on stderr, I can't see how that would break anything.

-----

1 point by evanrmurphy 5068 days ago | link

This is the little html lib I presented in http://arclanguage.org/item?id=12010. I've started developing it again and put it under version control.

-----