Skip to content
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

about naming conflicts in namespaces #680

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

noraj
Copy link

@noraj noraj commented Mar 30, 2023

@netlify
Copy link

netlify bot commented Mar 30, 2023

Deploy Preview for crystal-book ready!

Name Link
🔨 Latest commit df0b43d
🔍 Latest deploy log https://app.netlify.com/sites/crystal-book/deploys/6425ff59163051000845695f
😎 Deploy Preview https://deploy-preview-680--crystal-book.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@straight-shoota
Copy link
Member

Thanks for this contribution.

I think we should put this in a different place. It's not really a specification of a language feature. That would just be the last sentence and that's already covered in https://crystal-lang.org/reference/1.7/syntax_and_semantics/the_program.html#top-level-scope

This piece feels more like a mini howto: If you need to deal with this, you can do that (this = naming conflict, that = top-level namespace reference). Maybe we can put it in the Guides section? But guides are typically larger about more complex topics.
Actually, the scope could be a good format for https://stackoverflow.com/ which we endorse as a knowledge base for these kind of problems.

Anyways, I would suggest to make the example fully self-contained. The reader should not need to know anything outside the presented code.

module Bar
  def self.bar
  end
end

module Foo
  def self.foo
    ::Bar.bar
  end

  module Bar
  end
end

Foo.foo

@noraj
Copy link
Author

noraj commented Mar 31, 2023

Maybe a "Common issues" section under https://crystal-lang.org/reference/1.7/guides/index.html?

@beta-ziliani beta-ziliani self-assigned this Apr 24, 2023
@beta-ziliani
Copy link
Member

I think it's better to have something like this in the tutorial, although at the moment the tutorial itself is rather poor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants