Re: Module lookup and class naming
Henrik Grubbström <[email protected]> Thu, 23 Mar 2017 12:53:10 +0100 (CET)
| Newsgroups | gmane.comp.lang.pike.user |
|---|---|
| Organization | Roxen Internet Software AB |
| Message-ID | <[email protected]> |
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 [email protected]
Roxen Internet Software AB