Nick Sabalausky wrote:
"Andrei Alexandrescu" <seewebsiteforem...@erdani.org> wrote in message
news:gsak2p$1s8...@digitalmars.com...
I think there's merit in binding via strings. It makes for very flexible
code that is future-proof, dynamic-linking-friendly, and hot-swappable
without recompiling (e.g. you don't need to recompile because you now
implement an interface etc.) Reflection is very useful as well.
I think D can and should allow string lookup for its methods. It's a
low-complexity proposition that adds a very interesting tool to D's
arsenal.
That's a separate issue. I absolutely agree with the usefulness of being
able to invoke static methods via a string identifier at runtime. But I
think opDotExp is an extremely flawed way to do it. A much better way would
be through a reflection mechanism:
class Foo
{
void bar() {}
}
auto foo = new Foo();
traits(foo).func("bar").invoke();
That way, you can have the benefits of runtime-string-identifier-invocation
(and have it on *every* class/method), but without completely loosing
compile-time checking on the members of every class which is capable of
using it.
I was expecting this objection. I think it's not based because unifying
syntax is a major part of adding such a feature. If we get to dynamic
invocation but we can't go the last mile, we failed. Look at
IDispatch-based programming in C++ vs. interpreted languages.
If anything, this agreed-fest shows that the rift between static typing
and dynamic typing is alive and well. I've seen many discussions in which
people were mystified how anyone gets anything done in a statically-typed
OO language.
...Doesn't necessarily mean both sides have valid points. Just that there's
disagreement. Outside of diplomacy, it doesn't make any sense to agree with
something you disagree with, or disagree with something you agree with, just
for the sake a closing a rift. Better to just continue debating the issues
with logical arguments. If nothing gets accomplished, well ok, fine, but so
what? That's a lot better than coming to hasty-but-wrong agreement just for
the sake of agreement.
Of course. One thing that suggests the righteousness is not necessarily
on your side is that plenty knowledgeable, intelligent, credible people
use and advocate dynamic typing. Asserting that they simply miss the
point is a bit tenuous.
I guess what I'm saying is, people coming to an agreement is all fine and
dandy, but the most important thing is to arrive at the *correct* agreement.
If one group of people insist that "2+2=0" and another group insists that
"2+2=10", then it's far better to keep analyzing and debating until "2+2=4"
is discovered and proven than to say "let's all be happy!" and hastily agree
that "2+2=5". Again, outside of diplomacy, people disagreeing is not the
real problem, the real problem is that the best answer either hasn't been
found or hasn't been unquestionably shown to be best.
I'm with you, and in wake of my frequent postings I guess it's pretty
known by now that nothing makes me more annoying than knowing 100% I'm
right :o). Certainly I'm not one who "agrees to disagree" and I'm glad
you aren't either.
Andrei