Are you able to change the require order? Crystal 0.35.1

I’m using, I would LOVE to use the latest version but I have to wait for them. Anyways… in short: I’ve made a class in one file, being able to use it everywhere else I put a require "./*", but now in another the require stops working – I get a compile error saying the class doesn’t exist. I don’t know what’s happening although I suspect it has something to do with require order and what’s available at one point to another. Trouble is, I tested out a smaller version of the same problem and it went away! So I’m very confused. Link if it’s relevant:

The best solution here is to just not use that and require the files manually. Using a glob like that usually isn’t the best idea as you run into problems like this.

Another solution would ofc be to install Crystal locally and get the latest version :wink:.

I would if I could :frowning:. I’m a Windows User.

For the actual answer, I find that solution to be a bit tedious, but oh well. Thank you!

Install On Windows Subsystem for Linux - The Crystal Programming Language is always an option. Are quite a few people that use it and as far as I know it works quite well.

Also fwiw every file doesn’t need to require every other file. Normally you have a main file that requires all the children. Only times I noticed when a sub file needs an explicit require is if it uses a type defined before it. I.e. type uses a type defined in within some sub directory.

I was thinking of “tree” like structure file requiring. In my project, I’m replicating craftinginterpreters in Crystal so maybe I’d have require,, and Then those require both,, and, when I get there, Or is there a more efficient method to which you were referring?

Right yea. Have require Then require the files that it uses. Most of the time it’s a good idea if each file requires the stuff it uses that isn’t already included where that file was included.

I’m not sure if it’s correct but I’ve always assumed files are required in alphabetical order when using a glob require. So if you do require "./*" it will load before If there’s a specific file that is being required later than you need it to with the glob, you can just add it above the glob to force it to be required first

require "./b"
require "./*"