The pwan's weblog without a name

I'm hurting for a decent byline here, as you can tell.

[Previous entry: "Donna Barr Interview"] [Main Index] [Next entry: "Alexander DeLarge As Jag Spokesman"]

11/06/2002 Entry: "Why I love functional programming more each day"

No Peaches for me last night. I wasted last night tracking down a compiler problem in a really stupid CS656 programming assignment. I love functional programming more each day. Death to the dreaded side effect ! Boring particulars in the extended section. Upshot is the c++ compiler we have to use for the course doesn't process the if statement in correctly.


What it boiled down to was



A = expr1;
if (f(A) == expr3) {
A = expr4;
} else if (g(A) == expr5) {
A = expr6;
}


What was happening was control was reaching the first conditional, so A=expr4, then it was falling into the second conditional as well, so instead of A having expr1 like it should have, it had expr4 now, and g(expr4) was expr5. Uggles !! When I changed it to



A = expr1;
B = A;
if (f(B) == expr3) {
A = expr4;
} else if (g(B) == expr5) {
A = expr6;
}


everything works fine because the value of B doesn't change in the middle of the first conditons processing. There's no chance that even if control reaches the second condition, which it shouldn't, it's in the else clause, dammit, it's value won't be impacted by the first condition block's processsing, since there's no assignments to B in it.

Grumble, grumble, grumble.

Twigged and Blazing

American Samizdat
Anita Rowland
Bagdad Burning
City Comforts Blog
DC Metro Action
pwan's del.icio.us inbox
Follow Me Here...
Green Car Congress
iddybud
insightcentral.net
Lambda the Ultimate
lemonodor
librarian.net
metafilter
Mister Pants
Politics in the Zeros
purse lip square jaw
PwanWiki
randomWalks
rc3.org
Social Design Notes
socialfiction
Spin of the Day
the revealer
This Is Broken
Viridian Design
worldchanging
wood s lot

Don't Forget About These...

Constitution
Universal Declaration of Human Rights

Know Your Rights !

Archives

Not so grey Greymatter stuff
Dusty Blogger bits

More About Jude...

Bio Page for 02001
Bio Page for 02002

FOAF File
GPG public key

AIM: pwannygoodness

Masthead

ISSN 1540-0670

The Baba-Yaga Bird Yurt

The Baba-Yaga Bird Yurt