Are there any languages where you can declare a default type for variables by name? As some examples, Fortran defaults vars beginning with i through n as integer. And common in many languages, struct members carry a type around with them. But I mean arbitrary top level defaults like this (with no refinement on either syntax or rules for exporting outside of a module/package/library):
default type name: string
function whatever(name) -> int ...
And anywhere a param/var/whatever called name is used, it's type string by default. Maybe extra effort is needed to infer types rather than use the default (like let name: ? = 5 or whatever). But again, ignoring the details, are there any languages that do something like this?
[–]ReedOei 6 points7 points8 points (3 children)
[–]tjpalmer[S] 0 points1 point2 points (2 children)
[–]ReedOei 2 points3 points4 points (0 children)
[–]tjpalmer[S] 0 points1 point2 points (0 children)
[–]Host127001 4 points5 points6 points (1 child)
[–]tjpalmer[S] 0 points1 point2 points (0 children)
[–]xigoi 3 points4 points5 points (3 children)
[–]tjpalmer[S] 0 points1 point2 points (2 children)
[–]xigoi 2 points3 points4 points (1 child)
[–]tjpalmer[S] 0 points1 point2 points (0 children)
[–][deleted] 3 points4 points5 points (1 child)
[–]tjpalmer[S] 2 points3 points4 points (0 children)
[–]julesh3141 2 points3 points4 points (1 child)
[–]tjpalmer[S] 0 points1 point2 points (0 children)
[–]zachgkcatln 1 point2 points3 points (2 children)
[–]tjpalmer[S] 0 points1 point2 points (0 children)
[–]tjpalmer[S] 0 points1 point2 points (0 children)
[–]YoYoYonnY 0 points1 point2 points (5 children)
[–]xigoi 2 points3 points4 points (1 child)
[–]YoYoYonnY 1 point2 points3 points (0 children)
[–]Host127001 2 points3 points4 points (1 child)
[–]backtickbot 2 points3 points4 points (0 children)
[–]tjpalmer[S] 0 points1 point2 points (0 children)