--- Uri Guttman <uri@stemsystems.com> wrote: > >>>>> "P" == Paul <ydbxmhc@yahoo.com> writes: > P> means @a is an array that will be holding Str values. > P> So I *could* do C-ish "typecasting" by taking an anonymous set of > P> values and declaring them like this: > > P> @a = (1..3) is Str; # yes? bogus? I dunno. > > i think that is bogus. the trait (the 'is' stuff) must follow the > declaration. traits affect variables and not values. Ah, very true. @a = (1..3) but Str; # but for values as in "return 0 but true;" stuff. Yes? > also if @a was declared/used before this, i think that would be a > compile time error to redeclare it. traits can only be used on a > declaration and not on any general assignment. That's not a declaration -- it's just an assignment. The "but Str" is saying the 1..3 should be interpreted as string values. > i don't think there is c style typecasting. you can assign to another > type of var but its implementation has to decide if it likes the data > you are giving it. it may allow it and internally do some 'casting'. > and perl 'casting' usually would involve real munging of data or > putting it in a different slot in the PMC or something. c's casting > rarely changes the data (except for float/int) - it usually just > changes the type. But on a standard scalar, aren't 1 and "1" seperate values, both stored internally to the scalar and selected according to the context? And in most cases, if the context calls for one that hasn't been populated, doesn't it tend to do so on the fly from the value of the other? That's how I kind of envisioned the P5 behavior. What's P6 do? > P> Can you set properties on sets like that? I know I could say > P> @a is Str = 1..3; # right? > > you still need parens around that list (i think). Why? @a = 1..3; has always worked. Is that a new restriction in P6? Seems unlikely.... > P> But isn't that a different animal? > > maybe but one of the animals maybe mythical. :) lol....probably so. ;o] __________________________________________________ Do you Yahoo!? Yahoo! Tax Center - File online, calculators, forms, and more http://tax.yahoo.comThread Previous | Thread Next