Re: [LAU] OT: 2 minute intro to type systems (was C or C++?)

From: Erik de Castro Lopo <mle+la@email-addr-hidden-nerd.com>
Date: Fri Oct 15 2010 - 13:51:20 EEST

Chris Cannam wrote:

> On Fri, Oct 15, 2010 at 10:38 AM, R. Mattes <rm@email-addr-hidden-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/
_______________________________________________
Linux-audio-user mailing list
Linux-audio-user@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-user
Received on Fri Oct 15 16:15:04 2010

This archive was generated by hypermail 2.1.8 : Fri Oct 15 2010 - 16:15:04 EEST