Hi all,
When a construct is ambiguous, sometimes language designers will provide
a default which (they hope) does the right thing in the common case. An
example is XPath. When = is called on two sets, the semantics are that
there is at least one pair of elements (one from each set) that compare
equal, i.e. that their intersection is non-empty.
This is arguably counter-intuitive. For example, if an XML node
represents an item from a catalog that comes in multiple colors, and you
ask whether item1.color = item2.color, in some situations you'd be
surprised that {Red, Green, Blue} was considered the same as {Red,
Yellow}. Other times it's natural, e.g. when you want all items that
come in Red.
I have a hunch that, when a concept is genuinely ambiguous, providing a
default leads to "copy-and-paste" programming where programmers don't
really understand how a feature works, so they just use it in a few
canonical forms. Even though there is a simple semantics that's easy to
describe, they won't find that semantics unless they look in the manual,
and many people don't. Instead, they just think it's magic and become
confused when they try to do complicated things with it.
Have there been any studies that include a look at such "magic"
features? Scripting languages typically favor conciseness, and thus can
have a fair bit of "magic."
Thanks,
Martin
--
The Open University is incorporated by Royal Charter (RC 000391), an exempt charity
in England & Wales and a charity registered in Scotland (SC 038302).