Re: RFC 124 (v1) Sort order for any hash as an example of attributes in action
[email protected] ("David L. Nicol")
| Newsgroups | perl.perl6.language.objects |
|---|---|
| Organization | University of Missouri - Kansas City supercomputing infrastructure |
| Message-ID | <[email protected]> |
"Brust, Corwin" wrote: > > <snip> > -----Original Message----- > From: David L. Nicol [mailto:[email protected]] > How about > > %students : ( sort = $$students{^1}{GPA} <=> $$students{^0}{GPA} }); > > </snip> > > Ohhhh, this is cool. > > <snip> > -----Original Message----- > my %students : sorted( $ME{^1}{GPA} <=> $ME{^0}{GPA} ); > </snip> > > And this is even cooler! > > -Corwin I want there to be a STRICTLY SYNTACTIC way to tell if stuff that comes after an atrtribute specifier is info for the attribute or is initialization data for the attribute-having data element.... and, duh, I guess it's the presence of an assignment operator, w/o one of those we're setting the properties of the attribute, or at least passing the stuff to the attribute's methods, to do with as it will. Executive summary: objects have "attributes" and "value" which are syntacticly distinguishable. "type" aka "package" aka "class" may be considered a meta-attribute, as it affects which attribute methods will be. Internally, the available attributes will depend on what type we're in, and setting them may imply switching to a different type: Setting the :sorted on a hash switches it to a sorted-hash, with a variety of implications (maybe all hashes are sorted, and the default sort value is a (hash-bucket, arrival time) pair) So, setting an attribute in this instance will have the effect of changing the container's internal representation, and filling a virtual method with a coderef. -- David Nicol 816.235.1187 [email protected] Does despair.com sell a discordian calendar?