V: module name d茅j脿 vu

Created on 27 Mar 2019  路  3Comments  路  Source: vlang/v

In base64 example:

// --- file base64.v ---
module base64

... the rest of the file

Is there a reason for this redundancy and potential for confusion? Following file name = module name rule would be the simplest, making no room to cause a mess. D does this (by default) and it is one of brighter language features.

All 3 comments

Modules can have dozens of files.

Modules can have dozens of files.

Is it wise to support such design monsters? If a module really needs to be that big, why not require naming like:

base64.1.v
base64.2.v
base64.3.v
base64.4.v

All such files would form the base64 module.


Perhaps more useful than giant modules would be the ability to express the constraint: "_I want this module to be used only from that module, and by no one else_". Kind of utility modules.

This could be implemented by file names:

base64.v                    -- exports API of the module
base64.v.impl/              -- subdirectory, uses module name to indicate private implementation
     helper.v               -- module which is visible and used only from base64
     another-helper.v       -- more private utilities for base64
     something-else.v 

Of course having so many files in one module is a bad idea. I should have said "most modules will have more than one file".

Was this page helpful?
0 / 5 - 0 ratings

Related issues

penguindark picture penguindark  路  3Comments

fidergo-stephane-gourichon picture fidergo-stephane-gourichon  路  3Comments

taojy123 picture taojy123  路  3Comments

oleg-kachan picture oleg-kachan  路  3Comments

markgraydev picture markgraydev  路  3Comments