On Jan 25, 2007, at 8:31 PM, Daniel Stenning wrote:
http://www.realsoftware.com/feedback/viewreport.php?reportid=vahfpegj
In C , one can both assign a variable to something and test it -
all within
the IF test.
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.
For example in C we can write:
myClass* myRef;
if ( myRef = getA() != NULL )
{ do something with myRef }
elseif myRef = getB() != NULL )
{ do something with myRef }
elseif myRef = getC() != NULL )
{ do something with myRef }
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 <- .
so in RB we would be able to write something like:
Dim myRef As myClass
if myRef FROM getA() <> nil then
.. do something with myRef
elseif myRef FROM getB() <> nil then
.. do something with myRef
elseif myRef FROM getC() <> nil then
.. do something with myRef
end if
If you think this would be a desirable addition to the RB language
sing on
here:
http://www.realsoftware.com/feedback/viewreport.php?reportid=vahfpegj
Or feel free to disagree or discuss it. ( I am sure there are
plenty of
"BASIC" purists who will say this would unnecessarily "pollute" the
language ;) )
I will, although I don't consider myself a "BASIC" purist.
Charles Yeomans
_______________________________________________
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>