Exercism exercises in V.
Last known status:
This language has the potential to be made into an Exercism track, but with the caveat that there is an important decision to be made regarding directory structure and V's modules. Here are the factors resulting in the necessity of this decision:
- Recall that Exercism's directory structure is that an exercise named "Hello World" is considered to have a slug of hyphen-separated words like hello-world, which is then placed in
exercises/hello-world
of a track repo. - Recall that V expects modules to be named after the directory they are located in.
- Experimentation shows that hyphens are not a valid character in V module names.
This is then a problem, since it implies that any exercise with multiple words in its name would force an illegal module name.
After experimentation, here are three ways that work, for consideration by a future maintainer who wishes to take on this track:
- Break with Exercism's convention of using directory names like
hello-world
(separated by hyphens) and instead use directory names likehello_world
(separated by underscores), usingmodule
andimport
lines matching those underscore-separated names such asmodule hello_world
andimport hello_world
.- See
exercises/hello_world
in this repo for this approach. - NB: Omitting a separator entirely (like
helloworld
) does work, but becomes unreadable for longer exercise names. - It's not yet been confirmed whether breaking from convention in this way will cause problems elsewhere in the Exercism ecosystem, and in either case breaking from convention will require special handling for tools that assume the convention (such as comparing exercises against problem-specifications).
- See
- Keep with the convention of using directory names like
hello-world
. Withinexercises/hello-world
, have ahello_world
module, which would be located inexercises/hello-world/hello_world
and usesmodule hello_world
andimport hello_world
as usual.- See
exercises/hello-world-nest
in this repo for this approach. If this approach is taken, of course in the final track repo this would instead be calledexercises/hello-world
, containingexercises/hello-world/hello_world
. - This seems like a less-good experience for a student of this track, since there is a seemingly-unnecessary level of nesting in directory structure, beyond the one directory per exercise.
- See
- Keep with the convention of using directory names like
hello-world
. Usemodule main
.- See
exercises/hello-world-main-mod
for this approach. If this approach is taken, of course in the final track repo this would instead be called justexercises/hello-world
. - This doesn't appear to have either of the problems of the above. It keeps with Exercism convention and doesn't introduce any unnecessary nesting.
- Only concern here is the documentation stating
fn main()
declaration can be skipped in one file programs which might mean it cannot be skipped in multi-file programs - since we don't have afn main()
, perhaps we thus cannot have multi-file programs.
- See
Other attempts were tested unsuccessfully:
- Using no
module
norimport
lines at all- in this case, the functions to be tested cannot be found
- See
exercises/helloworldnomod
- Having the module name not match the directory name
- in this case, the module then cannot be found
- See
exercises/hello-world-mismatched
, in which the module is namedhello_world_mismatched
, using underscores instead of hyphens.
- Trying to use a hyphenated module name anyway
- in this case, then
error: cannot import multiple modules at a time
on theimport hello-world
line. - See
exercises/hello-world
- in this case, then
Please see CI results to see all attempts resulting from the cartesian product of various testing scripts vs exercise directory structures.
Since this is only a report of what has been tried so far, a future maintainer should feel free to consider new ways to solve the above problem. For example, maybe in the future V will allow hyphens in module names. Or, a future maintainer has an idea that was not covered above.