I am bringing Ruby into the discussion so that I can simply point to an ostensive/empirical example - it spares all of us from the tedious "define it!" game.
It depends on which evaluation strategy you are using. Call by value or call by reference.
def f
return Time.now
end
f == f
It produces exactly the same effect as the one I am going for. Look past the syntax.
I don't know Ruby. In your example, if you're comparing the function itself, it is true that
f == f
But it's not true if that's function invocation and there are implicit arguments. Applying a function and comparing its definition are of course different.
The evaluation strategy must come after we agree whether we're comparing values after invocation or definitions. If it's invocations, the evaluation strategy you pick can change the meaning of the program, so that we must discuss semantics.
A straightforward way can be to simply compare the text of the functions, as written in your programming language of choice, in this case Ruby.
Just take the text of both functions, do a diff, and if it says they are the same, they are the same.
Another comparison could be more abstract, since we know there's more than one way to accomplish the same with a programming language: two functions are the same if, given the same input, they produce the same output. You can either prove this by extension, if the number of possible inputs is finite and small, or you can prove it logically. With some languages which enforce purity using types, you can even show two functions are the same just by looking at their signatures, no need to evaluate anything! (this is one advantage of some statically typed languages, by the way!)
> There are no implicit arguments to the function I have in mind. Passing an argument to the function I have in mind is an error.
Yes, there are implicit arguments. You don't see them because they are implicit! A function that returns the moment in time, "now", of course depends on an implicit argument: the current time! How else is it going to know the moment of "now", otherwise? Think about how such a function is implemented.
Indeed. I pointed this out and provided a link in my first post on this thread.
>You don't see them because they are implicit!
The fact that my function takes no arguments is implicit in the specification of my function. I know because I said the English sentence "The function that I have in mind takes no arguments".
You seem to be suggesting that I don't know what function I am thinking about but you do. This is a very peculiar hypothesis.
Your function does take implicit arguments. There's no way your Ruby function can return the current time ("now") without external dependencies that supply that time.
If you want to argue otherwise, you must provide this hypothetical implementation that complies with your specs. I'm telling you that your function effectively can't exist as you describe it. In order for your function to work it requires an implicit argument (the "world" if you want to be coarse, though in this case we know it's the time).
If you want to argue that
magical function is not magical function
that's fine, but also uninteresting. Magic is not bound by the constraints of the physical universe. We generally don't find arguing about leprechauns and unicorns for this reason (at least, not seriously).
You are asking me to provide the hypothetical implementation for a real-world function?
I don't know how to respond to this. Just observe the thing I am showing you. THAT is what I am talking about. It's right before your eyes - I took it from my head and made it real.
>If you want to argue that
I DON'T want to argue! All I am doing here is expressing myself - you are the one jumping down my throat.
This is me telling you that I am not interested in any social game of figuring out "who is right or who is wrong". If that's the game you are playing - I am happy to terminate the interaction.
What I mean by f() != f() in the abstract is precisely that Ruby program in the concrete. Nothing more - nothing less.
There is no room for "right" and "wrong" here. Those are moral judgments and I've committed no moral violation of any sort.
I'm asking you to provide the actual implementation of your hypothetical function now().
I don't need to know the implementation of the real function Time.now from Ruby because, without looking at its source code, I can tell you that it has implicit arguments.
How can I tell this? Because it's impossible for your Ruby program to tell the time without some kind of interaction with an external source (be it the computer clock, the internet or whatever); this source is your implicit parameter and it's why two invocations of your function don't return the same value. It is impossible for your function not to have this source of time, either implicitly or explicitly.
If you disagree, then please explain how your function tells time.
And I am asking you to provide the actual implementation of your hypothetical function equal().
I don't need to know the implementation of the real function == from any programming language because, without looking at any source code I can tell you that it has implicit arguments: a tautology.
If you disagree, then please explain how equality functions.
It depends on which evaluation strategy you are using. Call by value or call by reference.
It produces exactly the same effect as the one I am going for. Look past the syntax.