package hello
type cat int
func greet(c cat) cat {
return c + 1
}
type dog string
func greet(d dog) dog { // greet redeclared in this block
return d + "one"
}
but you can with methods:
package hello
type cat int
func (c cat) greet() cat {
return c + 1
}
type dog string
func (d dog) greet() dog {
return d + "one"
}
It's possible with _Generic but there's a lot of caveats. Any seasoned C dev would just have two functions with a prefix or suffix, like cat_greet() and dog_greet().
Again that's this language constraining you to that. With procedure overloading it's not required that you have to have that ugly API. For instance the following is valid Nim:
type
Cat = object # these are just 'struct' in a different skin
Dog = object
proc greet(c: Cat): string = "Meow"
proc greet(d: Dog): string = "Bark"
assert Dog().greet() == "Bark"
assert Cat().greet() == "Meow"