On Jul 4, 2005, at 1:46 PM, Chris Schreiner wrote:
I understand this now. But I dont think the error message is *helping* me to understand it.
I have to say, I also always have to think for a second when I get this error message, even though it's certainly correct.
What about something like "Error: Dictionary>>keysAndValuesDo: was expecting a block with 2 arguments, but this block only accepts 1".
Note that I'm not saying that #keysAndValuesDo: was expecting to be *passed* a block with 2 arguments - the block doesn't know how it got there, it could have been passed to some other method at some other time and stored somewhere, and then used later by #keysAndValuesDo:. But we do know that #keysAndValuesDo: somehow has a block and is expecting it to accept 2 args, and in *most* cases that will also help to find which message send got the wrong kind of block as an argument as well.
Avi
Lets start monday morning with an intuitive error message:
Dictionary new at: 1 put: 1; keysAndValuesDo: [:each | ].
"Error: This block accepts 1 argument, but was called with 2"
Hi all,
I think I changed this error message a few years ago. I'm fairly sure that I was confused every single time I got the original message --> This block requires 1 arguments
because I used to think, 'yeh, I've declared it with one argument!'
So I changed it to be from the block's point of view --> This block expects 1 argument but was called with 2
If it's still confusing people then maybe it can be rewritten once and for all!
I can't remember exactly what was going on in my mind at the time but I'm sure that I had earlier versions that were more verbose. I think I tried to cut down the width of the message since it didn't always print in the default width of the debugger window.
I'm not sure I'm in the best position to come up with something better but my 2p would be --> Incorrect number of block arguments. Block expects 1 but is passed 2.
I think I would still write it from the block's POV because the block signals the error. I think Avi is suggesting more from the sender's POV:
Avi Bryant wrote:
What about something like "Error: Dictionary>>keysAndValuesDo: was expecting a block with 2 arguments, but this block only accepts 1".
which is quite nice, but how do you generate the string? Do you walk the sender chain to find which method evaluated the block?
Anyway, a fun little puzzle. Would "Incorrect number of block arguments" be a touch minimal?
Cheers
Mike
How about 'this block was defined as expecting 1 argument but has been passed 2 by ' and then find the selector of the sender to append.
tim -- Tim Rowledge, tim@rowledge.org, http://www.rowledge.org/tim Useful random insult:- Runs squares around the competition.
squeak-dev@lists.squeakfoundation.org