Boo

Unable to call blank constructor on a ValueType

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 0.7.5
  • Component/s: Compiler
  • Labels:
    None
  • Number of attachments :
    0

Description

in C#, this is legal:

int i = new int();

whereas in Boo,
i as int = int()
ERROR: The type 'System.Int32' does not have a visible constructor that matches the argument list '()'.

the blank constructor should create a new instance, even though it is impossible to define a blank constructor in a ValueType, it would be handy for instances like this:
Length(Feet: 5.0)
which would create a new Length, then assign Feet to 5.0, without having to go through an intermediary constructor.

Issue Links

Activity

Hide
Sorin Ionescu added a comment -

That's because there is no constructor. Disassemble Int32 and look for yourself.
That's syntax sugar.
int i = new int(); is the same as int i = 0;
jsut do length.Feet = 5.0 directly.

Show
Sorin Ionescu added a comment - That's because there is no constructor. Disassemble Int32 and look for yourself. That's syntax sugar. int i = new int(); is the same as int i = 0; jsut do length.Feet = 5.0 directly.
Hide
Cameron Kenneth Knight added a comment -

But I want to be able to set properties of the ValueType inline.

I know that "int i;" is the same as "int i = new int();", but because Boo allows you to set properties in a class' instantiation, it will actually have a point, e.g. Length(Feet: 5.0)

Show
Cameron Kenneth Knight added a comment - But I want to be able to set properties of the ValueType inline. I know that "int i;" is the same as "int i = new int();", but because Boo allows you to set properties in a class' instantiation, it will actually have a point, e.g. Length(Feet: 5.0)

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: