Arc Forumnew | comments | leaders | submitlogin
1 point by akkartik 4459 days ago | link | parent

  var name "Martin"
  cond
    (name equals "Martin") (print "You are a fool.")
    (name equals "Frodo")  (print "You like saved everyone.")
    (name equals "Alex")   (print "You rock.")
"..somewhat less ugly from what they would be in regular lisp owing to one set of parentheses being removed in bullet w.r.t lisp, but parentheses still abound.."

There's more to aesthetics than sheer number of parens. I would argue that lisp's cond is ugly primarily because it puts conditions and actions on a single line.

Here's how I write it in wart:

  (if
    (iso name "Martin")
      prn "fool"
    (iso name "Frodo")
      prn "savior"
    (iso name "Alex")
      prn "rocks"
    :else
      prn "who knows?")
I think this looks better even though it has more parens.


1 point by rocketnia 4459 days ago | link

"I would argue that lisp's cond is ugly primarily because it puts conditions and actions on a single line."

I like single-line cases. I might argue 'cond is ugly because any language with 'cond is probably verbose enough to force the case and consequence onto separate lines. :-p (Clearly bullet could be an exception to that.)

What's especially ugly about 'cond is that, once the condition and consequence are on separate lines, there's an indentation issue. I don't like indenting by just one space or indenting past an already matched paren, so my code would look like this, probably unlike anyone else's code:

  (cond
    ( (...case...)
      (...consequence...))
    ( (...case...)
      (...consequence...)))
(Actually, my code would probably define a macro (ifs ...) that worked like Arc's 'if, but that's cheating.)

-----

1 point by akkartik 4459 days ago | link

"I like single-line cases. 'cond is ugly because.. the case and consequence onto separate lines."

You know, you're right. I change my mind. The major problem isn't merging lines, it is how to keep things clear when both the case and consequence are long. Just using indent to distinguish them is a poor solution because we use indent to group things together everywhere else.

To see how bad things can get, this definition of markdown is an eyesore: http://github.com/nex3/arc/blob/fe2c9eb2d6/lib/app.arc. Wart doesn't really improve matters except to add the :else to distinguish the two consequences right at the end.

-----

1 point by seertaak 4459 days ago | link

That quote was meant to be a bit flippant :)

You can break the line accross by using "begin" in _bullet_:

    cond
      name equals "Martin" ; begin
        print "what a"
        print "fool"
      name equals "Frodo" ; begin
        print "what a"
        print "saviour"
      name equals "Alex" ; begin
        print "err..."
        print "who knows?"

-----