# IDEA: Allow multiple uses statements

**URL:** https://talk.remobjects.com/t/idea-allow-multiple-uses-statements/22045
**Category:** Oxygene
**Tags:** oxygene, language
**Created:** [May 21, 2020, 2:58am UTC](https://talk.remobjects.com/t/idea-allow-multiple-uses-statements/22045 "2020-05-21T02:58:17Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![deltics](https://talk.remobjects.com/user_avatar/talk.remobjects.com/deltics/32/804_2.png) [@deltics](https://talk.remobjects.com/u/deltics)
#### Post date: [May 21, 2020, 2:58am UTC](https://talk.remobjects.com/t/idea-allow-multiple-uses-statements/22045/1 "2020-05-21T02:58:18Z")

</div>

The comma separated namespace list in a `uses` statement feels somewhat out of date these days. It could be a simple enhancement to allow multiple, consecutive `uses` statements. Each statement would optionally support a comma separate list of namespaces as currently, or could identify a single namespace.

If used, multiple `uses` clauses must be contiguous. That is you could not have a `uses` statement followed by a `type` declaration followed by a further `uses` statement.

Contiguous `uses` statements would have the same effect as if they were one single statement with all namespaces listed in the order in which they occur in the separate statements.

That is:

```
uses A;
uses B;
uses C;

```

Would be equivalent to:

```
uses A, B;
uses C;

```

Which would be equivalent to:

```
uses A, B, C;

```

This would then provide flexibility in organising uses clauses which could be grouped by root namespace (for example):

```
uses
   System,
   System.Net;
uses
   Microsoft.AspNetCore.Mvc,
   Microsoft.Extensions.Logging;
uses
   MyApp.MyNamespace;

```

Or, more practically, to list namespaces as discrete references that can be more easily modified without breaking valid termination of the statements (since each is individually moveable/removable, irrespective of current/starting position in the list).

```
uses A;
uses B;
uses C;

```

A small change (?) and granted not exactly a massive leap forward in terms of language technology, but might be worth considering ?

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [May 21, 2020, 1:19pm UTC](https://talk.remobjects.com/t/idea-allow-multiple-uses-statements/22045/2 "2020-05-21T13:19:51Z")

</div>

While I’m not oppose don principle, I’m not exactly sure what actual _probem_ this solves?

> [@deltics](#):
>
> This would then provide flexibility in organising uses clauses which could be grouped by root namespace (for example):

You can already group (read: sort) them, now?

---

<div class="post-metadata">

### Author: ![Theo69](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/t/35a633/32.png) [@Theo69](https://talk.remobjects.com/u/Theo69)
#### Post date: [May 21, 2020, 6:39pm UTC](https://talk.remobjects.com/t/idea-allow-multiple-uses-statements/22045/3 "2020-05-21T18:39:50Z")

</div>

It would be easy for code generation.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [May 21, 2020, 7:09pm UTC](https://talk.remobjects.com/t/idea-allow-multiple-uses-statements/22045/4 "2020-05-21T19:09:26Z")

</div>

> [@Theo69](#):
>
> It would be easy for code generation.

How so? Code generation (be it CodeDom, or CG4) has no problem just emitting all namespaces in a single list?

---

<div class="post-metadata">

### Author: ![deltics](https://talk.remobjects.com/user_avatar/talk.remobjects.com/deltics/32/804_2.png) [@deltics](https://talk.remobjects.com/u/deltics)
#### Post date: [May 21, 2020, 9:02pm UTC](https://talk.remobjects.com/t/idea-allow-multiple-uses-statements/22045/5 "2020-05-21T21:02:14Z")

</div>

tbh grouping was not the primary use case I had in mind. For me, it is the differentiation of the last namespace with the presence of a terminator rather than a separator that is the most significant pain. But still a small one. 🙂

It is a minor problem, to be sure, but when adding namespaces to the list and needing to resort them, it is a pain to have fiddle around with terminators if the change affects the last one in the list.

```
uses
   A,
   B,
   D,
   C;

```

You cannot just move `C;` up in the list, you also have to replace the `;` with a ‘,’ (and vice versa for the `D` entry). For sure this can be worked around with fugly formatting tricks:

```
uses
  A
  ,B
  ,D
  ,C
  ;

```

Although this solves the problem for the last entry in the list, it just creates a similar one for the first.

With individual `uses` statements:

```
uses A;
uses B;
uses D;
uses C;

```

Each statement is self-contained, allowing each to be moved relative to any other more easily.

It was perhaps a mistake to provide the grouping example first, giving the impression that it was the most important, when the intent was to show that each `uses` statement could still include multiple, comma separated namespaces.

Upon reflection, allowing that might make things more complicated.

It is probably simpler to make this an option: EITHER use a single comma-separated list OR multiple contiguous statements with one namespace per `uses`. This option could then be determined for code generation by settings/configuration (possibly even a directive to allow for per-file configuration).

btw - I think the comment from Theo is thinking of code generation/modification using plain text emitters and handlers, rather than CodeDOM generators/modifiers.

Anyway, it was just an idea. 🙂

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [May 22, 2020, 2:17am UTC](https://talk.remobjects.com/t/idea-allow-multiple-uses-statements/22045/6 "2020-05-22T02:17:12Z")

</div>

Thanks, logged as [bugs://84339](https://www.remobjects.com/portal/bugs/?id=84339)

---

<div class="post-metadata">

### Author: ![Theo69](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/t/35a633/32.png) [@Theo69](https://talk.remobjects.com/u/Theo69)
#### Post date: [May 22, 2020, 11:48am UTC](https://talk.remobjects.com/t/idea-allow-multiple-uses-statements/22045/7 "2020-05-22T11:48:45Z")

</div>

> [@mh](#):
>
> How so? Code generation (be it CodeDom, or CG4) has no problem just emitting all namespaces in a single list?

No,manual code generation. - I generate code regurarly from (html) documentation, just for my own project(s); just an exe that takses the sour and writes code in text. And for that case this can be handy.

> [@deltics](#):
>
> btw - I think the comment from Theo is thinking of code generation/modification using plain text emitters and handlers, rather than CodeDOM generators/modifiers.

Exactly what I meant.

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [February 16, 2022, 7:45pm UTC](https://talk.remobjects.com/t/idea-allow-multiple-uses-statements/22045/8 "2022-02-16T19:45:35Z")

</div>

[bugs://E24136](https://www.remobjects.com/portal/bugs/?id=E24136) was closed as fixed.

Actually fixed/implemented ages ago, just got closed now.

---

<div class="post-metadata">

### Author: ![JohnMoshakis](https://talk.remobjects.com/user_avatar/talk.remobjects.com/johnmoshakis/32/2286_2.png) [@JohnMoshakis](https://talk.remobjects.com/u/JohnMoshakis)
#### Post date: [February 16, 2022, 8:13pm UTC](https://talk.remobjects.com/t/idea-allow-multiple-uses-statements/22045/9 "2022-02-16T20:13:28Z")

</div>

Oh yeah. It does look a bit strange
