GWT doesn't allow reflection, but it does allow polymorphism. Let's
assume your client uses interface IC which is implemented by C1 and
C2. Now C1.x() is marked as invalid, but C2.x() isn't. Now your client
also can't use IC.x() anymore. It better not be toString()...

This is just one example for the strange semantics this would create.
I don't say that it's necessarily bad, but it's so different from the
semantics we're used to expect from a compiler. For me, one of the
most important things about a compiler is reliability. This doesn't
only mean that it should ideally be free from bugs. It means, that it
must be easy to determine which things will compile, and which won't.
Otherwise, we'll end up with something that's even worse than a C++
compiler: Slow, and little tooling support compared to Java (it's
incredibly hard to write good tools for C++, because the semantics are
too complex even for really good tool developers.)

Still I somehow like your idea. It just shouldn't be part of the
compiler. If it happens in a pre-compilation step that can be done
independently of the compiler, everything is fine, because then we can
keep our compiler simple and reliable.


On Feb 4, 2:42 pm, getaceres <[email protected]> wrote:
> I chose the wrong letter to describe my algorithm. Going to my
> example:
>
> Class A not serializable.
> Class B serializable but with a B.field of type A marked as transient.
>
> In this case, only B has to be taken into account, which is the only
> class that uses A. The compiler would ignore completely A and mark
> B.field and all the methods in B which use B.field as invalid (not
> translatable). If any class C uses a method in B which has been marked
> as invalid, then the compilation fails. In this case, there isn't any
> possible mistake. The only way to use B.field or any invalid method in
> B and not declaring it in the code would be to use reflection, which
> is not supported by GWT so if the code compiles, it will work for
> sure. At least, no one will ever call any method which uses directly
> or indirectly something related to A because in that case, the
> compilation would have failed.
>
> I don't know much about modern compilers (apart from flex and yacc)
> and much less about the GWT compiler, but I don't think that
> implementing this would be very complex. On the code analysis of B
> (lexical or semantical) you put some information in a Hash Table which
> is consulted every time another class uses B.something. Of course,
> this will slow the compilation process, specially if B is a overused
> class which has a lot of functionality, but at least for me, it would
> be worth the extra compilation time just to be able to reduce my
> duplicated code.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to