A 'new' hope
Posted: Mon Jun 24, 2013 9:42 am
I've been thinking about how I don't really like instantiation and I think I got it kind of sorted out.
Why remove the 'new' keyword anyway? Isn't it all about readability? And readability's the one thing that 'new' provides?
variable = Something() # In any language which allows CamelCase functions, this could be an assignment of a return value.
variable = new Something() # A hundred percent clear that this instantiates.
But of course, if it was only for this, that would be a weak reason to include new. My take on the thing is purely a thing of consistency. All the time I hear this great stuff about how 'useless parentheses can be omitted' and then you wonder why the code doesn't compile.
As I posted in my pretty-much first post on here, this is confusing:
variable = Something # variable is of the type 'Type'
variable = Something() # Finally, an instance.
If I wanted to omit the parentheses and instantiate at the same time:
variable = new Something # Parentheses can be omitted, 'new' makes it obvious that I want an instance of Something and not its type
Please consider this. Not only does it play to your 'make it more verbal' style ('not' instead of '!', 'and' instead of &&, etc.), I think it really lends itself to the consistency of requiring parentheses only when they actually do something.
Why remove the 'new' keyword anyway? Isn't it all about readability? And readability's the one thing that 'new' provides?
variable = Something() # In any language which allows CamelCase functions, this could be an assignment of a return value.
variable = new Something() # A hundred percent clear that this instantiates.
But of course, if it was only for this, that would be a weak reason to include new. My take on the thing is purely a thing of consistency. All the time I hear this great stuff about how 'useless parentheses can be omitted' and then you wonder why the code doesn't compile.
As I posted in my pretty-much first post on here, this is confusing:
variable = Something # variable is of the type 'Type'
variable = Something() # Finally, an instance.
If I wanted to omit the parentheses and instantiate at the same time:
variable = new Something # Parentheses can be omitted, 'new' makes it obvious that I want an instance of Something and not its type
Please consider this. Not only does it play to your 'make it more verbal' style ('not' instead of '!', 'and' instead of &&, etc.), I think it really lends itself to the consistency of requiring parentheses only when they actually do something.