[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Equiv of single-line value verses a multiline value with one line
> I wrote my parser so that the above two MCP messages produce identical
> internal representations, and single line values are always sent in
> the message start line. I did this because I thought that was the
> concensus I received when I posted this question earlier.
I think Dave said "yes" and I said "no" and nothing was resolved.
The parsers we've done for LabSpace and AT&T (Scheme, MOO, and Java) all
treat multiline values as lists or arrays, and non-multiline values as
strings. So there is a distinction between the two.
There's no overwhelming reason for this to be the case. We've never
designed a package in which kwd: means one thing and kwd*: means another.
Nor have we had any messages in which a string and a list have different
implications for the same argument. (We haven't had any messages in which
both strings and lists are valid.)
I do think strings are easier to deal with for the common case. If you
interpret kwd: "foo" as an array, then all your message handlers have to
unwrap foo from its array before using it.
Also, some implementations have a semiautomatic type conversion facility,
in which messages declare their arguments as having certain types, and can
provide functions for converting from raw (string/list) form to that type.
Generally, these can take advantage of existing, low-level type conversion
from a string (e.g., tonum()), where they have to write their own wrapper
to deal with an array. I suppose this could be dealt with by some
automatic unwrapping of arrays.
Of course, the tradeoff is that in some statically typed languages you have
to use a union or some other layer of indirection to deal with the fact that
a value can be either a string or an array.
Could we leave this up to the implementation? I think with a few simple
rules to eliminate ambiguity, we can. Of course, I don't know exactly what
those rules are.
--Erik