Jump to content

Talk:Weak typing

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Why not just merge this with strong typing and make one article on typing levels?

[edit]

because this one just doesn't stand on its own. No sources, vague, and a stub if I've ever seen one. --72.207.253.76 (talk) 22:47, 25 February 2013 (UTC)[reply]

typedef does not introduce a new type, just an alias

[edit]

so this cannot be used as an example of a weak typing.

I took this out. Not only does typedef just introduce an alias, but the example as given is nonsensical. "typedef int Date;" gives you no indication (formal or informal) of how this "Date" is supposed to be stored as an integer, so as an example of typing it's inherently flawed. If you want a proper example, you could use Pascal's subrange types, which however don't exist in C. Enums come closest to a subtyping issue.
The example assigning an integer 5 to a float is also weak, because this particular conversion is guaranteed to succeed with no loss of precision. It would be counterproductive for the compiler to warn about it. 82.95.254.249 15:20, 10 August 2007 (UTC)[reply]

get rid of this article?

[edit]

The term "weak typing" is largely meaningless, in that it conflates dynamically typed languages such as JavaScript with languages such as C that simply have no type safety (or are type-safe only at the memory-is-a-sequence-of-bytes level).

Clements (talk) 06:59, 6 January 2009 (UTC)[reply]

That is true! However, I see the current easily read "essay" as an excellent way of handling this contradiction. The term is used in practice and deserves an article like this. Regards 83.255.39.118 (talk) 12:20, 14 October 2010 (UTC)[reply]
Do not get rid of the article. Even if it is "a meaningless term" the page can state that for the benefit of people looking it up so that they can understand the jabbering of people using that meaningless term. --Kcrossle (talk) 19:25, 1 April 2011 (UTC)[reply]
There's redundant info about Weak typing in Type system and Strong typing. In my opinion, Type system should have a brief explanation about both (possibly having the example table currently available in Strong typing), then link to an article that handles both Weak and Strong typing, since the explanation of each is brief and the concepts are compared everytime. This should make for a much cleaner way to organize this knowledge inside wikipedia. (I'm writing this opinion to all 3 current discussion pages) --Roberto.cr (talk) 09:13, 6 May 2011 (UTC)[reply]

C++ example

[edit]
 enum animal {CAT=0,DOG=2,ANT=3};
 animal a = CAT;  /* The enum keyword here is optional in C++ */
 animal b = 1;    /* This is an error in C++ */

This actually a bad example. The reader might think that a C++ compiler will give an error because 1 isn't a number used by the enumeration. The However, compilation will also fail for b = 2. The idea is that enum is strongly-typed because DOG is a type of animal, not 2. Trying this in C will fail all together. —Preceding unsigned comment added by 192.16.199.46 (talk) 15:26, 30 June 2009 (UTC)[reply]

Example is not proper C++ code

[edit]

The example given is not proper C++ code. It should be using a reinterpret_cast<T> rather than a C-style cast. This is a good example of an incorrect use of C++ though. C-style cast should not be used in C++ at all, there is a good reason for the compiler to give you a warning. It either needs to be considered as C or be changed to use reinterpret_cast<T>. Also, C++ is not weakly typed, it is in fact strongly typed, and you can not cast memory to any type freely, even when doing so explicitly. Function pointers can not be cast to variable pointers and vice versa. Sure, you can always force the compiler to ignore the error by using a C-style cast, but it's just asking for trouble.

I also agree on the page being merged with Strong typing (which actually contradicts the information on this page, saying C and C++ are strongly typed). I think it would be more relevant to put on one page information on both kinds of typing.

76.68.173.3 (talk) 20:37, 11 June 2011 (UTC)[reply]

Contradictory definitions

[edit]

This article implies that weak typing means that any implicit conversion is allowed, even if there is plenty of checking elsewhere. The strong typing article indicates that strong typing just means some checking is done. Thus, the one definition is not the opposite of the other. 1Z (talk) 16:37, 22 October 2011 (UTC)[reply]

The only way you Could your

[edit]

The only way I would

ж З з Ѕ ѕ И и І і Ї ї Й й Ј ј К к Ќ ќ Л л Љ љ М м Н н Њ њ О о П п Р р С с Т т Ћ ћ У у Ў

[edit]

ж З з Ѕ ѕ И и І і Ї ї Й й Ј ј К к Ќ ќ Л л Љ љ М м Н н Њ њ О о П п Р р С с Т т Ћ ћ У у Ў — Preceding unsigned comment added by 82.27.200.105 (talk) 19:17, 28 November 2022 (UTC)[reply]