From: David Garamond Date: 2004-06-07T02:51:55+09:00 Subject: Re: How to ducktype a Hash? Dave Thomas wrote: > On Jun 6, 2004, at 11:42, Sean O'Dell wrote: > >> If Hash tagged itself as complying with the "hash type" you could >> depend on >> certain methods doing certain things and taking a certain number of >> parameters. > > Perhaps you'd like Objective-C, which has the concept of protocols, and > where variable types can be unconstrained, partially constrained, or > specified by type. Interesting. Will Ruby ever have something like this? Will it be a good idea? For example, let there be a $TYPESAFE (ala $SAFE) that modifies how Ruby does type checking. $TYPESAFE=0 is the default, and makes Ruby behaves just like it is now (i.e. no type checking). $TYPESAFE = 1 will make variables have type and a warning will be issued if a variable is reassigned to a value of different type. $TYPESAFE = 2 will enable method parameter type checking. $TYPESAFE = 3 will forbid a variable from being reassigned another type, and so on. -- dave