Why only the first class in source file public ?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Why only the first class in source file public ?

Mr Antoon Verhoeven


Hello fellow-netrexxers,

I came accross a problem with multiple public classes in one source file.

According to the netrexx documentation, "a Program may have only one
public class, and if no class is marked public then the first is assumed
to be public (unless it is explicitly marked private)."
[NetRexx language Definition Part 1, page 46].

This confused me.. does 'program' here mean 'listing' ? Apparently,
because I have more than one public class in my application.
When in one listing a second class is declared public,
there will indeed be an error message.

I find this limiting  when working on a large collection of small
classes that are to be loaded with Class.forName(), hence they *have* to
be public. Is there a way to avoid having to put them each in a seperate
*.nrx file ?

On a more general note, the description in the NLD  on inheritance is very
thorough. But in a direct comparison  with Java, does netRexx inehritance
differ in any way or are there slight differences.

I hope Mike can enlighten me on this, because I always wonder if
what Java books say on inheritance and visibility  applies
for 100 % to netrexx as well.  So far it seems to do, but there may be
small exceptions.. ? Thus, is any Java source one-to-one translateble in
NetRexx ?

Regards,

Toon Verhoeven



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>

Reply | Threaded
Open this post in threaded view
|

Re: Why only the first class in source file public ?

dIon Gillard-5
Mr Antoon Verhoeven wrote:

>
> Hello fellow-netrexxers,
>
> I came accross a problem with multiple public classes in one source file.
>
> According to the netrexx documentation, "a Program may have only one
> public class, and if no class is marked public then the first is assumed
> to be public (unless it is explicitly marked private)."
> [NetRexx language Definition Part 1, page 46].
>
> This confused me.. does 'program' here mean 'listing' ? Apparently,
Program means a file, yes.

> I find this limiting  when working on a large collection of small
> classes that are to be loaded with Class.forName(), hence they *have* to
> be public. Is there a way to avoid having to put them each in a seperate
> *.nrx file ?
No....Mike could do this for you automatically, as Java requires 1 public class
per file, but then line numbers would all be screwed up unless he did that for
you too...

> On a more general note, the description in the NLD  on inheritance is very
> thorough. But in a direct comparison  with Java, does netRexx inehritance
> differ in any way or are there slight differences.
None as far as I know.

> small exceptions.. ? Thus, is any Java source one-to-one translateble in
> NetRexx ?
No, not directly, but with massage, yes. NetRexx doesn't support things like
inner classes at the moment.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>