| Arc currently has a character type and a string type, with some functions working on only one or the other. For example: (string '(#\a #\b))
=> "ab"
but (string '("a" "b"))
=> ERROR!
Instead you have to write: (apply string '("a" "b"))
You could patch string to work with strings, but the deeper question is: couldn't Arc just get rid of the character type, and use strings everywhere? Character types make sense in languages like C, where "a" takes up one more byte than 'a', but in a higher-level programming language, do we really need to make that distinction? What benefit do characters give you?Getting rid of characters would simplify the language and make programs shorter. You'd no longer need to convert characters into strings or vice versa. I think it would be a simple change too (although I'm not going to code it as it would break Anarki's compatibility with Arc). Just make every function that returns a character return a string of length one instead: ("bar" 1)
=> "a"
Every function that takes a character argument can take a string, and then drop all but the first character or try and do something intelligent with the whole string: (string '("f" "oo"))
=> "foo"
Are characters an onion in the varnish, or do they serve a useful purpose? I can't think of one, can anyone else?P.S. Characters would still have to be used under-the-hood to implement strings. The question is whether they need to be exposed to the user, or whether they're just an implementation detail. P.P.S. Might I point out that Lisp doesn't even have a true boolean type. Nil and T are symbols, but have served perfectly well for 40 years as booleans too. Are characters really more essential than booleans? |