On 26/1/07 01:44, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:

> On Jan 26, 2007, at 01:31 UTC, Daniel Stenning wrote:
> 
>> In C , one can both assign a variable to something and test it - all
>> within the IF test.
> 
> A horrid practice which is a common source of errors.
> 
>> Although this is often considered "bad form" and not easy to read, it
>> is sometimes a useful thing to be able to do, and can even make for
>> simpler to read code, and sometimes even slightly speedier code.
> 
> It's a myth that it makes for speedier code.

Well if the alternative ways of coding such stuff requires more lines of
code ( often involving many more tests branches than would otherwise be
necessary ) then that is necessarily taking up more computing steps.

> I also don't see how you
> can say that it makes for simpler to read code.  Perhaps it is
> occasionally useful, but those times are pretty rare IMHO.

Useful - particularly in those cases when one would like to keep an

If then
Elseif
Elseif
Elseif
Else
End if

Code section intact.  I find that often I am forced to break up such
constructs, merely because I cannot to the above.

> 
>> For example in C we can write:
>> 
>> myClass* myRef;
>> if ( myRef = getA() != NULL )
> 
> Yes, and does this do:
> 
>   1. assign myRef to the truth of "getA() != NULL", and then branch
> based on this same value?  Or does it
>   2. assign myRef to the result of getA(), and then branch based on
> whether it's != NULL?
> 
Its for the above reason that I propose NOT to use the = for assignment.
 
> I'm pretty sure I know the answer, but it depends on the operator
> precedence in the language, and I certainly wouldn't write code that
> depends on it, because the future reader of this code (possibly me) may
> well misunderstand my intent, even if I get it right today.
> 
>> For any new REALbasic equivalent to this kind of thing, I do not
>> think we should use the = sign to do the assignment, as that would
>> lead to confusion. We need some othe new keyword , such as "FROM", or
>> "ASSIGNFROM" etc , or maybe a new operator like <- .
> 
> Well, that would certainly make it clearer.  Still not something I
> would wish on the language, but of course opinions may differ, and I
> respect your right to yours.

  Like most things in a rich language - it would still be down to the coder
to ensure such a feature was used sparingly and only when necessary.
> 
>> I am sure there are plenty of "BASIC"  purists who will say this
>> would unnecessarily "pollute" the language  ;)
> 
> (raises hand and waves it enthusiastically) Here's one!
> 
> Cheers,
> - Joe
> 
> --
> Joe Strout -- [EMAIL PROTECTED]
> Verified Express, LLC     "Making the Internet a Better Place"
> http://www.verex.com/
> 
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> 
> Search the archives of this list here:
> <http://support.realsoftware.com/listarchives/lists.html>
> 


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to