nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.55k stars 1.47k forks source link

Is there a technical reason why nimscript files require the .nims extension? #17190

Closed wbehrens-on-gh closed 3 years ago

wbehrens-on-gh commented 3 years ago

Summary

Remove the requirement for nimscript files to have an extension

Description

Basically every other interpreted language can be use with a #! and no file extension, it would be nice if I want to embed a single nimscript file in a non-nim project and have it appear as any other script.

Additional Information

After discussing this in the nim discord for a while it appears there is no reason why there HAS to be an extension on nimscript files. This could be wrong though and any additional information on the choice to have it be required is welcome.

Araq commented 3 years ago

Files without extension are a design bug but that's a story for different time. I think it's reasonably easy to support it.

timotheecour commented 3 years ago

I'd like this:

proposal: --ext:nims flag for nim

nim e --ext:nims foo # assumes nims extension
nim e --ext:nims foo.nim # assumes nims extension, ie pretends it's a nims file
nim c -r --ext:nim foo.nims # assumes nim extension, ie pretends it's a nim file
nim rst2html --exp:rst foo # assumes rst extension

which is like clang -x cpp foo.c (etc)

it makes it easy to treat an existing nim file as nimscript as an example use case.

with this, you can write your shebang with a file with no or arbitrary extension as you see fit

example 1

this already works, if in foo.nims: chmod u+x foo.nims ./foo

#!/usr/bin/env -S nim e
echo (1,2,defined(nimscript))

example 2

with proposed --ext feature, it'd also work with foo instead of foo.nims:

#!/usr/bin/env -S nim e --ext:nims
echo (1,2,defined(nimscript))

and again, you'd also be able to use --ext:nim for native speed (and caching compilation with nim r)

rgpublic commented 1 year ago

Sorry to ask, but: This bug looks closed/merged and I've installed a recent nightly build but the --ext:nims option doesn't seem to be there... (invalid command line option)...?