Re: need help..



On Sat, 02 Apr 2005 17:00:06 -0500, in comp.lang.c , dot@xxxxxxx
wrote:

>On Sat, 02 Apr 2005 20:00:39 GMT, Keith Thompson <kst-u@xxxxxxx> wrote:
>
>>>>3) Quality compilers warn about the ``if (foo = 0)'' construct.
>>>
>>> It should be a syntax error.
>>
>>In a different language, sure. In C, an assignment is an expression
>>that yields the value assigned; changing that would break too much
>>existing code.
>
>If the compiler can detect it sufficiently to warn, it can hand out an
>error, stop compilation and force you to fix it.

point is, it might be able to warn you, but its a perfectly legal
construct, and one that many people use deliberately.

>Frankly, it would have made more sense to have the testing done on a single
>=, & or | marks and use the doubles for assignment along with >> and <<
>which are used for bit shifts.

If you have a time machine, pop back thirty odd years and mention that
to the designers of BCPL and B. Otherwise, you'll need to discuss it
in the context of a new language.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
.



Relevant Pages

  • Re: need help..
    ... >>> It should be a syntax error. ... Making an assignment invalid in a condition but valid ... But I'd much rather just learn the language and use it. ... You can use your macros if you like, but I guarantee they'll make it ...
    (comp.lang.c)
  • Re: Using function name as variable?
    ... >> b) any reference without parentheses always refers to the local variable ... But the fact remains that the script engine does not understand what we are ... > an "invalid assignment" error. ... > syntax error). ...
    (microsoft.public.scripting.vbscript)
  • Re: Using function name as variable?
    ... > a) any reference with parentheses always results in a recursive invocation ... Is there a context where this assignment ... if this is just a syntax error (even a runtime ...
    (microsoft.public.scripting.vbscript)
  • Re: assignment expression peeve
    ... > in code is that is it resembles, to some degree, natural language. ... specific disagreement about your contention that assignment - as - ... described and about which other imperatives are expressed within the ...
    (comp.lang.python)
  • Re: IsString
    ... Thus assignment NEVER copes the object, it simply stores a pointer to the bound object in the part of the local namespace allocated to that name. ... Although it appears at first glance that there is a direct correspondence between hands and things, it is crucial to realise that the relationship is mediated by a holding - the hand identifies a particular holding, which in turn identifies a particular thing. ... There is in fact another layer of indirection - the programmer refers to hands using strings, but this is just part of the language used to express programs textually: the correspondence between these strings and the hands they refer to is called a manual. ...
    (comp.lang.python)