I didn't mean to say that anyone "admires" using include, but empirically, it is used a lot as a code organization tool in Julia (more below).
I was asking about if there was precedent in a different language that shows that "no, the situation is actually totally fine; even though you can misuse include nobody does." My beef with include is that it is a deeply unstructured way of organizing code, in the sense that it can dump a lot of identifiers into any scope, and it makes no guarantees about how often the top level code in an included file will be run. I brought it up again here because I think OP's question is a good example of that second property biting someone. Now the empiricism: 9 out the 10 most starred Julia packages use "include" as a code organization tool: 1. https://github.com/JuliaLang/IJulia.jl/search?utf8=%E2%9C%93&q=include 2. https://github.com/dcjones/Gadfly.jl/search?utf8=%E2%9C%93&q=include 3. https://github.com/JuliaStats/DataFrames.jl/search?utf8=%E2%9C%93&q=include 4. https://github.com/stevengj/PyCall.jl/search?utf8=%E2%9C%93&q=include 5. https://github.com/JuliaOpt/JuMP.jl/search?utf8=%E2%9C%93&q=include 6. https://github.com/pluskid/Mocha.jl/search?utf8=%E2%9C%93&q=include 7. https://github.com/JuliaWeb/Morsel.jl/search?utf8=%E2%9C%93&q=include 8. https://github.com/JuliaOpt/Optim.jl/search?utf8=%E2%9C%93&q=include 9. https://github.com/forio/GeneticAlgorithms.jl/search?utf8=%E2%9C%93&q=include (the only one that doesn't use include) 10. https://github.com/nolta/Winston.jl/search?utf8=%E2%9C%93&q=include Julia core also uses include, e.g. in the markdown parser: https://github.com/JuliaLang/julia/search?l=julia&q=include&utf8=%E2%9C%93 Now the popular packages tend use include in a way that's fairly harmless--i.e. to allow a lot of different symbols and functions to be exported from a single module, without writing all the code in a single giant file. But given that the good uses of include are pretty restricted, I think we'd be better off if the default tool for doing this kind of thing was more restrictive. If you want to use include poorly, you can use it very poorly. This last part is entirely for amusement--it's a total strawman--but it just occurred to me that you can use include to simulate labeled GOTO: # factorial.jl n = parseint(ARGS[1]) accum = n include("helper-a.jl") # helper-a.jl n = n - 1 if n <= 0 print(accum) else include("helper-b.jl") end # helper-b.jl accum *= n include("helper-a.jl") Now I can run $ julia factorial.jl 5 120 On Sunday, December 28, 2014 4:27:34 AM UTC-5, Stefan Karpinski wrote: > > I'm not sure where you get the idea that anyone "admires" using include. I > specifically just recommended not using it. > > On Sun, Dec 28, 2014 at 1:45 AM, Jason Merrill <jwme...@gmail.com > <javascript:>> wrote: > >> On Saturday, December 27, 2014 5:15:38 PM UTC-5, Stefan Karpinski wrote: >>> >>> You shouldn't be using include here – the way to do this is to make sure >>> that moduleFile.jl is in your LOAD_PATH and then do `using moduleFile` or >>> `import moduleFile`. >>> >> >> I've complained before that "include" in user code is an anti-pattern, >> and I guess I'm going to complain about it again. >> >> Are there examples of other languages that people admire where the >> equivalent of "include" is regularly used in user code? >> >> The main place that I think I've seen people use something like it is >> PHP, and even there, I think "require" is used more frequently in good code. >> >> Languages I've used where include-like functionality is very rarely used >> include Python (include->execfile), Java, and node-style Javascript >> (include->exec(fs.readFileSync("filename"))). >> >> I don't think there's much to learn from Matlab here, and Mathematica's >> culture of user created libraries seems weaker than in many other >> environments. >> >> Do people frequently use source() in R? >> > >