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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Chris Cannam wrote:

> On Fri, Oct 15, 2010 at 10:38 AM, R. Mattes <rm@xxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxxxxxxx
http://lists.linuxaudio.org/listinfo/linux-audio-user


[Index of Archives]     [Linux Sound]     [ALSA Users]     [Pulse Audio]     [ALSA Devel]     [Sox Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux