Perl-Sensitive Sunglasses | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
You have three data types -- scalar, array, hash. There are a few other types, such as subroutines and filehandles, plus the umbrella glob type. Also, I would argue that array and hash should be considered subtypes of the type 'list', since you can coerce a hash into an array (which may or may not give a useful result). You could also consider blessed references to have their own type (that type being the package they were blessed into), but if you do, you have to remember that it's totally seperate from the rest of Perl's type system. It's also easy to subvert via re-blessing. Java does the B&D thing with data types, leading to the ever-popular downcast. They may claim to be Strongly Typed, but you can't do anything useful without having to subvert the type system to get data moved around. Java actually has a rather weak type system, preciely because of the subversion you mention (C and C++ exibit the same problem). A big mistake a lot of people have made is equating static typing = strong, and dynamic typing = weak. Perl is dynamically typed, but also very strong. C/C++/Java are statically typed, but are relatively weak. Languages with a type system like C are usually only good for giving the compiler some optimization hints. Some would argue that it's more self-documenting, but given how easy it is to subvert, I think this could easily lead to more confusion than its worth. ---- Note: All code is untested, unless otherwise stated In reply to Re: Re: Re: There's Only One Way To Do It
by hardburn
|
|