Boo

Generics

Details

  • Type: New Feature New Feature
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Labels:
    None
  • Number of attachments :
    1

Description

Being able to consume Generics is required for any CLS-compliant .NET 2.0 language.

Issue Links

Activity

Hide
Avishay Lavie added a comment -

I've done some work on point #2 from here: http://groups.google.com/group/boolang/msg/4c49391b6778330f
The attached patch allows for type inference in for-loops over types that implement IEnumerable<T>:

ints = List<int>
ints.Add(21)
for i in ints:
print i * 2

In addition, the patch also allows classes to inherit from constructed generic types, to allow the following:

class MyList(List of int):
pass

ints = MyList()
ints.Add(21)
for i in ints:
print i * 2

The patch defines a new interface, IGenericType, that represents a constructed (or partially constructed) generic type; and a new class, ExternalGenericType, that implements the interface for external constructed generics.

This is my first patch for Boo, so I'd really like to hear your comments (coding style, bugs, etc.)

Show
Avishay Lavie added a comment - I've done some work on point #2 from here: http://groups.google.com/group/boolang/msg/4c49391b6778330f The attached patch allows for type inference in for-loops over types that implement IEnumerable<T>: ints = List<int> ints.Add(21) for i in ints: print i * 2 In addition, the patch also allows classes to inherit from constructed generic types, to allow the following: class MyList(List of int): pass ints = MyList() ints.Add(21) for i in ints: print i * 2 The patch defines a new interface, IGenericType, that represents a constructed (or partially constructed) generic type; and a new class, ExternalGenericType, that implements the interface for external constructed generics. This is my first patch for Boo, so I'd really like to hear your comments (coding style, bugs, etc.)
Hide
Avishay Lavie added a comment -
  • IEnumerable<T> type inference in for-loops
  • Correct binding when subclassing constructed generic types
Show
Avishay Lavie added a comment -
  • IEnumerable<T> type inference in for-loops
  • Correct binding when subclassing constructed generic types
Hide
Avishay Lavie added a comment -

Added testcases.

Show
Avishay Lavie added a comment - Added testcases.
Hide
Avishay Lavie added a comment -

Attached BOO-448-2.patch –
+ Resolves BOO-758, BOO-760, BOO-761 and BOO-762.
+ Adds testcases for above issues and for BOO-763 (generic generators, which aren't yet supported).

Show
Avishay Lavie added a comment - Attached BOO-448-2.patch – + Resolves BOO-758, BOO-760, BOO-761 and BOO-762. + Adds testcases for above issues and for BOO-763 (generic generators, which aren't yet supported).
Hide
Rodrigo B. de Oliveira added a comment -

Thanks for the patch, Avishay! I'm working on it right now.

In the future, please make sure all of the existing tests pass with your patch applied (I know there were already 2 broken tests in our suite before so I apologize for the confusion).

Please also try to submit broken test cases as separate attachments as it's not desirable to keep failing test cases in the code base - unless we create a specific test suite for broken test cases which would make the point clear. Thoughts?

Thanks again!

Show
Rodrigo B. de Oliveira added a comment - Thanks for the patch, Avishay! I'm working on it right now. In the future, please make sure all of the existing tests pass with your patch applied (I know there were already 2 broken tests in our suite before so I apologize for the confusion). Please also try to submit broken test cases as separate attachments as it's not desirable to keep failing test cases in the code base - unless we create a specific test suite for broken test cases which would make the point clear. Thoughts? Thanks again!
Hide
Avishay Lavie added a comment -

Yes, I was sloppy with testing before committing. I apologize.
Does the patch break anything?
Also, Is there a quick and easy way to run all of the unit tests? (I'm using Windows with SharpDevelop 2.1)

Show
Avishay Lavie added a comment - Yes, I was sloppy with testing before committing. I apologize. Does the patch break anything? Also, Is there a quick and easy way to run all of the unit tests? (I'm using Windows with SharpDevelop 2.1)
Hide
Rodrigo B. de Oliveira added a comment -

The patch broke a very simple issue with the way generic types were presented in error messages.

I always use 'nant test' but make sure peverify is on your path. If it isn't, define the peverify environment variable with a value of false.

By the way, the code is in. Great work!

Show
Rodrigo B. de Oliveira added a comment - The patch broke a very simple issue with the way generic types were presented in error messages. I always use 'nant test' but make sure peverify is on your path. If it isn't, define the peverify environment variable with a value of false. By the way, the code is in. Great work!

People

Vote (4)
Watch (4)

Dates

  • Created:
    Updated: