[OT] Perl woes and types

Rafael Garcia-Suarez rgarciasuarez at gmail.com
Wed Jan 28 17:06:19 GMT 2009


2009/1/28 Ovid <publiustemp-londonpm at yahoo.com>:
> ----- Original Message ----
>
>> From: Peter Corlett <abuse at cabal.org.uk>
>
>> > The problem with "strongly" and "weakly" typed is that different people define
>> them differently and they don't have much meaning in type systems.  It's static
>> typing and dynamic typing which is important.
>>
>> Wikipedia says that weakly- versus strongly-typed indicates how readily the
>> language coerces between types. I'm not sure one can get much weaker than Perl
>> on that front.
>
> By "types" I assume you mean "kinds of data a variable can hold".  Strictly
> speaking, taint checking in Perl is another type system in the language, one
> which (like "use strict") must be explicitly enabled in the code.  There is a
> very specific action which is required to extract untainted data from tainted
> data, so Perl is "strongly typed" in this respect..  You also can't coerce an
> array reference into a hash reference though you can create them out of thin
> air via auto-vivification, but once created, you can't change 'em:
>
>    $ perl -Mstrict -le 'my $foo = []; $foo->[0]{bar}[0] = "Wheee!"; print $foo->[0]{bar}[0]; $foo->[0]{bar}{baz}'
>    Wheee!
>    Can't coerce array into hash at -e line 1.
>
> So is Perl strongly or weakly typed?

I see tainting as something the value holds, not its container. Unlike
types.

>> > I *think* what you're describing as "strongly typed" is "a variable can hold
>> different types, but that operators change their behavior at runtime:
>>
>> That's just polymorphism, no?
>
> Yes, but many argue that early binding is a key component of a strongly typed
> language.  The python example I posted clearly had different kinds (types) of
> data assigned to the 'foo' and 'bar' variables at different points in the
> program.
>
> I'm just saying that while type theorists generally agree on the meaning of
> "static" and "dynamic" typing (and all languages contain elements of each),
> "strong" and "weak" typing don't have much meaning there.  They only have
> meaning to those who make up their own definitions :)

C passes for "strongly" typed, but allows casting back and forth to such
types as void*. Could be called the dark side of the strong typing. And
I'm not mentioning the funny cast operators in C++.

That reminds me :

The Typing is strong with this one.
The Typing can have a strong influence on the weak-minded.
I want to learn the ways of the Typing and become a Haskell coder like
my father.
For my ally is the Typing, and a powerful ally it is.

-- 
"You don't mean odds and ends, you mean des curieux et des bouts", corrected
the manager. -- Terry Pratchett, Hogfather


More information about the london.pm mailing list