I asked this earlier, but it wasn't the first question in my email, so it may have been overlooked.
In Smalltalk lingo is it correct to say "signal" and "handle" in place of Java's "throw" and "catch"?
--- Mark Volkmann
Mark Volkmann a écrit :
I asked this earlier, but it wasn't the first question in my email, so it may have been overlooked.
In Smalltalk lingo is it correct to say "signal" and "handle" in place of Java's "throw" and "catch"?
Mark Volkmann
He, nobody answering, seems you reached some kind of quota ;)
I would say, you mostly get it, but: - in java/C++ etc... throw/catch try/catch are part of Syntax - in Smalltalk, these are just ordinary messages sent to objects...
As such, you'll see some differences across dialects like #raise instead of #signal for example... Inside a Smalltalk dialect, you'll see also some variations (browse usage of #signal: in Squeak for example).
Concerning #handle, i don't know where you get the information... #handle:do: is a compatibility message dating from very old Visualworks image and is not in Squeak images, AFAIK. ANSI recommend using #on:do: Also browse usage of simpler messages like #ensure: #ifCurtailed:
Also browse all possible handling actions like #reject #pass #retry #return #retryWith: #return: #resignalAs: Maybe you'll need some good tutorial to learn the differences between these actions (remember that Smalltalk can handle the MethodContext call stack, so don't be amazed of rich possibilities there).
Cheers
On Wed, Oct 1, 2008 at 7:34 AM, nicolas cellier ncellier@ifrance.comwrote:
Mark Volkmann a écrit :
I asked this earlier, but it wasn't the first question in my email, so it may have been overlooked.
In Smalltalk lingo is it correct to say "signal" and "handle" in place of Java's "throw" and "catch"?
Mark Volkmann
He, nobody answering, seems you reached some kind of quota ;)
Nah. Mark: don't stop asking questions; I've learned stuff myself from some of the answers. If you haven't already, jump on IRC (Freenode, #squeak) and ask stuff there too.
I'm not sure there's a common lingo in the community for talking about exceptions. Personally, I haven't used them as much as I should and I think that applies to most Smalltalkers.
"signal" can be a bit confusing because we also signal semaphores.
Gulik.
Am 30.09.2008 um 14:12 schrieb Michael van der Gulik:
Mark: don't stop asking questions; I've learned stuff myself from some of the answers. If you haven't already, jump on IRC (Freenode, #squeak) and ask stuff there too.
Actually, if you're not in a hurry, please prefer the mailing list over IRC. Many more people can learn that way.
- Bert -
On Sep 30, 2008, at 1:34 PM, nicolas cellier wrote:
Mark Volkmann a écrit :
I asked this earlier, but it wasn't the first question in my email, so it may have been overlooked. In Smalltalk lingo is it correct to say "signal" and "handle" in place of Java's "throw" and "catch"?
Mark Volkmann
He, nobody answering, seems you reached some kind of quota ;)
I would say, you mostly get it, but:
- in java/C++ etc... throw/catch try/catch are part of Syntax
- in Smalltalk, these are just ordinary messages sent to objects...
As such, you'll see some differences across dialects like #raise instead of #signal for example... Inside a Smalltalk dialect, you'll see also some variations (browse usage of #signal: in Squeak for example).
Concerning #handle, i don't know where you get the information... #handle:do: is a compatibility message dating from very old Visualworks image and is not in Squeak images, AFAIK. ANSI recommend using #on:do: Also browse usage of simpler messages like #ensure: #ifCurtailed:
Also browse all possible handling actions like #reject #pass #retry #return #retryWith: #return: #resignalAs: Maybe you'll need some good tutorial to learn the differences between these actions (remember that Smalltalk can handle the MethodContext call stack, so don't be amazed of rich possibilities there).
Thanks! I think I understand all you said except for two things.
1) The ifCurtailed method. From just looking at the comment in the method and the code, I have no idea what it does.
2) The reject method. Which class are you referring to? The ones I see that contain that method don't seem related to exception handling.
--- Mark Volkmann
Mark Volkmann <mark <at> ociweb.com> writes:
On Sep 30, 2008, at 1:34 PM, nicolas cellier wrote:
Thanks! I think I understand all you said except for two things.
- The ifCurtailed method. From just looking at the comment in the
method and the code, I have no idea what it does.
(execBlock ensure: finiBlock) will execute finiBlock whether an Exception occur or not while executing execBlock. One typical use in image is to close files.
(execBlock ifCurtailed: finiBlock) will execute finiBlock only if an Exception occur. Usage is rare.
- The reject method. Which class are you referring to? The ones I see
that contain that method don't seem related to exception handling.
Sorry, forget it, I'm just mixing the dialects! Exception>>#reject was a synonym for #pass in early VW pre-ANSI implementation. I find reject quite expressive though: either I handle the exception or reject it. If I reject it, the Exception is passed to an upper level (in the call stack) handling. I see #pass more as a consequence of my decision to #reject the Exception. But that's surely an effect of age: old progammers don't like their framework to change ;).
Mark Volkmann
And of course, please ask your questions, you are welcome. The idea of quota was just a joke addressed to this community for not answering promptly.
beginners@lists.squeakfoundation.org