History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: BOO-540
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Rodrigo B. de Oliveira
Reporter: Cameron Kenneth Knight
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Boo

Unable to call blank constructor on a ValueType

Created: 23/Oct/05 08:49 PM   Updated: 21/Nov/05 09:36 AM
Component/s: Compiler
Affects Version/s: None
Fix Version/s: 0.7.5

Time Tracking:
Not Specified

Issue Links:
Duplicate
 


 Description  « Hide
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.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Sorin Ionescu - 23/Oct/05 09:29 PM
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.

Cameron Kenneth Knight - 24/Oct/05 07:41 AM
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)