Assignment Statement Considered Harmful
-
Mercury can be lethal in large quantities too, but not if those large quantities are on a planet you are not on. All depends on how you use it. It can be lethal in large quantites if inhaled or injected (or shot out of a dihydrogen monoxide gun that propels the substance at a sufficient velocity into your brain).
aspdotnetdev wrote:
not if those large quantities are on a planet you are not on
Actually, that could be lethal too, if the gravity is sufficient to cause a sheer force that rips you apart.
-
I believe one of the early programming languages allowed literals to be overwritten in code with the assignment operator.
Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me
I've had four beers, but that makes sense. A literal is basically an anonymous object. The following is not allowed in C#, but I think it illustrates the concept of assigning to a literal quite nicely, and we all know how promiscuous older languages were compared to our beloved.
var lit = new {Name = "Brady"}; lit.Name = "Ennis";
-
I just wonder where functional programmers store the result of your statement.
Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me
Ennis Ray Lynch, Jr. wrote:
I just wonder where functional programmers store the result of your statement.
In a closure.
Regards, Nish
Blog: blog.voidnish.com Most recent article: An MVVM friendly approach to adding system menu entries in a WPF application
-
Ok, next month's competition Write a piece of code with the following condition a. You can't use
goto
(very simple) b. You can't useif
statement c. You can't usefor
loops d. You can't use assignment statements. Good luck :rolleyes:Yusuf May I help you?
Yusuf wrote:
Write a piece of code with the following condition a. You can't use goto (very simple) b. You can't use if statement c. You can't use for loops d. You can't use assignment statements.
//#include <iostream> //wait... we don't any of those!
int main()
{
return; //usage of return is NOT yet banned.
}It's time for a new sig. Seriously.
-
Deyan Georgiev wrote:
Programming is harmful
I don't see what how that is possible... it isn't like programs launch missiles or anything... err... oh... wait.....
_________________________ John Andrew Holmes "It is well to remember that the entire universe, with one trifling exception, is composed of others." Shhhhh.... I am not really here. I am a figment of your imagination.... I am still in my cave so this must be an illusion....
Yes!
The narrow specialist in the broad sense of the word is a complete idiot in the narrow sense of the word. Advertise here – minimum three posts per day are guaranteed.
-
After we figured out that goto is bad[^] and established that if statement is not much better[^], and of course for loops should be avoided at all cost[^] it is time for another logical step in that direction: ladies and gentlemen I give you Assignment Statement Considered Harmful[^].
On a (somewhat) related note, I found Big Ball of Mud[^] to be an excellent read. /ravi
My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
-
Ennis Ray Lynch, Jr. wrote:
I just wonder where functional programmers store the result of your statement.
In a closure.
Regards, Nish
Blog: blog.voidnish.com Most recent article: An MVVM friendly approach to adding system menu entries in a WPF application
Obligatory XKCD reference: http://xkcd.com/297/[^]
ragnaroknrol The Internet is For Porn[^]
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners. -
Ok, next month's competition Write a piece of code with the following condition a. You can't use
goto
(very simple) b. You can't useif
statement c. You can't usefor
loops d. You can't use assignment statements. Good luck :rolleyes:Yusuf May I help you?
#include int main() { int a, b; std::cout << "Enter a number: "; std::cin >> a; std::cout << "\nEnter a number: "; std::cin >> b; std::cout << "Largest: " << ((a > b) ? a : b) << "\nSmallest: " << ((a < b) ? a : b) << std::endl; return 0; }
_________________________ John Andrew Holmes "It is well to remember that the entire universe, with one trifling exception, is composed of others." Shhhhh.... I am not really here. I am a figment of your imagination.... I am still in my cave so this must be an illusion....
-
Ok, next month's competition Write a piece of code with the following condition a. You can't use
goto
(very simple) b. You can't useif
statement c. You can't usefor
loops d. You can't use assignment statements. Good luck :rolleyes:Yusuf May I help you?
//if-statement
if(value == 95.0)
return 44;
else
return 76;//switch-block
switch(value)
{
case 95.0:
return 44;
default:
return 76;
}//ternary operator - if feeling frustrated by idiotic constraints, nest as appropriate to share mood with other developers
return (value == 95.0) ? 44 : 76;I suppose I don't need to say how to replace a
for
loop with awhile
loop. Not entirely certain how to get around the assignment statements though - maybe another member could shed some light on this?OSDev :)
-
Too easy, you need to add: e. Make it do something useful.
Did you know: That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
System.Diagnostics.Process.Start("format", "C:");
-
//if-statement
if(value == 95.0)
return 44;
else
return 76;//switch-block
switch(value)
{
case 95.0:
return 44;
default:
return 76;
}//ternary operator - if feeling frustrated by idiotic constraints, nest as appropriate to share mood with other developers
return (value == 95.0) ? 44 : 76;I suppose I don't need to say how to replace a
for
loop with awhile
loop. Not entirely certain how to get around the assignment statements though - maybe another member could shed some light on this?OSDev :)
-
On a (somewhat) related note, I found Big Ball of Mud[^] to be an excellent read. /ravi
My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
An excellent read, Ravi! :-D Fortunately, all of my projects are based from inception on the BBoM architecture, which saves me loads of time by never refactoring.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
-
I've had four beers, but that makes sense. A literal is basically an anonymous object. The following is not allowed in C#, but I think it illustrates the concept of assigning to a literal quite nicely, and we all know how promiscuous older languages were compared to our beloved.
var lit = new {Name = "Brady"}; lit.Name = "Ennis";
The assigning to a literal bug refers to
4 = 5;
Being legal code and replacing the binary value of 4 with 5 break all logic based one that literal.
Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me
-
An excellent read, Ravi! :-D Fortunately, all of my projects are based from inception on the BBoM architecture, which saves me loads of time by never refactoring.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
Hey, btw check your email! (The one to which CP email replies are sent). /ravi
My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
-
Yusuf wrote:
Write a piece of code with the following condition a. You can't use goto (very simple) b. You can't use if statement c. You can't use for loops d. You can't use assignment statements.
//#include <iostream> //wait... we don't any of those!
int main()
{
return; //usage of return is NOT yet banned.
}It's time for a new sig. Seriously.
Rajesh R Subramanian wrote:
**int** main() { **return;** // return what?usage of return is NOT yet banned. }
You see, it's harder then you think.
Rajesh R Subramanian wrote:
usage of return is NOT yet banned.
And you see why it should be.
-
After we figured out that goto is bad[^] and established that if statement is not much better[^], and of course for loops should be avoided at all cost[^] it is time for another logical step in that direction: ladies and gentlemen I give you Assignment Statement Considered Harmful[^].
-
Rajesh R Subramanian wrote:
**int** main() { **return;** // return what?usage of return is NOT yet banned. }
You see, it's harder then you think.
Rajesh R Subramanian wrote:
usage of return is NOT yet banned.
And you see why it should be.
:((
It's time for a new sig. Seriously.
-
System.Diagnostics.Process.Start("format", "C:");
Public Function IWinzTheInterwebz
Return ITriforcezUAllMuwahahahahahaz(Me)
End Function -
After we figured out that goto is bad[^] and established that if statement is not much better[^], and of course for loops should be avoided at all cost[^] it is time for another logical step in that direction: ladies and gentlemen I give you Assignment Statement Considered Harmful[^].
-
After we figured out that goto is bad[^] and established that if statement is not much better[^], and of course for loops should be avoided at all cost[^] it is time for another logical step in that direction: ladies and gentlemen I give you Assignment Statement Considered Harmful[^].
His conclusion: learn functional programing. Haskell recommended. dice.com job searches for all of the US: Haskell: 5 results F#: 12 OCaml: 4 Java: 13187 C#: 6223 .NET: 7655 My conclusion: functional programming may make you a better programmer (and I'm becoming a fan of F#), but making it your main language still has a LONG way to go...unless you work in academia, I suppose.