Question

In: Computer Science

Explain how coercion can negatively affect type checking but not prevent a language from being strongly...

Explain how coercion can negatively affect type checking but not prevent a language from being strongly typed.

(Programming languages)

Solutions

Expert Solution

Most of the programming languages support conversions in which one data type is converted to Other. These type conversions can be made both implicitly and explicitly which depends on the programmer. Implicit conversion, which is also called coercion, is automatically done by Either Compiler or Interpreter and Some times both in case of programming languages like java.

Explicit conversion, is also known as casting, is performed by Explicit code instructions. Thes codes treat a variable of one data type as belongs to another data type.

The Programming languages that have implicit conversions define that the rules will automatically be implemented when fundamental values are involved.

Let Consider Following Code for better Understanding of implicit and explicit coercion.

double a, b;

a = 3; // implicitly coercion (coercion)

b = (double) 5; // explicitly coercion (casting)

In-Line 2 Integer constant 3 is automatically converted to double before assignment which is Implicit coercion.

In-Line 3 Explicit coercion is performed by involving the destination type with parenthesis.

Every programming language has its rules about how Conversions on Data types can be made Done. Programming Languages with strong typing typically do the little implicit conversion and control the reinterpretation of copies, while Programming languages with weak typing perform many implicit conversions between data types. Weak typing language often allows forcing the compiler to arbitrarily interpret a data item as having different representations. this can be a non-obvious programming error or a technical method to directly deal with the underlying hardware.

In most programming languages, the term coercion is used to indicate an implicit conversion, either through the compilation or during runtime. For example, in an interpretation mixing integer and floating-point numbers (like 10 + 0.20), then either compiler or interpreter or their Combination stuff will automatically convert integer representation into floating-point representation so fractions are not lost.

Explicit type conversions are implied by formulating additional code

(Eg: - adding type identifiers or calling builtin methods) or by coding conversion methods for the compiler to utilize when it otherwise would finish with a type mismatch.

Thus coercion can negatively affect type checking but not prevent a language from being strongly typed as in the case of languages like C, C++


Related Solutions

How can leadership negatively affect the success of a company?
must be at least 150 words and in paragraph form
How can leadership negatively affect the success of a company?
must be at least 150 words and in paragraph form
How fluctuating exchange rates can be beneficial to MNCs and how they can affect MNCs negatively....
How fluctuating exchange rates can be beneficial to MNCs and how they can affect MNCs negatively. You must give one example of each scenario in order to receive full credit for this question. Furthermore, your answer must be purely qualitative. In other words, you should not use any numerical data to answer this question.  
1. From your understanding of the Sarbanes–Oxley Act, explain how you feel it may negatively affect...
1. From your understanding of the Sarbanes–Oxley Act, explain how you feel it may negatively affect America’s stock exchanges. 2. What advantages would China offer foreign companies to list on its exchanges? Are these advantages greater than the disadvantages? Explain. 3. Do you feel that China will eventually control the world’s financial industry? Explain your answer
How can an employee's use of social media positively or negatively affect their company even if...
How can an employee's use of social media positively or negatively affect their company even if done on their own time and from their own personal account(s)?
How can you prevent ovulation? How can you prevent spermatogenesis? How does oogenesis differ from spermatogenesis?...
How can you prevent ovulation? How can you prevent spermatogenesis? How does oogenesis differ from spermatogenesis? What are nurse cells? What causes the release of LH and FSH?
Explain how cobalamin can prevent allergies and toxins.
Explain how cobalamin can prevent allergies and toxins.
What are the roadblocks that prevent Trek from being efficient?
What are the roadblocks that prevent Trek from being efficient?
How does the filibuster affect the workings of Congress, positively and negatively?
How does the filibuster affect the workings of Congress, positively and negatively?
How does the filibuster affect the workings of Congress, positively and negatively?
How does the filibuster affect the workings of Congress, positively and negatively?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT