-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Implement the new path search algorithm #2788
Conversation
I'll do that over the weekend.
Yes, let's do that at the same time.
Oh, it was a nice touch 😢 |
Yes, maybe, but it only applied to the standard library. Without that rule it's now easier to see which top-level names are occupied by the standard library: all files under With that, I'd like to free some names. For example |
This is now implemented in Crystal, and can be merged as soon as it's reviewed and this PR is merged :)
👍 |
Woot?
Nooooo! I'd like that rule tried after foo.cr "everywhere"... |
I think that the rules should be kept as simple as possible, i.e. |
@ysbaddaden I guess it's a personal thing, but I really like the contents of I guess we should keep both styles then. |
I think I'd like to put back the rule that |
a584b3b
to
4048ecb
Compare
UPDATE: I added one more general rule: for any With the above rule we get two things:
The first point is the main reason I decided to do this change: backwards compatibility for at least one release, to more easily evolve shards and every code out there. But the second point is also nice, and we could consider keeping it afterwards. It means that if someone does
Or use this tree:
I personally find the second tree nicer, because everything related to |
4048ecb
to
093e71b
Compare
👍 for everything related in the same dir :-) If I have one file only for a class / functionality - I keep it directly accessible, without wrapping dir. But as soon as I split it up / add more files to the module - I move it down in its' own dir. |
This fixes #2690.
The new rules are:
For
require "foo"
, search:foo.cr
(to find something in the standard library)foo/src/foo.cr
(to find something in a shard)For
require "foo/bar"
search:foo/bar.cr
(to find something in the standard library)foo/src/bar.cr
(to find something in a shard, non-namespaced structure)foo/src/foo/bar.cr
(to find something in a shard, namespaced structure)For
require "foo/bar/baz"
search:foo/bar/baz.cr
(to find something in the standard library)foo/src/bar/baz.cr
(to find something in a shard, non-namespaced structure)foo/src/foo/bar/baz.cr
(to find something in a shard, namespaced structure)We support rules 2 and 3 in the nested path search so that current shards continue to work, and later we can decide if we prefer to keep this nested structure or not. Or maybe we can leave it like that and each shard author can choose this.
To move forward with this we'd need shards to put the whole contents of a shard inside
libs
, not just thesrc
directory. I guess this will be easier, but it needs to happen in sync with the next release. @ysbaddaden Would you like to do that?Additionally, it should probably put things inside
lib
so we can fix #321 . This needs no change in the compiler, just a change in omnibus.This is the reason I un-nested many files in the standard library, because the old
foo
findsfoo/foo.cr
doesn't apply anymore.