Le samedi 27 décembre 2014 à 22:45 -0800, Jason Merrill a écrit :
> 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?
Definitely not in packages, since all .R files in the R/ directory are
concatenated together when building the package. Probably more
frequently when writing large scripts, if you don't want to include
everything in one file. Some people appear to prefer that solution over
creating packages, but that shouldn't be considered as recommended:
http://stackoverflow.com/questions/1266279/how-to-organize-large-r-programs


Regards

Reply via email to