[LAU] OT: 2 minute intro to type systems (was C or C++?)
Erik de Castro Lopo
mle+la at mega-nerd.com
Fri Oct 15 10:51:20 UTC 2010
Chris Cannam wrote:
> On Fri, Oct 15, 2010 at 10:38 AM, R. Mattes <rm at mh-freiburg.de> wrote:
> > On Fri, 15 Oct 2010 10:20:45 +0100, Chris Cannam wrote
> >> How about Perl?
> >
> > Pretty much at the same location that Python and Ruby.
Yes, Perl is not much different in this regard from those two; strict
runtime type checking. Its been a long time since I looked at Perl,
but I think that Perl does small amount of compile time checking; the
language distinguishes between scalars, arrays and dictionaries by
(from memory) use of $scalar, @array and %dict.
However, elements within an array like:
@array = ( 1, "two", $value );
are all just objects with type information to distinguish between
the int, string and the scalar.
> Well, you can do things like
>
> $x = 1;
> $y = "2";
> $z = $x + $y;
>
> where the result is the number 3.
>
> But yes, I guess that's a consequence of implicit conversion rather
> than lack of type information.
Exactly. The types are checked and an implicit conversion from int
to string is performed on $x and then the '+' operator then concatenates
the two strings.
Cheers,
Erik
--
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
More information about the Linux-audio-user
mailing list