aboutsummaryrefslogtreecommitdiff
path: root/notes/use_lines.txt
blob: e4e1e57bf5430caa059b6748f554cdc7e3c8773b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82

Explciit `use` lines? (bad idea?)
=================================

`use` wculd be a way to specify dependencies on a per-file level.
The idea is to make it clear (to a human reader) which classes are being
used in a class, as well as to allow file-local version overrides.

However, `use` lines might not be necessary at all (see the end of this file).

See also import_groups.txt


Could `use` lines be combined with `giveme` lines?
--------------------------------------------------

* Ordering might be an issue.
    - io-`use` should preferably come first.
    - `giveme`s are not type-unique
      (e.g. there can be 2 `Reader`s)
    - `giveme`s can be ordered in a certain way.
      (e.g. related CLI options grouped together)
* Combining them can lead to duplication
  (e.g. of the module name).

Syntax tests
------------

1:

    giveme io std Reader srcfile1 = inputparam "-f,--file1"    "Input file 1"
    giveme io std Reader srcfile2 = inputparam "-g,--file2"    "Input file 2"
    ...
    # but there could be `io` giveme's "hidden" below!

2:

    io std Reader srcfile1 srcfile2
    ...
    giveme
        srcfile1 = inputparam "-f,--file1"    "Input file 1"
        srcfile2 = inputparam "-g,--file2"    "Input file 2"
    end
    # but adding/removing parameters requires editing in two places!

3:


Alternative solution
--------------------

Skip `use` (only have project-wide imports) and instead have per-file renames
in order to support upgrades?

Or have per-file `use` only to *override* versions of dependencies, i.e. to
use an older API of a depdendency. Maybe call it something else than `use`?

Not sure if this is even necessary at all? Maybe it is sufficient to be able
to turn off specific deprecation warnings/errors?

Perhaps the central dependency file should have lower and upper bounds of the
version:

    # use 1.0.1 but allow source files to suppress deprecation warnings/errors
    # back to how it was in 0.6.0
    somedep >= 1.0.1 and 0.6.0
    # similar, but use 0.6.0 by default
    somedep >= 0.6.0 and 1.0.1

And in source files:

    useversion somedep 0.6.0

Skip `use` entirely?
--------------------

Not sure if even `use` is necessary? Maybe it is better to have smaller
modules and upgrade one module at a time? "Modules" could perhaps even
be single-file modules?

While `use` lines makes it easier to audit/review files, that could also
be done with some kind of tooling, e.g. a command that shows which
classes / modules / qualifiers(`!` etc.) are in use by each source file.