Page 5 of 7

Re: Pure functions? What the heck are those ?!?!

Posted: Sat Jul 16, 2022 9:37 pm
by Flannel Jesus
To the contrary, it actually sounds like your entire point in this thread is to bicker over definitions. The term "pure function" already has a definition, and you're now apparently arguing that we should change the definition, and you're putting me down for not accepting your changed definitions. So it sounds like bickering over definitions was your point from the start, no?

Re: Pure functions? What the heck are those ?!?!

Posted: Sat Jul 16, 2022 9:41 pm
by Skepdick
Flannel Jesus wrote: Sat Jul 16, 2022 9:37 pm To the contrary, it actually sounds like your entire point in this thread is to bicker over definitions. The term "pure function" already has a definition, and you're now apparently arguing that we should change the definition, and you're putting me down for not accepting your changed definitions. So it sounds like bickering over definitions was your point from the start, no?
Define it however the fuck you want. I really don't care about definitions.

I am asking you whether you recognise by observation/intuition (either you do; or you don't) that according to the status quo one of these functions is classified as "pure" and the other one isn't.

Even though they are exactly the same function.

Code: Select all

bool f(x){
   if x == 1:
       return true;
   else:
       return false;
}

Code: Select all

void f(x){
   if x == 1:
       throw Yes;
   else:
       throw No;
}

Re: Pure functions? What the heck are those ?!?!

Posted: Sat Jul 16, 2022 9:43 pm
by Flannel Jesus
What does "x" mean in the second function? Where does it come from? Is it a global variable?

Re: Pure functions? What the heck are those ?!?!

Posted: Sat Jul 16, 2022 9:44 pm
by Skepdick
Flannel Jesus wrote: Sat Jul 16, 2022 9:43 pm What does "x" mean in the second function? Where does it come from? Is it a global variable?
It means exactly the same thing as x in f(x) = x

It's a variable you pass to the function.

Re: Pure functions? What the heck are those ?!?!

Posted: Sat Jul 16, 2022 9:51 pm
by Flannel Jesus
Ah okay, that wasn't obvious to me because there was no apparent arguments in the function definition.

Are you sure they aren't both seen as pure functions?

Re: Pure functions? What the heck are those ?!?!

Posted: Sat Jul 16, 2022 9:59 pm
by Flannel Jesus
Is it impure because you're throwing the result, rather than returning it? The idea that a pure function cannot throw errors is somewhat opinion based and there's wiggle room on that ideologically.

Re: Pure functions? What the heck are those ?!?!

Posted: Sat Jul 16, 2022 10:03 pm
by Skepdick
Flannel Jesus wrote: Sat Jul 16, 2022 9:51 pm Are you sure they aren't both seen as pure functions?
It depends on who you ask.

Some people have caught on/corrected their misconception.

Re: Pure functions? What the heck are those ?!?!

Posted: Sat Jul 16, 2022 10:05 pm
by Flannel Jesus
But neither of them are pure according to the redefinition you offered up in your original post.

Re: Pure functions? What the heck are those ?!?!

Posted: Sat Jul 16, 2022 10:05 pm
by Skepdick
Flannel Jesus wrote: Sat Jul 16, 2022 9:59 pm Is it impure because you're throwing the result, rather than returning it? The idea that a pure function cannot throw errors is somewhat opinion based and there's wiggle room on that ideologically.
The two programs are semantically equivalent. They signal 1 bit of information. They just encode the information differently.

Re: Pure functions? What the heck are those ?!?!

Posted: Sat Jul 16, 2022 10:06 pm
by Skepdick
Flannel Jesus wrote: Sat Jul 16, 2022 10:05 pm But neither of them are pure according to the redefinition you offered up in your original post.
Precisely.

A pure function has no side-effects.
There is no difference between outputs, effects and side-effects. Information is information!
Therefore a pure function has no outputs, effects and side-effects.

A pure function does nothing.

Re: Pure functions? What the heck are those ?!?!

Posted: Sat Jul 16, 2022 10:09 pm
by Flannel Jesus
So why would anybody be interested in using your new definition? We could use the existing definition, which refers to things what are useful and do things, or we could choose to switch to your definition, which doesn't refer to anything useful, doesn't refer to anything anybody has any reason to use or think about ever?

Because who has reason to use or think about functions that don't do anything?

If you're trying to make a case for the redefinition, I'm not seeing any pros

Re: Pure functions? What the heck are those ?!?!

Posted: Sat Jul 16, 2022 10:12 pm
by Skepdick
Flannel Jesus wrote: Sat Jul 16, 2022 10:09 pm So why would anybody be interested in using your new definition? We could use the existing definition, which refers to things what are useful and do things, or we could choose to switch to your definition, which doesn't refer to anything useful, doesn't refer to anything anybody has any reason to use or think about ever?

Because who has reason to use or think about functions that don't do anything?

If you're trying to make a case for the redefinition, I'm not seeing any pros
I don't care about definitions.

You can define this color as green.
red.png
What I do care about is having as few misleading misconceptions in my head as possible.

A function that has no (side)effects would be like a calculator with no screen.

Far more importantly, if pure functions existed in reality they would be impervious to cryptanalysis or side-channel attacks.
Pure functions would be immmune to reverse engineering.

They would be ideal black boxes and there are no such things in this universe.

Re: Pure functions? What the heck are those ?!?!

Posted: Sat Jul 16, 2022 10:25 pm
by Flannel Jesus
But you just said pure functions are functions that don't do anything. Of course they would be impervious to crypto analysis, any form of attack, and nobody would want to reverse engineer them, because you've defined them as "functions that don't do anything"

Re: Pure functions? What the heck are those ?!?!

Posted: Sat Jul 16, 2022 10:32 pm
by Skepdick
Flannel Jesus wrote: Sat Jul 16, 2022 10:25 pm But you just said pure functions are functions that don't do anything. Of course they would be impervious to crypto analysis, any form of attack, and nobody would want to reverse engineer them, because you've defined them as "functions that don't do anything"
Obviously this is a judgment relative to the observer's reference frame.

For all you know your calculator (which has no screen) has calculated the answer to 5+5. You don't know.
Which leaves you with two hypotheses about it.

A. It has performed the computation, but it has failed to communicate it.
B. It hasn't performed the computation.

Those two things are observationally equivalent if you ONLY monitor the regular outputs.
Those two things are NOT observationally equivalent if you also monitor side-channels. Heat, power draw, execution time, memory usage etc.

The example I used throughout this thread is like this...

Code: Select all

def f():
	5+5

Code: Select all

def f():
	pass
Mathematically they are the same function.
Empirically they aren't.

Re: Pure functions? What the heck are those ?!?!

Posted: Sat Jul 16, 2022 10:36 pm
by Flannel Jesus
I have no idea what your point is, and I would honestly be surprised if anybody but you does at this point.