Boo

Consuming generic methods

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 0.7.7
  • Component/s: Compiler, Parser
  • Labels:
    None
  • Number of attachments :
    2

Description

ints = List of int()
ints.Add(1)
ints.Add(2)
ints.Add(3)

strings = ints.ConvertAll of string( {i as int | return i.ToString("g")} )

and then, using type inference, just:

strings = ints.ConvertAll( {i as int | return i.ToString("g")} )

I don't think the parser even knows about generic method invocations.
The syntax gets a little ugly when you have more than one generic parameter.
Consider System.Array.ConvertAll of int, of string(ints, {i as int | return i.ToString("g")}) for example.

  1. BOO-777-1.diff
    02/Apr/07 5:43 PM
    41 kB
    Avishay Lavie
  2. BOO-777-2.diff
    03/Apr/07 9:52 AM
    42 kB
    Avishay Lavie

Issue Links

Activity

Hide
Avishay Lavie added a comment -

Scheduled for 0.7.7. We may not support defining new generic types, but we should at the very least be able to consume all forms of generics, including generic methods.

Show
Avishay Lavie added a comment - Scheduled for 0.7.7. We may not support defining new generic types, but we should at the very least be able to consume all forms of generics, including generic methods.
Hide
Avishay Lavie added a comment -

Attached patch (BOO-777-1.diff) including simple testcases.

I can't commit this cause way too many unit tests are failing; however they all fail on a clean checkout as well, so one can never know.

Please, kind people, take this patch and treat it with warmth and kindness. Test it on thy windows boxen and if found worthy, tell me and I'll commit it (or you can commit yourself, whatever).

Show
Avishay Lavie added a comment - Attached patch (BOO-777-1.diff) including simple testcases. I can't commit this cause way too many unit tests are failing; however they all fail on a clean checkout as well, so one can never know. Please, kind people, take this patch and treat it with warmth and kindness. Test it on thy windows boxen and if found worthy, tell me and I'll commit it (or you can commit yourself, whatever).
Hide
Avishay Lavie added a comment -

Added second patch, since first one seems corrupted.

Show
Avishay Lavie added a comment - Added second patch, since first one seems corrupted.
Hide
Max Bolingbroke added a comment -

Had considerable difficulty applying the patch (both have the same problem):

  • Needed to remove leading BOMs from MixedGenericType and the MixedGenericType section of the patch before TortoiseSVN would apply it
  • Had to then remove leading junk character (the question mark) from MixedGenericMethod and one other (can't remember, possible MixedGenericType) before the project would compile

This may be a TortoiseSVN bug, it looks to my untrained eye at least that your patches are valid.

Show
Max Bolingbroke added a comment - Had considerable difficulty applying the patch (both have the same problem):
  • Needed to remove leading BOMs from MixedGenericType and the MixedGenericType section of the patch before TortoiseSVN would apply it
  • Had to then remove leading junk character (the question mark) from MixedGenericMethod and one other (can't remember, possible MixedGenericType) before the project would compile
This may be a TortoiseSVN bug, it looks to my untrained eye at least that your patches are valid.
Hide
Max Bolingbroke added a comment -

OK, I've run the test suite over a copy of revision 2444 with this patch, and I get exactly two failures, both in BooCompiler.Tests:

1) BooCompiler.Tests.LocalizationTestCase.TestPtBrCulture :
String lengths are both 22.
Strings differ at index 0.
expected: <"Token inesperado: foo.">
but was: <"Unexpected token: foo.">
------------^
at BooCompiler.Tests.LocalizationTestCase.AssertCultureDependentMessage(Strin
g message, CultureInfo culture)
at BooCompiler.Tests.LocalizationTestCase.TestPtBrCulture()

2) BooCompiler.Tests.RegressionTestFixture.BOO_748_1 : E:\Programming\Checkouts\
Boo-Trunk-777\tests\testcases\regression\BOO-748-1.boo: BCE0011: An error occurr
ed during the execution of the step 'Boo.Lang.Compiler.Steps.RunAssembly': 'Coul
d not load file or assembly 'testcase, Version=0.0.0.0, Culture=neutral, PublicK
eyToken=null' or one of its dependencies. The system cannot find the file specif
ied.'.
BCW0000: WARNING: Could not start peverify.exe
at BooCompiler.Tests.AbstractCompilerTestCase.Run(String stdin, CompilerConte
xt& context)
at BooCompiler.Tests.AbstractCompilerTestCase.RunAndAssert()
at BooCompiler.Tests.AbstractCompilerTestCase.RunCompilerTestCase(String name
)
at BooCompiler.Tests.RegressionTestFixture.BOO_748_1()

I don't know what is causing the first, but the second one could be because 748_1 does not define an expectation in a """blah""" block at the top of the file. At least, every other regression test I've looked at has one of these.

Show
Max Bolingbroke added a comment - OK, I've run the test suite over a copy of revision 2444 with this patch, and I get exactly two failures, both in BooCompiler.Tests: 1) BooCompiler.Tests.LocalizationTestCase.TestPtBrCulture : String lengths are both 22. Strings differ at index 0. expected: <"Token inesperado: foo."> but was: <"Unexpected token: foo."> ------------^ at BooCompiler.Tests.LocalizationTestCase.AssertCultureDependentMessage(Strin g message, CultureInfo culture) at BooCompiler.Tests.LocalizationTestCase.TestPtBrCulture() 2) BooCompiler.Tests.RegressionTestFixture.BOO_748_1 : E:\Programming\Checkouts\ Boo-Trunk-777\tests\testcases\regression\BOO-748-1.boo: BCE0011: An error occurr ed during the execution of the step 'Boo.Lang.Compiler.Steps.RunAssembly': 'Coul d not load file or assembly 'testcase, Version=0.0.0.0, Culture=neutral, PublicK eyToken=null' or one of its dependencies. The system cannot find the file specif ied.'. BCW0000: WARNING: Could not start peverify.exe at BooCompiler.Tests.AbstractCompilerTestCase.Run(String stdin, CompilerConte xt& context) at BooCompiler.Tests.AbstractCompilerTestCase.RunAndAssert() at BooCompiler.Tests.AbstractCompilerTestCase.RunCompilerTestCase(String name ) at BooCompiler.Tests.RegressionTestFixture.BOO_748_1() I don't know what is causing the first, but the second one could be because 748_1 does not define an expectation in a """blah""" block at the top of the file. At least, every other regression test I've looked at has one of these.
Hide
Max Bolingbroke added a comment -

OK, maybe not . I ran the test suite on a clean checkout of 2444 and got no failures at all!

Show
Max Bolingbroke added a comment - OK, maybe not . I ran the test suite on a clean checkout of 2444 and got no failures at all!
Hide
Avishay Lavie added a comment -

Fixed in revision 2446.
Type inference for generic methods (BOO-814) is not yet implemented, however.

Show
Avishay Lavie added a comment - Fixed in revision 2446. Type inference for generic methods (BOO-814) is not yet implemented, however.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: