Open timotheecour opened 3 years ago
In case1
, wouldn't you have two functions with the same name and signature? I don't see why that should compile at all.
In case1, wouldn't you have two functions with the same name and signature? I don't see why that should compile at all.
procs declared in current module take precedence; conflicts only occur if you'd have ambiguities via imports:
import a # contains proc fn(a: int)=discard
import b # contains proc fn(a: int)=discard
fn(1)
it's a reasonable rule and it's in the manual
The thing is it helps maintainability if the default is closed identifiers, and the current rules are very simple, much, much simpler than trying to nail down exactly which dependent expressions should be open and which should be closed.
We want closed by default (imo) because open identifiers hurt the compilers ability to emit diagnostics while parsing the generic definition, and also make the generic more brittle as it could be broken by subsequent overloads that it has no control over
Innocuous looking refactorings such as case1=>case2 below are actually currently causing breaking changes due to the fact that a single generic sigmatch currently implies closedSymChoice instead of openSymchoice.
example
current behavior
nim r -d:case1 main override # open symchoice
nim r -d:case2 main 1.0 # closed symchoice
proposed behavior
nim r -d:case1 main override # open symchoice
nim r -d:case2 main override # open symchoice
ditto for case3, caes4 since in each case the sigmatch is either generic or involves > 1 overloads
links
notes
this is a breaking change, but one that will actually allow code refactorings without breaking changes, so less breaking changes down the line.
implementation
logic to change should be inside: see
if i <= 1 and r != scForceOpen:
in semtempl.symChoice