Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

haskell weenies

Name: Anonymous 2015-10-21 12:48

<kant> Why doesn't this work? http://pastebin.com/7qMqFRg5

var phrase = "hi there";
var changephrase = function() {
phrase = "good bye";
};

console.log(phrase);

<aristotle> kant: it works
<Plato> kant: Did you try bombing it?
<aristotle> kant: not sure what you are expecting it to do
<Plato> When will people start using Gist instead of fucking pastebin?
<kant> Plato: I'm thinking about it.
<kant> aristotle: The phrase should be changed to "good bye", but isn't.
<marx> no it shouldn't
<aristotle> kant: then maybe you should execute the function
<marx> a function don't call itself without you calling it :-D
<kant> Hmmm.
<Plato> marx: Sounds like a philosophical statement.
<aristotle> try console.log(changephrase(phrase));
<Plato> aristotle: Are you joking?
<marx> likely the interpreter is just punishing you for using global variables
<Plato> marx: Lambda all the way.
<Plato> Jk.
<aristotle> Plato: no, I am not a hipster
<Plato> marx: He's punishing him for using states.
<Plato> #fuckmutability
<marx> fucking mutable state
<marx> kant: rewrite your code in Haskell so it's easier to reason with. It is impossible to understand such code with so much mutating state.
<Plato> marx: ily.
<kant> antarn: What do you mean by mutating state?
<aristotle> kant: he is suggesting you don't change the global var phrase in the function
<aristotle> kant: instead, make a new local var, change that, and return it
<aristotle> kant: if you try my suggestion you will see that it logs nothing
<kant> aristotle: But why can't I change the global var?
<aristotle> kant: you can
<aristotle> kant: Plato is following a specific philosophy that doesn't like such global state

Name: Anonymous 2015-10-22 15:20

holy shit these people are retarded

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List