The Cellar  

Go Back   The Cellar > Main > Technology
FAQ Community Calendar Today's Posts Search

Technology Computing, programming, science, electronics, telecommunications, etc.

Reply
 
Thread Tools Display Modes
Old 11-29-2010, 12:52 PM   #31
Flint
Snowflake
 
Join Date: Mar 2006
Location: Dystopia
Posts: 13,136
Quote:
This is because !(a) is actually calling a().
No. It isn't. It is crucial for you to realize that this is where you are wrong.

!(a) where (a) is a bool function evaluates true or false, it doesn't literally execute the function.



Really, it doesn't. It doesn't do that.



Really.
__________________
******************
There's a level of facility that everyone needs to accomplish, and from there
it's a matter of deciding for yourself how important ultra-facility is to your
expression. ... I found, like Joseph Campbell said, if you just follow whatever
gives you a little joy or excitement or awe, then you're on the right track.

. . . . . . . . . . . . . . . . . . . . . . . . . . Terry Bozzio
Flint is offline   Reply With Quote
Old 11-29-2010, 01:56 PM   #32
Happy Monkey
I think this line's mostly filler.
 
Join Date: Jan 2003
Location: DC
Posts: 13,575
You are wrong. The 'true' or 'false' that a() evaluates to is the one that is returned in the body of the function as it executes. I don't know where you think that value comes from if it doesn't come from the execution of the function.

Try this:

Add a second parameter to a() and b(), and pass in a unique value to each call. At the beginning of a() and b(), print out that value.

Quote:
bool a(pw, x)
{
cout << "a " << pw << " " << x << endl;
...
}

bool b(pw, x)
{
cout << "b " << pw << " " << x << endl;
...
}

while !(a(pw,1)) or !(b(pw,2))
{
if !(a(pw,3))
call (a(pw,4))

if !(b(pw,5))
call (b(pw,6))
}
If you keep entering short, numberless passwords then you will see all six.
__________________
_________________
|...............| We live in the nick of times.
| Len 17, Wid 3 |
|_______________| [pics]
Happy Monkey is offline   Reply With Quote
Old 11-29-2010, 02:57 PM   #33
Flint
Snowflake
 
Join Date: Mar 2006
Location: Dystopia
Posts: 13,136
Everything that you've said was supposed to happen (posts #8, 13, 15, 19, 25) doesn't happen. I don't see how showing you another example that doesn't happen will be more convincing than the overwhelming evidence I've already presented.
__________________
******************
There's a level of facility that everyone needs to accomplish, and from there
it's a matter of deciding for yourself how important ultra-facility is to your
expression. ... I found, like Joseph Campbell said, if you just follow whatever
gives you a little joy or excitement or awe, then you're on the right track.

. . . . . . . . . . . . . . . . . . . . . . . . . . Terry Bozzio
Flint is offline   Reply With Quote
Old 11-29-2010, 05:51 PM   #34
Happy Monkey
I think this line's mostly filler.
 
Join Date: Jan 2003
Location: DC
Posts: 13,575
It will happen.

I withdrew my predictions from 8 and 13 already.

I don't think you've tested whether the things I've said were supposed to happen in 15, 19, and 25 are happening. They wouldn't affect what you see in your normal execution, just what is happening behind the scenes. As I said, the while loop is correcting for the strange behavior of the functions, and it seems to me that all of the overwhelming evidence you have presented includes the while loop.

If you test the functions alone, not in a while loop, you can see the side effects:

main()
{
cin.getline(pw)
if (a(pw))
cout << "a returned true, pw is now " << pw << endl;
else
cout << "a returned false, pw is now " << pw << endl;
}

If you enter a bad password, it will ask for another. If you enter another one, it will return false, even if the second one was good.
__________________
_________________
|...............| We live in the nick of times.
| Len 17, Wid 3 |
|_______________| [pics]
Happy Monkey is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -5. The time now is 02:38 PM.


Powered by: vBulletin Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.