4 ms·
Python is a truly bizarre language in this regard. It's behavior is unusual and similar only to a few other less well known niche languages such as C# and Java.
by InclinedPlane 14y ago
Python is a truly bizarre language in this regard. It's behavior is unusual and similar only to a few other less well known niche languages such as C# and Java.
- irahul 14y agoYou might want to add /s http://en.wikipedia.org/wiki/Poes_law http://en.wikipedia.org/wiki/Poes_law
- pdw 14y agoI wish all this "call by x" terminology would just disappear. It's fine if you're discussing ALGOL-60 dialects, which by modern standards were all horribly confused about parameter passing (call by name, anyone?). It's just not helpful at all when discussing modern languages. If we have to keep it, I vote for Kent Pitman's suggestion of "call by identity". (I can't find the reference right now.)
- barrkel 14y agoThe usual phrase I've seen to describe this is "passes references by value". And it's the norm in almost all popular OOP languages since the mid-90s.
- sirclueless 14y agoI like to think of this as "call-by-name". That's because every name in python is actually a lookup in a dictionary mapping strings to values. This is different from languages like C# and Java where some things such as class and function references can actually be thought of as "values". In python, everything that isn't a keyword or a literal is a name, thinking otherwise leads to gotchas.
- pdw 14y agoThe term call-by-name already exists and means something entirely different. It will blow your mind. http://www.cs.sfu.ca/~cameron/Teaching/383/PassByName.html http://www.cs.sfu.ca/~cameron/Teaching/383/PassByName.html
- rcthompson 14y agoI genuinely can't tell if you're trolling by calling Java a "less well known niche language". As for Python being bizarre, it's just call-by-value, as has been pointed out elsewhere. The only arguably bizarre part is that all values must be pointers to objects. But I target like that consistency. I prefer it to Java, where I always have to think about whether a variable is an object pointer or a primitive type.
- calinet6 14y agoAs far as I can tell, he was being entirely sarcastic.
- InclinedPlane 14y agoIt didn't occur to me that here on HN one could actually get away with calling Java or C# a "niche language", since they are some of the most popular languages out there (though less so in the HN bubble, partly deservedly so I'd say, but still).