AndrevanTonder <andre_at_het.brown.edu> writes:
> On Thu, 2 Nov 2006, Michael Sperber wrote:
>
>> Many procedures in many libraries accept arguments from a finite set,
>> or subsets of a finite sets to describe a certain mode of operation,
>> or several flags to describe a mode of operation. Examples in the
>> R6RS include the endianness for bytes-object operations,
>
> But endiannesses are symbols in the current version, so the
> abstraction is illusory in that case.
Exactly: enumeration values are symbols by the enumerations library.
However, endianness could have been represented differently. In fact,
in SRFI 74, upon which the bytes objects are based, *does* represent
them differently; we made a policy decision. To avoid all kinds of
future APIs going seven different ways on the same issue, it makes
sense to provide a standard one.
> In other words, one could write, e.g.,
>
> (bytes-u16-ref b 14 'little)
>
> using QUOTE to break the abstraction by forging the enumerated
> values.
I think there's a misunderstanding: You're not breaking an abstraction
here. (The spec clearly states these are symbols.) You're doing two
things by using the `endianness' macro:
- You give the expander a chance to report a spelling error in the
name of the enum value statically. (How large a benefit that is
depends on how well you type.)
- You give a human reader information that this "little" thing is
indeed an endianness. That's obvious when used directly in a call
to a procedure from the bytes library, but less obvious when passed
indirectly.
> I happen to think that symbols are just fine here, but if I had to
> build a safe "endianness" abstraction, I would think that it would be
> better to use generative objects that cannot be forged by "quote".
We did consider that (and in fact I argued for this position), but the
editors ended up rejecting the idea. All the gory details on that
discussion are somewhere in the ML archives. I'll try to summarize in
the rationale document.
--
Cheers =8-} Mike
Friede, V?lkerverst?ndigung und ?berhaupt blabla
Received on Thu Nov 02 2006 - 11:00:26 UTC