New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
X::MyModule::Foo or MyModule::X::Foo ? #57
Comments
FWIW, I prefer to treat X:: as a "parallel namespace" next to the regular class namespace, because X:: in the lead position is visually distinctive, almost sigil-like; it calls out that Exceptional Stuff is Happening Here. When it's buried in the middle it gets lost -- especially since a great many modules have at least two level names at the module's top level, plus at least one level of submodules below it, so with ::X:: you'd really end up with ModuleCategory::MyModule::MySubModule::X::ExceptionName or ModuleCategory::MyModule::X::MySubModule::ExceptionName, both of which totally lose the visual distinctiveness of being an exception. |
@JJ sounds like something that can be done in the docs. Please leave this ticket here in case we want to come back to this discussion. But yeah, if @ugexe, any thoughts? |
From what I remember there used to be (still is?) bugs with using |
Yeah, I vaguely remember something like that too, but what kind of bugs? Can't find anything now. |
I remember this from not long ago, but this seems kinda special and avoidable with proper namespacing maybe? |
Yes, but in that case it was |
ping @jonathanstowe -- does any of this ring a bell? Maybe jonathanstowe/Tinky@8bfc778 ? |
I think it's about this ticket. The commit resolved the name clash between two modules, and the namespace indeed made a difference (“Note that if it's a name other than X then it's OK”). |
yep, I put the Raku/doc#2865 to discuss how to improve the documentation on this. It's the things like :
That cause the problem. I've converged on making it |
Ah! I just stumbled upon a dup: Raku/user-experience#11 |
While I do agree that it is nice to have
That's my own 2¢, though. Thanks for listening. |
@Xliff I think the point here is BTW, it is arguable which notation is more confusing. I'm inattentive and might easily overlook the |
@vrurg This From my experience - I have
|
@bbkr may I remind you that nothing is obligatory here?
Don't see what makes it easier?
This is not a point whatsoever. Sometimes renaming a namespace needs so many concomitant changes that one more directory to rename is not an argument. ;)
Same thing. You have the namespace of My own conlusion: this is all is mostly about one's taste. And as any discussion about different taste it leads to nowhere. The primary points of this thread are: |
but that is not the case for anything else -- doing it in this instance would not be consistent with namespaces not being owned or magical (and is still useless to tooling for indirect names). And using the |
Yes. I'm aware that we're discussing best practices.
Let's assume you have trading platform, where users can trade items and services. To prevent all actions forbidden by law you made exceptions: As you add more an more exceptions you realise that it's good to have Then you want to do the same with items, so After reorganizing into What I'm trying to show is that you can add inheritance levels on both left and right side of ::X:: without even thinking about naming collisions: |
There's no need for two directory trees in either form. I've been using the |
|
Yeah,if anything I'd document it as a "Trap" and leave it on the grounds of no consensus. |
This question comes up relatively often (IRC discussion):
(very) rough estimates:
class\s*X::
– 1045 lines, 180 modules: https://gist.github.com/e2cf3062222c4c2bb28f2e3d2a423370class.*::X::
– 108 lines, 19 modules: https://gist.github.com/ff64469296d20d54e78490a1ea39605cEven considering all false matches, seems like
MyModule::X
style is not very popular.Should there be a recommendation somewhere in the docs to use
X::MyModule
style? Or are there any good arguments forMyModule::X
?The text was updated successfully, but these errors were encountered: