Arc Forumnew | comments | leaders | submitlogin
1 point by jazzdev 5166 days ago | link | parent

> Jazzdev, where is the 'pr behaviour problematic?

I'm writing an HTML package. I'd like it to work as follows:

  (html
    (body
      (somesetup)
      "Some text"
      (pr "Some more stuff")
  ))
I'm experimenting with the idea that calling pr shouldn't be necessary, so the tag expansion eval's everything and if it gets back something non-nil then it pr's it. I'd like to still allow pr to work also, but since it returns non-nil then some things get output twice.

I want the user of the HTML package to use standard stuff, so having prnil is awkward. Allowing pr inside these tags isn't necessary. I'm just playing around and trying to see what feels natural to use.

Using pr to print something without changing the semantics of a functional program makes sense in theory, but in practice it doesn't see useful. Have you ever actually done it?



1 point by conanite 5165 days ago | link

One way to make this possible is to have your 'html macro (I'm assuming it's a macro) unhygienically provide a lexical binding for 'pr for its body

  (mac html body
    `(do (pr "<html>")
         (let pr prnil ,@body)
         (pr "</html>")))
That way your callers can use 'pr like they're used to, but secretly and subversively you have them calling your own private pr function.

-----

1 point by jazzdev 5165 days ago | link

That's a clever way to do it. Thanks.

-----

1 point by palsecam 5165 days ago | link

> I'm experimenting with the idea that calling pr shouldn't be necessary

You may like that idea: http://arclanguage.org/item?id=11048

-----

1 point by jazzdev 5165 days ago | link

Yep. I'm trying to do the same thing. I need to follow this forum more regularly.

-----