4 ms·
I saw a similar philosophy at work in a dynamically typed language (Lua): function foo(String, Float) -- Some code end "String" and "Float" aren't typ
by loup-vaillant 14y ago
I saw a similar philosophy at work in a dynamically typed language (Lua):
function foo(String, Float)
-- Some code
end
"String" and "Float" aren't type names. "string" and "float" are. But they are just as effective at signalling intent, when the name of the type is enough.
- mistercow 14y agoIt's also pretty easy to have a one-letter convention for type-obvious situations. For example, if I name a variable s, f, i, or n, then I always know that it's a string, float, integer or integer, respectively. Beyond type information, I also always know that "n" is going convey the notion of a count. Obviously again this is only reasonable if you only need to know type information, but if you're writing a function like repeatString = (s, n) -> (s for i in [0...n]).join '' then it's completely pointless to give those more verbose names. You wouldn't actually be conveying additional information until you got to an utterly ridiculous point like repeatString = (stringThatWillBeRepeated, numberOfTimesToRepeatTheString) -> (stringThatWillBeRepeated for i in [0...numberOfTimesToRepeatTheString]).join ''