On Tuesday, October 15, 2002, at 01:07 PM, Luke Palmer wrote:
>> Any value may be forced, however, into being an explicit type: this is >> commonly known as casting or typecasting. Typecasting is the act of >> transforming a value of one type into a value of another type. The >> typecasting operator in Perl is as: >> >> 5 as int >> 5 as string >> 5 as MyNumber > > Weren't we going to use constructor-style typecasting (at least as it > currently stands)? > > int(5) > # or > int.new(5) Not sure -- probably so, but now I'm thinking it couldn't work that way. I don't think typecasting can be constructor-based, because if you said ($obj as MyThing), and $obj was already a MyThing, you probably shouldn't be cloning it, whereas (MyThing.new($obj)) probably should. >> The keyword but is provided as a synonym for is. A typical use for but >> is in expressions where the property is perhaps "surprising" in some >> way. > > Nope. C<but> is entirely different from C<is>. I think the best > description is that C<is> is for variables, and C<but> is for values. > I can't be sure this is always the case, however.... Indeed, many of > your examples use C<is> when they should use C<but>. Thanks, I'll redo. I'm trying to look it up again, but I still can't find the thread. (Apparently I am the only one confused by this, but mighty confused I still be.) MikeL
