Deborah Ariel Pickett: # > > ..., and someone pointed out that it had a problem # > > with code like "{ some_function_returning_a_hash() # }". Should it give a # > > closure? Or a hash ref? ... # > Oh, well now that it's stated this way... (something went # wrong in my # > brain when I read the actual message) It returns a closure # :(. A4 says # > that as a term, { } define a closure, unless it contains a pair # > constructor at the top level. But, thanks to Perl 6's # smartness, that would # > be excessive syntax anyway: # > $hashref = some_function_returning_a_hash() # > would do what you wanted. # # Would it always? What if I had two functions (or more), all returning # part of the hash I want to package up? Can I do: # $hashref = some_function_returning_a_hash(), # some_other_function_returning_more_of_the_hash(); # and get the result of both functions into the anonymous hash?
Not directly--just use the hash {} constructor. # Besides, does # $hashref = some_function_returning_a_hash() # make $hashref simply refer to the result of the function, or does it # make $hashref refer to a hash containing a *copy* of the result of the # function? If Perl6 is going to do fancy things with # functions returning # lvalues, which looks like the case, those two things aren't # necessarily # the same thing. # # Or, saying the same thing another way, does this: # $href = %hash; # which I presume will be legal Perl6, mean the same as this Perl5: # $href = \%hash; #A # or this Perl5: # $href = { %hash }; #B # and how would I say each of A and B in Perl6 unambiguously? A. And unambiguously: $href = \%hash; #A $href = hash { %hash }; #B # Automatic referencing and dereferencing is all well and good, and it # appears that it's here to stay in Perl6 (it's been in most # Apocalypses), # but I don't think anyone's actually sat down yet to thrash out exactly # under what circumstances it happens. Autodereferencing happens whenever we have a scalar but we need an array or hash; autoreferencing happens whenever we have an array or hash but need a scalar (usually because of scalar assignment, but not necessarily). --Brent Dax <[EMAIL PROTECTED]> @roles=map {"Parrot $_"} qw(embedding regexen Configure) He who fights and runs away wasted valuable running time with the fighting.