avva: (Default)
[personal profile] avva
(интересно будет только программистам и сочувствующим, знающим язык C)

Интервьюировал кандидата, который в своем коде на C все время писал так:

for (unsigned i = 0; i < ...


Забавно. Вполне нормальный C, конечно, но в последний раз я видел код, который использовал unsigned, а не unsigned int, где-то в середине 90-х, наверное. Веет от этого кода чем-то старинно-олдскулным.

Date: 2011-05-25 10:05 am (UTC)
From: [identity profile] dimrub.livejournal.com
После этого человек понабирается еще опыта, и снова начинает использовать unsigned там, где это вполне разумно (например, для переменных цикла с заведомо ограниченным числом итераций).

Date: 2011-05-25 12:57 pm (UTC)
From: [identity profile] msh.livejournal.com
Для счетчика цикла с ограниченным числом итераций есть int, его заодно и писать быстрее. В подавляющем большинстве случаев unsigned либо не имеет смысла, либо должен быть с явным размером.

Date: 2011-05-26 02:26 pm (UTC)
From: [identity profile] igorlord.livejournal.com
If I see code that uses int instead of unsigned, I'd usually fix it.

There is a reason for types in a typed language. Types is to LIMITING the possible domain of the variable. If a negative value for something makes no sense, it should be impossible for that variable to even contain a negative value. It is a part of the general "programming by contract". The more narrow the contract, the easier it is to understand and reason about the code.

December 2025

S M T W T F S
  123 4 56
78 9 10 11 1213
1415 1617181920
21 22 23 24 2526 27
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Dec. 29th, 2025 09:23 pm
Powered by Dreamwidth Studios