[Vala] 'using' importing too many symbols



'using' seems problematic to me.  I think we need finer control.  For
example, this bit of code:

  using Gee;

  public void main() {
     var queue = new Queue<Object>();
  }

gives the build error: "`Queue' is an ambiguous reference between
`GLib.Queue' and `Gee.Queue'.

I want to resolve the ambiguity in my code -- either stop it importing
GLib.Queue, or tell it that when I say 'Queue' I mean "Gee.Queue".

Really 'using GLib' is equivalent to 'import GLib.*' in Java.  This
invites problems with symbol clashes, especially as packages are
expanded with new classes -- something that built once might not build
later when the packages are upgraded.

Java's solution is to allow importing symbols one by one, e.g. 'import
GLib.Queue'.  This means a lot more typing, but with support from the
IDE (e.g. Eclipse) it becomes very easy because you can ask the IDE to
fixup the imports.  It can guess most of them, and where there is
ambiguity, it asks you to choose.  The Vala compiler could perhaps do
a similar thing, suggesting import/using statements in the error
message.

Alternatively, someone posted about 'aliases'.  Would this solve the
problem?  I'm not sure it would, unless the alias overrides all other
matches and resolves the ambiguity: e.g. would 'using Queue =
Gee.Queue' solve my problem?

Jim

-- 
 Jim Peters                  (_)/=\~/_(_)                 jim uazu net
                          (_)  /=\  ~/_  (_)
 UazĂș                  (_)    /=\    ~/_    (_)                http://
 in Peru            (_) ____ /=\ ____ ~/_ ____ (_)            uazu.net



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]