3 ms·
good point - I am just a little reluctant to swallow that a strong type system is intended to stop us accidentally assigning a number to a string var - raku is
by librasteve 2y ago
good point - I am just a little reluctant to swallow that a strong type system is intended to stop us accidentally assigning a number to a string var - raku is an interesting case since the strong types in raku (aka perl6) were crafted so that the typical (untyped) perl case of
my $x = "1";
print $x+1; #2
print $x.1; #'11' ('.' is perl for string concatenate)
so in raku, untyped, thats
my $x = "1";
say $x+1; #2
say $x~1; #'11' ('~' is raku for string concatenate)
ok, but raku can be strongly typed too, so how to graduate to that without throwing out the first draft
my IntStr $x = <1>; ('<>' is raku for Allomorph literal)
say $x+1; #2
say $x~1; #'11'
just reach for the IntStr type (it's built in and has a literal syntax sugar)
the main idea for gradual typing to allow code to be evolved by adding types over time without necessarily knowing all the types you are going to settle on before you start