Arc Forumnew | comments | leaders | submitlogin
1 point by rocketnia 5509 days ago | link | parent

I don't have a problem with nil being a symbol, but speaking of writing shorter programs, I can't think of a single time I've actually needed to coerce nil/null to a string in any language except when printing it out for debugging purposes, and even then, in Arc:

  (is "nil" (tostring pr.nil))  ; because 'nil is sent to MzScheme's 'display
So when...

  (is "" string.nil)  ; because 'coerce special-cases 'nil to do this
...I'm taken by surprise, and I'm not sure where this discrepancy would pay off in brevity.

I suppose string-returning procedures that need to be convenient in boolean contexts can return nil instead of "" and expect anyone who calls them to wrap them up as string:foo in string contexts... but even so, I can't think of any practical examples of when doing that would be shorter than having the procedures return only strings and wrapping them up as ~empty:foo in boolean contexts.

Is there some brilliant use of (is "" string.nil) I'm not thinking of?



5 points by aw 5509 days ago | link

Conditionally include things in a string:

  (string "You are going "
          (if (> speed 100) "very ")
          "fast")

-----