Arc Forumnew | comments | leaders | submit | are's commentslogin

> Polymorphism means "several functions with the same name, dispatching on type" which implies some kind of objects.

I'm assuming that by "some kind of objects", you mean a user-extensible type system.

You can have multiple dispatch on function arguments (by type or even by instance) without providing user-extensible types, so it's not really "imply". Just sayin'...

-----

1 point by are 6283 days ago | link | parent | on: Unifying characters, strings AND symbols?

Thanks; you're probably right that this is unnecessary, and wouldn't help the Arc parser much anyway.

You would have to escape double-quotes, though.

I like how Smalltalk handles this by allowing both single- and double-quotes as string delimiters:

"This is a string which includes two 'single quote' characters, which aren't escaped"

'This is a string which includes two "double quote" characters, which aren't escaped either'

This wouldn't work for Arc, though, if you also want to be able to use a _single_ single-quote for quoting symbols.

I've removed the sentence you quoted from my proposal.

-----

2 points by ehird 6283 days ago | link

wrong

smalltalk "abc"= comment

-----


Would have been interesting to hear PG's thoughts on unifying chars, strings AND symbols...

[Edit: Much updated below this] Here are my 2 cents':

- A string would be either the empty string, or a non-empty sequence of strings of length 1.

- A string would also have an _associated value_ (nil by default), that can be of any type (including functions, macros, special forms or other strings). A string would then also be a key-value pair, and a keyed hashtable could be treated conceptually as a collection of strings with no duplicates.

- A non-whitespace, no-paren (alphanumeric?) string will return its associated value (= be evaluated) in an Arc expression if you _don't quote it_, making such unquoted strings convenient for using as variable or function names. In addition, if such an unquoted string immediately follows a left-paren in an Arc expression, its value will be treated as a function and applied. (All this is different for special forms and macros, of course.)

- To quote a string, you would use double-quotes around it, to keep it from being evaluated, and returning itself rather than its associated value. Quoted strings are then string literals, and in this usage, the associated value will often be nil. String literals of length 1 are used as character literals.

- A non-whitespace, no-paren (alphanumeric?) string can alternatively be quoted by prepending a single-quote, in the same manner that you quote a composite Arc expression by prepending a single-quote before the leading left-paren. If you intend to use the associated value of the string, this is the preferred way of quoting it (for clarity).

- In a double-quoted string, you will have to escape parens, double-quotes and single-quotes by prepending a single-quote.

- To return the associated value for a string that includes whitespace or parens (or non-alphanumeric parts?), you would have to do explicit evaluation by using eval with the double-quoted string. This would discourage (but not disallow) using such strings for variables and definitions.

I'm guessing this proposal is inconsistent and unworkable, but I'm throwing it out there anyway...

-----

1 point by are 6283 days ago | link

This comment has now bee posted as a submission. Please comment there.

-----