But then what /should/ be taken as a definition?
I’m saying, “Saying that ‘type inference’ means ‘type inference’ makes sense; and Wikipedia agrees.” You say no. Citation needed.
Here’s an example of what I call type inference in Perl. It happens at execution, not at compile time. It’s also an example of why uncontrolled inference of types is bad:
sub complement {
my ($string) = @_;
$string =~ tr/acgt/tgca/;
return $string;
}
EDIT: Your comment has been substantially edited so looks like I’ll have to do the same for mine.
“tttggg\n”, since Perl “reverse” is for reversing lists, right? But it’s not clear what that has to do with type inference. You seem to once again be using “type inference” to mean “implicit type conversion”. There’s no need to call this “type inference” because it already had a name. If Perl used type inference—and did not implicitly convert between scalars and lists of one scalar—the program would never even start, because it would contain a type error. Again, the notion of “type inference” only applies in a static typing system, so it’s not really applicable to Perl.
If you want an actual definition, then here is my attempt: “Type inference” refers to compile-time inference of types so that type errors can be detected.
But then what /should/ be taken as a definition? I’m saying, “Saying that ‘type inference’ means ‘type inference’ makes sense; and Wikipedia agrees.” You say no. Citation needed.
Here’s an example of what I call type inference in Perl. It happens at execution, not at compile time. It’s also an example of why uncontrolled inference of types is bad:
sub complement { my ($string) = @_; $string =~ tr/acgt/tgca/; return $string; }
$fasta = “aaaccc”; $fasta = &complement(reverse($fasta)); print “$fasta\n”;
What do you think this code will produce?
EDIT: Your comment has been substantially edited so looks like I’ll have to do the same for mine.
“tttggg\n”, since Perl “reverse” is for reversing lists, right? But it’s not clear what that has to do with type inference. You seem to once again be using “type inference” to mean “implicit type conversion”. There’s no need to call this “type inference” because it already had a name. If Perl used type inference—and did not implicitly convert between scalars and lists of one scalar—the program would never even start, because it would contain a type error. Again, the notion of “type inference” only applies in a static typing system, so it’s not really applicable to Perl.
If you want an actual definition, then here is my attempt: “Type inference” refers to compile-time inference of types so that type errors can be detected.