tags:

views:

164

answers:

1

In Boo, let's say I'm overriding a method that takes a parameter that takes string[] urls. Type inference, for whatever reason, isn't matching up to the base class, so I need to explicitly specify the type of the parameter.

class MyClass: MyBase
  override method(urls as Array[of (string)])
    dostuff()

This turns out not to be correct Boo syntax. What's the right way of specifying that I'm overriding a method that takes an array parameter?

Normally I prefer to expect an IEnumerable, but I'm overriding someone else's base class, which is part of Rhino.DSL.

Edited to add: It turns out my issue was only tangentially related to the array declaration syntax... my real problem was two different versions of the Boo Assembly being referenced in my project.

+2  A: 

Parenthesis around a type represents an array of that type:

class MyClass : MyBase
  override def method(urls as (string)):
    dostuff()
Mehrdad Afshari
Thanks, I finally found that in the documentation just seconds after I posted. In the simple case above, it clearly works. However, oddly, I've found that it doesn't like:override def method(bar as Boo.Lang.Compiler.CompilerPipeline, urls as (string)) although most arbitrary types worked fine...Any chance there's a well-known issue around certain types of objects, or do I need to do more hunting?
JasonTrue
'Virtuoso.QA.VatDsl.Features.MyClass1.DoStuff(Boo.Lang.Compiler.CompilerPipeline, (string))': no suitable method found to override. Method of same name has been found with incompatible signature(s). (BCE0060) - C:\virtuoso\sl\QAMain\Virtuoso\Virtuoso.QA.Vat\Virtuoso.QA.VatDslSupport\TestDSLEngine.boo:9,18
JasonTrue
@JasonTrue: Not one that I know about. That said, I'm not a Boo expert but that's a weird thing for a programming language so I would research for the problem somewhere else rather than looking at parameter definitions. Are you sure there's a method with that parameters to override?
Mehrdad Afshari
Yes, I ended up simplifying the issue by writing a minimalist base class with the CompilerPipeline as a parameter. It worked without complaints when I used "as int" in the base method declaration and the boo code, and worked fine with another class in my project in the base class and the boo override... Very strange. I'll try asking Ayende, who wrote the library I am depending on.
JasonTrue
I actually resolved the issue through further experimentation. It turns out that two conflicting versions Boo were being referenced in different parts of my solution, and the failure seems to have arisen from an assembly mismatch, even though the signatures appear identical.The solution was to update my local copy of the Rhino DSL code to support Boo 0.9.1 (about 6 lines of code, plus unit tests), and then pull a build of boo from trunk. Now I reference my home-brew version in all places and things just work.
JasonTrue