> c0mrade wrote:
>
> Regarding the Python-style implementation, could groovy not
> just look at something like "Class()" and think as so: "if
> there is a function called 'Class', run that function. If
> there is not a function called 'Class' look for any classes
> called 'Class', if there is a class called 'Class' - return
> 'Class.newInstance()'".
IMO omitting 'new' would weaken the language's expressive strength too much.
The code would become less understandable for the reader. But even worse,
the compiler's inference rules would become much more complex, probably up
to a point where it not even could decide to generate a NEW bytecode (think
e.g. of pretended methods). The decision what to invoke would then be left
to the runtime...
As you note, this argument does not neccessarily hold for the Ruby syntax
TheClass.new(...)
as a syntactic equivalent for
new TheClass(...)
However, personally I would not like to see this construct in Groovy. I
suspect it would force to drop the restrictions to 'new' from the grammar.
Would it allow to define methods with the name 'new'? If so, how should the
compiler separate constructor calls
Xxx.new(...)
from method calls on an instance
Xxx.new(...)
Regards,
Alex
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email