You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Type checking modifier which allows interleaved support nominal and structural checking behaviours #24519
How about introduction a new type checking modifier operator, that is implemented for type checking only. Which would allow the best of both worlds, nominal an structural typing paradigms.
As far as I know '$' is not used for specially many yet, so how about allowing $ donate use nominal type checking for the following use cases.
I would prefer to have everything swapped around, but that could break alot of backwards compatibility, maybe it could be debated to have a global compiler and localised ts file setting
It may also be better to rather use a variable naming convention, that is prefixed with dollar, because then one explicit knows, what type of checking is being used... As may loos sight of things on which equality typechecking operator to use.
The compiler could also have auto correct mode for assignment to dollar assignment instead of the
Use Cases
nominal variants
assignment:
$=
call signature only:
(index :$ {index :number} => void
call signature and return:
(index :$ {index :number} $=> void
return:
(index : {index :number} $=> void
type, implies nominal should also be used were , unless explicitly cast away..
type test $= testing;
variable, implies nominal should also be used were , unless explicitly cast away..
For each nominal declare type their is an additional generated structure type name. The same behaviour as for classes, were their is a generated interface..
The $ identify must always be used in a type definition and assignments, so that it is explicitly obvious as to how type checking is being performed.
type nTypeA $= {a : string}; .nominal type
type nTypeB $= {a : string}; // nominal type
type TypeA = nTypeA or // structured type
type TypeA = typeof NTypeA //structured type
// type checking ensure consistence, that nominal type variable a $= must be used..
Andy (Andrewkraft) (@Andy-MS) I was typically looking for a way to communicate everywhere explicit what is going on. So if you could imagine reading a book, then I know for using modified $ plus character, which forms the token identifier. Were ever I read the code, I know explicitly that whether nominal typing or structure typing rules are being applied. Yes I agree on may forget to put the dollar in, but that is why their is a compiler, which would be able to determine this and underline it for you. Maybe casting from structural to nominal and visa needs to be a little bit more verbose.
The ide could also provide auto correction of operators to nominal operators for readability purposes,
which would save having to type $ character for explicit readability.
Typically I would imagine, if I were to develop a new package, module, file, project. I would develop the module using nominal typing throughout my current project internally and only when I have to interact with external libraries or 3 party code, then I would consider using, or should be force to use structural typing, because it allows decoupling from 3rd party libraries, which why I would have also chosen structural typing.(Better internal data structure names, that what may have been provided(typealias). Using this approach would allow me to write more traditional constrained code using nominal typing patterns, unless I choose to do something that requires structural typing.
Their is more to this I should write about, such detail the class hide, that we actually want exposed, which results in mistakes. Such as like in java, communicating, which exceptions can be throw by a function, so consume what types of errors to potentially handling and should have to explicitly, choose to ignore them, by having a short hand re-throw [.a list of exceptions or categories...] try catch shouldn't allow swallowing, by default re-throw unmatched errors.
Classes are their and to hide implementations details and abstraction and simplified use consumer, which allows changing things under the hood, however, classes also high details in this blackbox approach, such as impedance mismatches. Classes supposed be memory only access, but someone actually made it access disk drive. This only ends up being discover production alter on. I have an idea to solve this were classes stipulate a required impedance miss match number, 1 On Die, Node, L1,L2,L3 50 paged, 240 disk,) a class then is not required to call any external function, method that doesn't meet this performance constraint. typically a class aggregate impedance miss match would be determined by lowest common denominated. to improve the lowest common denominator, a class functions would have to wrapped external call with impedance mismatch, which would provide caching and specify a new impedance miss match. static analysis could be develop to solve this problem, by ensure certain io constraints, impedance miss matches are met by a written function.
I hope that this gives you a clear idea, of how clearly and explicitly I would like a language to communicate things. I don't want to have rely on IDE enhancements.. they typically slow, so is using the mouse having to wait for hovering and effects, speed, instance, speed!!
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
Activity
wesleyolis commentedon Jun 10, 2018
Andy (Andrewkraft) (@Andy-MS) I was typically looking for a way to communicate everywhere explicit what is going on. So if you could imagine reading a book, then I know for using modified $ plus character, which forms the token identifier. Were ever I read the code, I know explicitly that whether nominal typing or structure typing rules are being applied. Yes I agree on may forget to put the dollar in, but that is why their is a compiler, which would be able to determine this and underline it for you. Maybe casting from structural to nominal and visa needs to be a little bit more verbose.
The ide could also provide auto correction of operators to nominal operators for readability purposes,
which would save having to type $ character for explicit readability.
Typically I would imagine, if I were to develop a new package, module, file, project. I would develop the module using nominal typing throughout my current project internally and only when I have to interact with external libraries or 3 party code, then I would consider using, or should be force to use structural typing, because it allows decoupling from 3rd party libraries, which why I would have also chosen structural typing.(Better internal data structure names, that what may have been provided(typealias). Using this approach would allow me to write more traditional constrained code using nominal typing patterns, unless I choose to do something that requires structural typing.
This is some of my yet to be complete thoughts on code readability:
Coding Standards and Conventions, why one needs them; why should one want them and what does one stand to gain.
Their is more to this I should write about, such detail the class hide, that we actually want exposed, which results in mistakes. Such as like in java, communicating, which exceptions can be throw by a function, so consume what types of errors to potentially handling and should have to explicitly, choose to ignore them, by having a short hand re-throw [.a list of exceptions or categories...] try catch shouldn't allow swallowing, by default re-throw unmatched errors.
Classes are their and to hide implementations details and abstraction and simplified use consumer, which allows changing things under the hood, however, classes also high details in this blackbox approach, such as impedance mismatches. Classes supposed be memory only access, but someone actually made it access disk drive. This only ends up being discover production alter on. I have an idea to solve this were classes stipulate a required impedance miss match number, 1 On Die, Node, L1,L2,L3 50 paged, 240 disk,) a class then is not required to call any external function, method that doesn't meet this performance constraint. typically a class aggregate impedance miss match would be determined by lowest common denominated. to improve the lowest common denominator, a class functions would have to wrapped external call with impedance mismatch, which would provide caching and specify a new impedance miss match. static analysis could be develop to solve this problem, by ensure certain io constraints, impedance miss matches are met by a written function.
I hope that this gives you a clear idea, of how clearly and explicitly I would like a language to communicate things. I don't want to have rely on IDE enhancements.. they typically slow, so is using the mouse having to wait for hovering and effects, speed, instance, speed!!
typescript-bot commentedon Jun 25, 2018
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.