jstrachan | 29 Jan 07:46 2005

Re: Builder ideas

Russel Winder wrote:
> On Thu, 2005-01-27 at 05:44 +0000, jstrachan wrote:
>>   builder = builderExpression as Markup
> I can see using "as" as a cast of type in analogy with "instanceof" as a
> test of type but is this a difference from Java that is useful / needed?
> The Java way is the old C way
> 	(Markup)BuilderExpression
> and I wonder whether just using this to have consistency with Java is a
> better way forward.  In a sense I am not fussed as both mechanisms have
> their merits but I just wonder if the "minimum distance from Java" might
> be better for Groovy in this case?

I hear you. We definitely should support casting for similarity with 
Java. The benefit of the 'as' syntax is we could add the ability (almost 
like an operator overloading of + - etc) to allow classes to provide a 
co-ercion mechanism.

e.g. one day we could do things like

foo = "123" as Integer
assert foo.class == Integer.class