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.  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.

> 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?

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.

> 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>

Reply via email to