Default arguments -> another syntax?


Lately I had an idea.

Methods take default arguments like so:

def foo(i = ‘blee’, j = ‘blabalaa’)

I had a need to call foo() in my code, but change the default
to the j argument. There may be several ways, like redefining:

def foo(i = ‘blee’, j = ‘foofoo’)

One could also use a hash instead.

But I myself, thought about this:

foo.j = ‘dumdedum’

Of course this does not work. But my question is, would this
work in Ruby in theory? And if not, why can it not work?

I am thinking that methods could be treated as pseudo objects.
We also can already create objects from methods via method(:name)
(I think it is of UnboundMethod class)

I am wondering, if arguments to methods are data, why couldn’t
they be (pseudo)objects at the same time as well?

Marc H. wrote in post #1002090:

I am wondering, if arguments to methods are data,

Besides being simple data they can be syntax trees. E.g., you can do:

def foo(i = ‘blee’, j = i.length)

and it will be evaluated anew each time you call the function (without