Arc Forumnew | comments | leaders | submitlogin
stdout vs. return values (re: html.arc)
1 point by evanrmurphy 2715 days ago | 2 comments
There's been discussion [1, 2] about html.arc's (peculiar?) construction around stdout rather than function return values. I've been increasingly aware of the problems this poses in my projects and have been considering reworking my html.arc [3] to use return values instead. Before I get too invested in that though, does anyone think I'm chasing a windmill? I think there's pretty broad agreement about the benefits of programming in the functional style in general, but could there be something about html.arc's particular role that makes it unsuitable? If not, then why wasn't it designed that way in the first place? (Are there some real benefits to the stdout-based approach?)

Recap: I want to reconstruct html.arc around return values rather than stdout. If I'm running toward a dead end or in the wrong direction and you know it, save me! :P

[1] http://arclanguage.org/item?id=5565

[2] http://files.arcfn.com/doc/html.html

[3] http://arclanguage.org/item?id=12010



3 points by shader 2715 days ago | link

By printing directly to stdout you don't get to have as many tail calls, but you don't have to worry about much complexity when it comes to aggregating output or adding new functionality. A simple pr is all it takes to add output, and you don't need to worry much about context.

One alternative is functions that take lists as input, and cons in their own output before passing them on to the next level. Then use a final translation function that walks the tree converting it to text using something like the sml parser. Unfortunately this means you have to walk the code twice, once for content generation and once for output transformation.

The pros of the first system are simplicity, efficiency, and compatibility with a socket based web server (just redirect stdout to the socket)

The second system has the advantage of decoupling content from presentation at the cost of complexity managing aggregation, and walking the tree twice.

-----

1 point by shader 2715 days ago | link

Btw, I found almkglor's whtml.arc: http://github.com/nex3/arc/blob/arc2.master/whtml.arc

There's a lot of good stuff that apparently got left behind in the old arc2 branches.

-----