From: Tom Sawyer Date: 2002-08-08T19:36:53+09:00 Subject: Re: Named paramters again did a little wondering about the internet, found this quote: Viewing Hash and Array as instances of "Container" leads to easy implementation of "Sparse Array" and "Sorted Hash" and "Real Array" of course, what i'm suggesting is perhaps a bit more radical: unifying array and hash --well, perhaps just making a new type of object which is this unification (but given this, i can't exactly see why you'd still need the other two, but no matter) this new "MixedContainer" class could have a literal representation denoted by parantheticals: ( 'one', :opkey=>'two' ) then a subclass of Container could be made called Arguments, where Arguments has some added features that give it some of the reminaing applicaple characteristics of Ruby's current argument behavior, ie. *array, &block and the like. thus, calling any method simply boils down to passing a single Arguments object. f ('one', :opkey=>'two') which then could also be done like this: args = ('one', :opkey=>'two') f args the end result? we get a new powerful class and named parameters in one shot. neat/clean/interestig idea? ~transami p.s. found a nice pitch page for ruby: http://www.cse.unsw.edu.au/~gjmc469/ On Thu, 2002-08-08 at 04:05, Justin Johnson wrote: > > Where this is used a lot in python are constructors in GUI widgets were > > lots > > of default values can be set and you only need to provide those you wish > > to > > 'override'...and yes...order independence becomes relevant here too > > because you will have a hard time maintaining the order in your head for > > 20 or 30 parameters. Granted, you could just implement this as > > subsequent calls to attribute getter/setters, but it's nice to be able > > to do it in widget construction. > > I see your point. > > I think that the named argument method that I outlined serves a slightly > different purpose to the one above. The one I outlined gives the language a > way of calling methods based on set named parameters in a way similar to > Smalltalk and Objective-C. The Python style call allows flexible > specification of named arguments and seems particularly useful in the > presence of default argument values. > > The main thing for me is that the Python style named arguments must require > extra processing when calling a method with named arguments. > > But there again, maybe that's the price you pay for flexibility. > > -- > Justin Johnson > > > > -- ~transami