Content deleted Content added
|
|
{{Type systems}}
<span lang="vi" dir="ltr">In</span> [[computer science]], '''type safety''' is the extent to which a [[programming language]] discourages or prevents '''[[type error]]s'''. A type error is erroneous or undesirable program behaviour caused by a discrepancy between differing [[data type]]s for the program's constants, variables, and methods (functions), e.g., treating an integer ('''int''') as a floating-point number ('''float'''). Type safety is sometimes alternatively considered to be a property of a computer program rather than the language in which that program is written; that is, some languages have type-safe facilities that can be circumvented by programmers who adopt practices that exhibit poor type safety. The formal [[type theory|type-theoretic]] definition of type safety is considerably stronger than what is understood by most programmers.
[[Type enforcement]] can be static, catching potential errors at [[compile time]], or dynamic, associating type information with values at [[Run time (program lifecycle phase)|run-time]] and consulting them as needed to detect imminent errors, or a combination of both.
|