From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: question on using `with` without `use` and visibility of operators such as '*'
Date: Mon, 30 Jul 2012 09:30:54 +0300
Date: 2012-07-30T09:30:54+03:00 [thread overview]
Message-ID: <a7mo0uFqi5U1@mid.individual.net> (raw)
In-Reply-To: <jv585h$9tj$1@speranza.aioe.org>
On 12-07-30 09:04 , Nasser M. Abbasi wrote:
> <warning, newbie in Ada>
>
> I prefer to use the long name of a package when I call some of its
> functions. So I like to write
>
> ------------------------
> with package_foo;
> package_foo.function_name();
> -----------------------
>
> rather than
>
> -----------------------
> with package_foo; use package_foo;
> function_name();
> ----------------------
>
> So that when reading the code, I know where things are.
>
> This worked well so far, but when the package happened to export
> functions/operators such as '*' or "+" for the types, then it will
> not work any more. i.e. I really want to just write
>
> x * y
>
> where x,y are variables with types defined in the package, and not write
>
> x package_foo("*") y
>
> (or whatever the correct syntax would be)
>
> This is annoying. It means I have now to `use package_foo`
> to be able to write x*y, since "*" is defined in the package.
>
> Is there a way around this, so I can avoid using `use` but still
> be able to just write x * y (may be use something like
> `use package_foo("*") at the top if this possible)
Use "use type package_foo.T", where T is the type of x and y. Then you
can apply the "primitive operators" of the type with qualifying with the
package name.
See the "use_type_clause" in
http://www.ada-auth.org/standards/12rm/html/RM-8-4.html.
Note the additional names made visible when the "all" keyword is placed
between "use" and "type".
--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
. @ .
next prev parent reply other threads:[~2012-08-07 6:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-30 6:04 question on using `with` without `use` and visibility of operators such as '*' Nasser M. Abbasi
2012-07-30 6:30 ` Niklas Holsti [this message]
2012-07-30 6:33 ` Dmitry A. Kazakov
2012-07-30 6:50 ` Ludovic Brenta
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox