3 ms·
In F#, can you ask a function object what its original name was? If so, what is the original name of "test1" and "test2" in your example? That's what python is
by jjnoakes 8y ago
In F#, can you ask a function object what its original name was? If so, what is the original name of "test1" and "test2" in your example?
That's what python is doing and why the two are different.
(I don't think a language should track that sort of thing, but that's a different story).
- nikofeyn 8y agoi am not for sure what you mean by "original name". the value of each of those function definitions are: val test1 : x:int -> int val test2 : x:int -> int you call them the same way, and they have the same type. a caller has no knowledge of how they were defined because it isn't important. they're identical.
- yorwba 8y ago> they're identical. Does that mean that test1 == test2 will return true? Personally, I have found it very useful for debugging that function objects in Python carry their name. That makes it much easier to find out where something is coming from.
- jjnoakes 8y agoI mean in python, one can ask a function what it was originally defined as. Sounds like in F# one can not, so that's why there's a difference in python between "var x = lambda..." and "def y(): ..."; the latter knows it is named "y" and the former has no idea what its name is (so it is "lambda").