in reply to syntax error checking on object methods

What I've been thinking about doing is hijacking the pseudo-hash syntax and using it for this. So if you did
my Animal $spot = Dog->new; $spot->Reproduce; # fine $spot->DriveToWork # not OK some_other_function_that_returns_an_object()->method # ignore this
I was thinking of using the B framework to get access to the parsed code. In a very simple implementation you would wander around the parsed code, looking for methods called directly on a variable, find out that the variable is a lexical declared as my Animal and end up checking Animal->can("Reproduce") and Animal->can("DriveToWork"). In a more sophisticated implementation, instead of using can, the method information would be held in say $Animal::INTERFACE and could also include info about method arguments or other useful stuff.

Objections:

I had a quick look at B last weekend and it looks like it should be possible by navigating through a B tree of opcodes looking for the method calls but it could be a lot of work to write the code because you need to cater for each opcode (athough most of the time you're just ignoring them I think).

If anyone else fancies a challenge...