From: Tom Sawyer Date: 2003-01-14T08:05:07+09:00 Subject: Re: arguments as actual objects On Monday 13 January 2003 06:28 am, dblack@candle.superlink.net wrote: > I don't think there's anything wrong with using * . We use operators > in Ruby all the time (like [], . , (), etc.). Also, there are lots of > cases where you use * other than in argument lists. As long as it's > there, it seems fine to use it for argument lists too. i'm not really saying that there is anything wrong with it per se. only pointing out that b/c arguments aren't objects in their own right we require a sytatically disperate operator to provide the functionality. > There's another conundrum here. How would you define to_arg? What > would its return value be? Let's say you did: well, that's the thing. Arguments would need to be a built-in class. > class Array > def to_arg > *self > end > end > > This will return an array. Since Ruby uses Arrays as its mechanism > for handling multiple return values, any method called on any object > that returns more than one value (including Array#to_arg) will return > an Array. That's why you need an operator like * to manipulate arrays > directly. well, you hit the nail on the head: Arguments are not Arrays. if they were then this wouldn't be an issue and * would not be needed. moreover * behavior is complex. in one instance it converts an Array into "Arguments" and in a another instance returns an Array (as in your Array#to_arg example above). > Oh, we can get more OO than that: > > send(:i_take_args,Array.new.push(1,2,3).to_arg) > silly david ;-) ** actually, it quite interesting. what i am thinking of is an object that dosen't get passed like normal objects, rather: arg_obj = (1, 2, 3) # literal contructor for args somemethod arg_obj this would not pass a single Argument object as such, but would act as if it were: somemethod(1, 2, 3) an oddity in itself, for then how does one pass an Argument object? to be clear, my whole desire for this is to be able to do: i_take_args i_make_args rather than having to do: i_take_args *i_make_args but perhaps that is simply logically impossible? -- tom sawyer, aka transami transami@transami.net .''. .''. . *''* :_\/_: . :_\/_: _\(/_ .:.*_\/_* : /\ : .'.:.'. .''.: /\ : ./)\ ':'* /\ * : '..'. -=:o:=- :_\/_:'.:::. | ' *''* * '.\'/.' _\(/_'.':'.' : /\ : ::::: = *_\/_* -= o =- /)\ ' * '..' ':::' === * /\ * .'/.\'. '._____ * | *..* : |. |' .---"| * | _ .--'| || | _| | * | .-'| __ | | | || | .-----. | |' | || | | | | | || | ___' ' /"\ | '-."". '-' '-.' '` |_. ------------------------------------------------------------