Module lookup and class naming

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Module lookup and class naming

Bertrand LUPART - Linkeo.com
Hello,


I'm using a custom module for dealing with CSV files for some years now, and everything's fine :

— 8< — 8< — 8< —
// Public.Standards.CSV.FILE
class FILE
{
  inherit Stdio.FILE;
  // custom code here, everything's fine
}
— >8 — >8 — >8 —


Now, i'm slightly updating the module to handle CSV data stored in strings :

— 8< — 8< — 8< —
// Public.Standards.CSV.String
class String
{
  // obviously won't inherit String here
  // class name collision : can't invoke classes from top level String, like String.SplitIterator for example
}
— >8 — >8 — >8 —


This leads me to two questions :

1- Invoking String classes (like String.SplitIterator) from my String class fails because of class name collision. There should be a way to ask the compiler to look up String.SplitIterator from the top level hierarchy and not the local class but i failed to find this myself from the doc.

2- Obviously, renaming the String class solves the issue. Should class names be globally unique ? Public.Standards.CSV.CSVFILE and Public.Standards.CSV.CSVString looked redundant to me.


Thank you,

--
Bertrand

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Module lookup and class naming

Henrik Grubbström-2
On Thu, 23 Mar 2017, Bertrand LUPART - Linkeo.com wrote:

> Hello,

Hi Bertrand.

> I'm using a custom module for dealing with CSV files for some years
> now, and everything's fine :
>
> — 8< — 8< — 8< —
> // Public.Standards.CSV.FILE
> class FILE
> {
>  inherit Stdio.FILE;
>  // custom code here, everything's fine
> }
> — >8 — >8 — >8 —
>
>
> Now, i'm slightly updating the module to handle CSV data stored in strings :
>
> — 8< — 8< — 8< —
> // Public.Standards.CSV.String
> class String
> {
>  // obviously won't inherit String here
>  // class name collision : can't invoke classes from top level String,
>  // like String.SplitIterator for example
> }
> — >8 — >8 — >8 —
>
>
> This leads me to two questions :
>
> 1- Invoking String classes (like String.SplitIterator) from my String
>    class fails because of class name collision. There should be a way to
>    ask the compiler to look up String.SplitIterator from the top level
>    hierarchy and not the local class but i failed to find this myself
>    from the doc.
Surprise; there is! Try global.String.SplitIterator.

> 2- Obviously, renaming the String class solves the issue. Should class
>    names be globally unique ? Public.Standards.CSV.CSVFILE and
>    Public.Standards.CSV.CSVString looked redundant to me.

No need.

> Thank you,

No problem,

  /grubba

--
Henrik Grubbström [hidden email]
Roxen Internet Software AB
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Module lookup and class naming

Bertrand LUPART - Linkeo.com
Hi Henrik,

This leads me to two questions :

1- Invoking String classes (like String.SplitIterator) from my String
  class fails because of class name collision. There should be a way to
  ask the compiler to look up String.SplitIterator from the top level
  hierarchy and not the local class but i failed to find this myself
  from the doc.

Surprise; there is! Try global.String.SplitIterator.

2- Obviously, renaming the String class solves the issue. Should class
  names be globally unique ? Public.Standards.CSV.CSVFILE and
  Public.Standards.CSV.CSVString looked redundant to me.

No need.

Thank you,

No problem,

Wonderful ! Thanks.

-- 
Bertrand
Loading...