Post by Simon WillcocksOn Oct 12, 11:09 pm, "Emmanuel Stapf [ES]"
Post by Emmanuel Stapf [ES]Post by HelmutClearly, there are always pros and cons. But I am not sure whether you
have read the change completely. There is no --- I repeat -- no change
of semantics. The long and clumsy form you are proposing and the more
concise form are semantically identical.
I'm sorry but reading a.b does not read as a check to me.
But a.attached.do_something reads as a check.
I would agree with this; it's something you can quickly search for, or have
highlighted in an editor. (I don't think it's a good place for a keyword,
though; the feature in ANY seems reasonable, to me. I prefer my ? though.)
Indeed, the placing of a keyword is part of the argument.
It is in the same position as a called feature and, perhaps
unintentionally, subverts the usual Eiffel grammatical habits.
I'm deliberately exaggerating in the following example,
to illustrate the point: by the same token, one might rewrite
if a.query then
foo.bar
end
as
a.query.if.foo.bar
The "if" is quickly searched for, or highlighted in an editor,
and we can use sed for refactoring. I suggest many would find
my placement of "if" absurd. Not so with "attached", it seems.
Why is that?
I'd also count the placement issue as going against what is called
"natural target of quality assurance efforts" in [1, p.12], even
though the argument there is not the same. The emphasis would be
on "natural", a notion to be kept in mind with advantage when making
language decisions,I believe.
On the positive side, a clearly visible infix symbol can invalidate
some of the arguments, though. To avoid overloading at the syntax
level, the symbol should perhaps have no other uses. (I have picked
this one (CHECK MARK, U+2713) for the sake of an example.)
b.foo(bar)
a ✓ do_something
c.d
A compiler can then still try to show that a is always attached
or else generate code raising a meaningful exception. But with
the brevity the opportunity to add a note has vanished...
Post by Simon WillcocksEmpirical research regarding programmer behavior ...
Do you have any references to these studies?
Yes, some recent, some old; lengthy elaboration and some
conclusive arguing might be needed, and reference to other languages.
Since doing so might entail loosing focus or even incite language
wars, I'll try to send them via email.
Post by Simon WillcocksI also trust that since you want this style of expression,
there is no point in discussing it.
I don't think it's helpful to dismiss someone in that way; it's too easily
used by someone who has already made up their own mind.
Agree, but I think the issue always needs to be on the table:
a new language feature is to be defended, exhibit all motives.
Risk some impoliteness.
Post by Simon WillcocksI would suggest that "multi- language personnel" may have more problems with
a check statement (essentially an assertion, until recently) becoming both
an essential part of the program and a variable declaration!
exp: detachable E
anc_exp: detachable E_ANCESTOR -- conformant
-- old syntax
check attached exp as x then
x.some_feature
end
check attached {E} anc_exp as x then
x.some_feature
end
In it, it looks like x has appeared from nowhere (and presumably needs yet
another name that doesn't clash with a feature, local or parameter?) and
disabling runtime checks is no longer an option.)
The order of symbols in the declaration has changed, yes.
Object test syntax aside, if symmetry seems desirable then
check
x : attached exp
then
x.some_feature
end
looks like it has fewer syntactical rearrangements?
But x appeared from nowhere in attached exp as x?
I'd assume that language savvy programmers (or indeed anyone having
read a math text) have seen an expression of the kind
x op y where y = f(t1, t2)
Finding x standing on the right would not seem to be
an unusual expectation to me.
(AFAIU, the semantics of check may have changed a bit, but the
spirit, too? Assume the thing to be attached, and have quality
assurance fix the error otherwise; "check" still is not "if"
and can be turned off, once you trust your attachments. Correct?)
Post by Simon WillcocksThere was a rather nice construct suggested a while ago, where you could
select o -- an instance of some superclass of E
when E
o.some_e_function -- you get to use the same name!
when NULL
-- o = Void, now what?
end
I liked that!
Note how this does not have the placement issue! ;-)
Post by Simon WillcocksAs this is usually called refactoring, assign a degree of increased/
decreased feasibility of refactoring, with existing tools and
processes in mind.
Since both approaches are easily interchangable, I doubt this is a major
factor.
Ideally, any unambiguous syntax can be transformed into another.
But in real life, programmers struggle with regular expressions,
for a start. Even for Eiffel a good, general tool might not be
trivial to write and use if there is older source, too, written
using an older, different grammar.
Post by Simon WillcocksEiffel's co- vs contra-variant type hierarchy decision
provides us with one example.
Eiffel has covariant hierarchies because ... and not because
contra-variance has certain technical benefits. Again, syntax
and semantics are not enough to make a choice.
Isn't covariance semantics? And aren't CAT calls still a concern?
Exactly, OOSC2 does not hesitate to use what, upon closer
inspection, appears to be persuasive rhetoric to defend
covariance, in the presence of CAT calls.
I'm sure others will be able to provide equally compelling
examples of why contravariance would have been preferable.
But the point is, both language design decisions (co or contra)
have implications that could not have be deduced from syntax and
semantics alone. Examples, or use cases, were needed.
Georg
__
[1] Avoid a Void: The eradication of null dereferencing
http://docs.eiffel.com/sites/docs.eiffel.com/files/void-safe-eiffel.pdf