H
Hugh Sasse Staff Elec Eng
This is too half-baked to be an RCR, but here goes...
At the moment we cannot write
class Thingy
def somefunc
def newfunc
...
end
end
end
OK, fair enough, somefunc is an instance method, so what would
newfunc get defined as? It could not be an instance method because
it might depend on variables having values which differ in another
instance.
So, my half-baked idea: let the above code be a shorthand for
class Thingy
def somefunc
class << self
def newfunc
...
end
end
end
end
This would have the [questionable] advantage that it would hide that
relatively obscure class << self syntax used in constructing
singletons, and it would be better tnan passing a string to instance
eval because it would get syntax highlighted by the editor.
It is not legal now, so old code would not break.
So, now I'll push this idea out and see if it sinks...
Hugh
At the moment we cannot write
class Thingy
def somefunc
def newfunc
...
end
end
end
OK, fair enough, somefunc is an instance method, so what would
newfunc get defined as? It could not be an instance method because
it might depend on variables having values which differ in another
instance.
So, my half-baked idea: let the above code be a shorthand for
class Thingy
def somefunc
class << self
def newfunc
...
end
end
end
end
This would have the [questionable] advantage that it would hide that
relatively obscure class << self syntax used in constructing
singletons, and it would be better tnan passing a string to instance
eval because it would get syntax highlighted by the editor.
It is not legal now, so old code would not break.
So, now I'll push this idea out and see if it sinks...
Hugh