Pharo-dev
By thread
pharo-dev@lists.pharo.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- 1 participants
- 144619 messages
Re: [Pharo-project] Improving Pharo's Exception Hierarchy
by Dale Henrichs
By managing the class hierarchy:
Imagine trying to find meaningful exception classes in a class
hierarchy of 10,000 classes with significant nesting vs finding a
meaningful class in a hierarchy of 10 classes ... at what point does
the hierarchy get out of hand?
I think GemStone had 600 some unique errors and that was pared down to
<30 Exception classes with reason codes...
It's a matter of practicality...I would think that somewhere around 100
classes the hierarchy starts to become very tedious to understand even
for those trying to find the right place to insert there brand spanking
new exception class.
99% of exception handlers will _use_ Error_ anyway, so the exception
hierarchy will be largely ignored by most folks, especially if it is
large an unwieldly.
100 small classes that serve a real purpose and have explicit exception
handlers written using every one of them, well then by god! 100 classes
are absolutely called for.
To me this is different than 100 places where I signal an exception ...
do really need a different exception class for each of the 100
signalling sites? What if there are no handlers written for any of them?
Like I said, if there are legitimate need to handle an exception, then
there is a legitimate need to create an exception class, but if I have 5
different error conditions, but I will have a single exception handler
for all 5 conditions, _should_ I create 5 classes or 1 class with some
state to disambiguate?
If your answer is "It depends...", then you will understand what I am
saying:)
Dale
On 04/13/2011 02:01 PM, Toon Verwaest wrote:
> I find the "managing the exception hierarchy" a bit strange... Do you
> really have to manage anything more than just normal classes? Every
> exception is related to a specific part of your code, just like other
> classes. What's wrong with creating hundreds of small classes wherever
> it's necessary? You might save a tiny bit of memory by using error codes
> or symbols, but I don't really see much more of a gain there, while you
> do gain from proper objects.
>
> Being clear and modeling properly generally pays off in the long run.
> And the bit of runtime memory you save isn't really worth your while...
>
> Or am I missing something else? I didn't really follow the whole
> conversation in-depth.
>
> cheers,
> Toon
>
> On 04/13/2011 09:54 PM, Dale Henrichs wrote:
>> Camillo,
>>
>> Hey, I _am_ old, but not _that_ old:) ... There are a couple of things
>> that were invented in the Stone Age that have survived to today, so
>> old ideas are not immediately bad, because they are old:)
>>
>> It feels like you are creating classes that are not much more than
>> symbols ...
>>
>> I am not one to shy away from using classes when they are called for,
>> but I am just making a practicality point ... we don't have a unique
>> class for each character in the alphabet, but we could....we could
>> have a unique class for every possible error condition or not ...
>>
>> I think it is simply a practical answer...
>>
>> I do maintain that you _should_ use some sort of test along the lines
>> of: "Will anyone ever need to write a handler for the exception?" in
>> your criteria for deciding when to create a class and when to use
>> something like a "reason code" to disambiguate the signalling site...
>>
>> Dale
>>
>> On 04/13/2011 12:32 PM, Camillo Bruni wrote:
>>> Perfect, I ll be there to bang heads ;).
>>>
>>> So without "Exception" pre- or suffix seems to be nice. However I
>>> don't see the need of using symbols over real classes. This feels
>>> indeed like going to stone age of error handling, thats what you have
>>> polymorphism and ExceptionSets for.
>>>
>>> Anyway, the main idea is to make single exceptions recognizable and
>>> not just use one single, basically meaningless, exception type.
>>>
>>> best regards, Camillo Bruni
>>>
>>>
>>> On 2011-04-13, at 21:22, Sven Van Caekenberghe wrote:
>>>
>>>> Thanks a lot everybody for the reactions, this could become a nice
>>>> discussion next Friday. All points raised are valid, I would like
>>>> simple names and a compact multipurpose hierarchy too.
>>>>
>>>> On 13 Apr 2011, at 19:39, Dale Henrichs wrote:
>>>>
>>>>> Some thoughts from an old man (started programming before
>>>>> exceptions of any kind were available:) ...
>>>>>
>>>>> In the old days, error numbers had a place in the universe ...
>>>>> error numbers of a certain range indicated specific errors and
>>>>> the "error handlers" could check for a range or a specific error
>>>>> ...
>>>>>
>>>>> Today I think there is still a place for the notion of "error
>>>>> numbers".
>>>>>
>>>>> In Smalltalk I would use Symbols instead of numbers, but the idea
>>>>> would be to use a concrete exception class to identify broad
>>>>> categories of error conditions (i.e., FileStreamError) and a
>>>>> symbolic "reason code" to indicate the specific error (i.e.,
>>>>> #fileDoesNotExist, #fileExists, #cannotDelete, etc.), that way an
>>>>> error handler can be written for FileStreamError and then
>>>>> specific action take with respect to which "reason code" is
>>>>> involved, if such action is needed.
>>>>>
>>>>> The main advantage of using reasonCodes over using a "class per
>>>>> error condition" is that you can reduce the size of the Exception
>>>>> hierarchy to a manageable size (GemStone has hundreds of error
>>>>> conditions, so we've resorted to using "reason codes" to manage
>>>>> the size of the hierarchy).
>>>>>
>>>>> As Hernan hints, more often than not it is important to be very
>>>>> specific about the error condition when signalling an error (a
>>>>> unique error message per "per reason code" would be desirable),
>>>>> but the there are very few places where the handler is going to
>>>>> be that specific ...
>>>>>
>>>>> In other words, if it is likely that programmers in the course of
>>>>> using an application will be writing specific error handlers to
>>>>> distinguish between the KeyNotFound and ValueNotFound condition,
>>>>> then classes should be created, otherwise, the NotFoundException
>>>>> could be implemented with three reason codes: #keyNotFound,
>>>>> #valueNotFound, and #elementNotFound and you'd get the best of
>>>>> both worlds, explicit information at the signalling site and a
>>>>> much smaller and more manageable Exception class hierarchy.
>>>>>
>>>>> Dale
>>>>>
>>>>> On 04/13/2011 10:15 AM, Hernan Wilkinson wrote:
>>>>>> I think it is not a good idea to use the prefix Exception. We
>>>>>> do not use the word "exception" in real life, so we should not
>>>>>> do it on our systems. About the proposed hierarchy, the problem
>>>>>> with having specific exceptions is that they are important for
>>>>>> those who catch them, not for those who signal them. For
>>>>>> example, besides the name, what is the difference between
>>>>>> KeyNotFound or ValueNotFound? none. So, I think that the
>>>>>> exception hierarchy should be grown from it uses, not created
>>>>>> based on how or where they are signaled.
>>>>>>
>>>>>> my 2 cents :-)
>>>>>>
>>>>>> On Wed, Apr 13, 2011 at 1:55 PM, Miguel
>>>>>> Cobá<miguel.coba(a)gmail.com<mailto:miguel.coba@gmail.com>>
>>>>>> wrote:
>>>>>>
>>>>>> El mié, 13-04-2011 a las 14:52 +0200, Camillo Bruni escribió:
>>>>>>
>>>>>>> And as Mariano pointed out, there should be a convention on
>>>>>>> the naming: I am still not sure about suffixing the exception
>>>>>>> classes
>>>>>> with
>>>>>>> "Exception", but I guess this is a good thing to do. Though
>>>>>>> I
>>>>>> must say
>>>>>>> that I omitted it so far ;) and just put the verb there, but
>>>>>>> that can be easily changed.
>>>>>>
>>>>>> I would say no to suffixes. Analogous to announcements, they
>>>>>> shouldn't have the suffix. The name should be descriptive
>>>>>> enough and intention revealing that the suffix isn't needed in
>>>>>> most cases. For example, I think that
>>>>>>
>>>>>> DividedByZero
>>>>>>
>>>>>> is better than
>>>>>>
>>>>>> DividedByZeroException
>>>>>>
>>>>>> and no information is lost with the sorter name. Instead,
>>>>>> DivideByZero isn't clear enough to indicate that is a event
>>>>>> that happened.
>>>>>>
>>>>>> What do you think?
>>>>>>
>>>>>> -- Miguel Cobá http://twitter.com/MiguelCobaMtz
>>>>>> http://miguel.leugim.com.mx
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> -- *Hernán Wilkinson Agile Software Development, Teaching&
>>>>>> Coaching Mobile: +54 - 911 - 4470 - 7207 email:
>>>>>> hernan.wilkinson(a)10Pines.com site:
>>>>>> http://www.10Pines.com<http://www.10pines.com/>*
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
April 13, 2011
Re: [Pharo-project] Meanwhile, at another vm
by Mariano Martinez Peck
aha....good point guys. Thanks :)
On Wed, Apr 13, 2011 at 11:29 PM, Nicolas Cellier <
nicolas.cellier.aka.nice(a)gmail.com> wrote:
> Maybe if that class has living instances, you must provide a way to
> mutate the instances...
> The easiest way is to create a mutated clone and becomeForward.
>
> Nicolas
>
> 2011/4/13 Mariano Martinez Peck <marianopeck(a)gmail.com>:
> >
> >
> > On Wed, Apr 13, 2011 at 11:06 PM, Dave Mason <dmason(a)mason-rose.ca>
> wrote:
> >>
> >> From:
> >> http://www.jcp.org/en/jsr/detail?id=292
> >>
> >> "We will also investigate support for hotswapping, the capability to
> >> modify the structure of classes at run time."
> >>
> >> So, yes, they planned to "investigate" a version of become:
> >>
> >
> > How is that phrase related to #become: ? Modyfing the structure of a
> > class at runtime has nothing to do with a #become:
> >
> >
> >>
> >> The DaVinci Machine
> >>
> >> http://openjdk.java.net/projects/mlvm/
> >>
> >> has an implementation:
> >>
> >> http://wiki.jvmlangsummit.com/images/4/41/DaVinciMachineTalk.pdf
> >>
> >> ../Dave
> >
> >
> >
> > --
> > Mariano
> > http://marianopeck.wordpress.com
> >
> >
>
>
--
Mariano
http://marianopeck.wordpress.com
April 13, 2011
Re: [Pharo-project] Meanwhile, at another vm
by Nicolas Cellier
Maybe if that class has living instances, you must provide a way to
mutate the instances...
The easiest way is to create a mutated clone and becomeForward.
Nicolas
2011/4/13 Mariano Martinez Peck <marianopeck(a)gmail.com>:
>
>
> On Wed, Apr 13, 2011 at 11:06 PM, Dave Mason <dmason(a)mason-rose.ca> wrote:
>>
>> From:
>> Â Â Â Â http://www.jcp.org/en/jsr/detail?id=292
>>
>> "We will also investigate support for hotswapping, the capability to
>> modify the structure of classes at run time."
>>
>> So, yes, they planned to "investigate" a version of become:
>>
>
> How is that phrase related to #become:  ?  Modyfing the structure of a
> class at runtime has nothing to do with a #become:
>
>
>>
>> The DaVinci Machine
>>
>> Â Â Â Â http://openjdk.java.net/projects/mlvm/
>>
>> has an implementation:
>>
>> Â Â Â Â http://wiki.jvmlangsummit.com/images/4/41/DaVinciMachineTalk.pdf
>>
>> ../Dave
>
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
>
April 13, 2011
Re: [Pharo-project] Meanwhile, at another vm
by Göran Krampe
On 04/13/2011 11:15 PM, Mariano Martinez Peck wrote:
> On Wed, Apr 13, 2011 at 11:06 PM, Dave Mason <dmason(a)mason-rose.ca
> "We will also investigate support for hotswapping, the capability to
> modify the structure of classes at run time."
>
> So, yes, they planned to "investigate" a version of become:
>
>
> How is that phrase related to #become: ? Modyfing the structure of a
> class at runtime has nothing to do with a #become:
It depends. If "modify structure" means "modifying methods" then indeed
it has little to do with become:. But if it means "changing the memory
layout of the class by for example adding ivars" then it has to do with
become: because it is needed to do instance migration from the old class
to the new class.
regards, Göran
April 13, 2011
Re: [Pharo-project] Improving Pharo's Exception Hierarchy
by Nicolas Cellier
What's wrong is simple to explain: Your image is a namespace. The more
names you have, the more difficult it is to apprehend, understand and
reuse.
Wait, wait, wait, you might say, whether I use Symbols or Class names,
there are always the same number of names at the end.
Yes, but what makes the big difference is the IDE. What we see thru
this IDE is either:
- a view by package or protocol
- a hierarchical view.
How to find if a specific Exception exists, what it's name is ?
By now, I find package names misleading, because not very uniform.
Even if uniformized, it's not always obvious where to search for.
Plus, there are a lot of packages.
The hierarchical view would be more natural, but is to my taste
unusable above 30 items. I find current Exception hierarchy
unfriendly.
So the idea to use a double classification, a quite generic exception
name like FileError and a specialization "code" does make sense.
You must understand this, when our neurons were younger, we learnt
Smalltalk with a ~300 classes image. What a great pleasure to be able
to embrace the whole system !
Now our older neurons must remember about 8x more...
So we appreciate the inflation with a different scale.
Nicolas
2011/4/13 Toon Verwaest <toon.verwaest(a)gmail.com>:
> I find the "managing the exception hierarchy" a bit strange... Do you really
> have to manage anything more than just normal classes? Every exception is
> related to a specific part of your code, just like other classes. What's
> wrong with creating hundreds of small classes wherever it's necessary? You
> might save a tiny bit of memory by using error codes or symbols, but I don't
> really see much more of a gain there, while you do gain from proper objects.
>
> Being clear and modeling properly generally pays off in the long run. And
> the bit of runtime memory you save isn't really worth your while...
>
> Or am I missing something else? I didn't really follow the whole
> conversation in-depth.
>
> cheers,
> Toon
>
> On 04/13/2011 09:54 PM, Dale Henrichs wrote:
>>
>> Camillo,
>>
>> Hey, I _am_ old, but not _that_ old:) ... There are a couple of things
>> that were invented in the Stone Age that have survived to today, so old
>> ideas are not immediately bad, because they are old:)
>>
>> It feels like you are creating classes that are not much more than symbols
>> ...
>>
>> I am not one to shy away from using classes when they are called for, but
>> I am just making a practicality point ... we don't have a unique class for
>> each character in the alphabet, but we could....we could have a unique class
>> for every possible error condition or not ...
>>
>> I think it is simply a practical answer...
>>
>> I do maintain that you _should_ use some sort of test along the lines of:
>> "Will anyone ever need to write a handler for the exception?" in your
>> criteria for deciding when to create a class and when to use something like
>> a "reason code" to disambiguate the signalling site...
>>
>> Dale
>>
>> On 04/13/2011 12:32 PM, Camillo Bruni wrote:
>>>
>>> Perfect, I ll be there to bang heads ;).
>>>
>>> So without "Exception" pre- or suffix seems to be nice. However I
>>> don't see the need of using symbols over real classes. This feels
>>> indeed like going to stone age of error handling, thats what you have
>>> polymorphism and ExceptionSets for.
>>>
>>> Anyway, the main idea is to make single exceptions recognizable and
>>> not just use one single, basically meaningless, exception type.
>>>
>>> best regards, Camillo Bruni
>>>
>>>
>>> On 2011-04-13, at 21:22, Sven Van Caekenberghe wrote:
>>>
>>>> Thanks a lot everybody for the reactions, this could become a nice
>>>> discussion next Friday. All points raised are valid, I would like
>>>> simple names and a compact multipurpose hierarchy too.
>>>>
>>>> On 13 Apr 2011, at 19:39, Dale Henrichs wrote:
>>>>
>>>>> Some thoughts from an old man (started programming before
>>>>> exceptions of any kind were available:) ...
>>>>>
>>>>> In the old days, error numbers had a place in the universe ...
>>>>> error numbers of a certain range indicated specific errors and
>>>>> the "error handlers" could check for a range or a specific error
>>>>> ...
>>>>>
>>>>> Today I think there is still a place for the notion of "error
>>>>> numbers".
>>>>>
>>>>> In Smalltalk I would use Symbols instead of numbers, but the idea
>>>>> would be to use a concrete exception class to identify broad
>>>>> categories of error conditions (i.e., FileStreamError) and a
>>>>> symbolic "reason code" to indicate the specific error (i.e.,
>>>>> #fileDoesNotExist, #fileExists, #cannotDelete, etc.), that way an
>>>>> error handler can be written for FileStreamError and then
>>>>> specific action take with respect to which "reason code" is
>>>>> involved, if such action is needed.
>>>>>
>>>>> The main advantage of using reasonCodes over using a "class per
>>>>> error condition" is that you can reduce the size of the Exception
>>>>> hierarchy to a manageable size (GemStone has hundreds of error
>>>>> conditions, so we've resorted to using "reason codes" to manage
>>>>> the size of the hierarchy).
>>>>>
>>>>> As Hernan hints, more often than not it is important to be very
>>>>> specific about the error condition when signalling an error (a
>>>>> unique error message per "per reason code" would be desirable),
>>>>> but the there are very few places where the handler is going to
>>>>> be that specific ...
>>>>>
>>>>> In other words, if it is likely that programmers in the course of
>>>>> using an application will be writing specific error handlers to
>>>>> distinguish between the KeyNotFound and ValueNotFound condition,
>>>>> then classes should be created, otherwise, the NotFoundException
>>>>> could be implemented with three reason codes: #keyNotFound,
>>>>> #valueNotFound, and #elementNotFound and you'd get the best of
>>>>> both worlds, explicit information at the signalling site and a
>>>>> much smaller and more manageable Exception class hierarchy.
>>>>>
>>>>> Dale
>>>>>
>>>>> On 04/13/2011 10:15 AM, Hernan Wilkinson wrote:
>>>>>>
>>>>>> I think it is not a good idea to use the prefix Exception. We
>>>>>> do not use the word "exception" in real life, so we should not
>>>>>> do it on our systems. About the proposed hierarchy, the problem
>>>>>> with having specific exceptions is that they are important for
>>>>>> those who catch them, not for those who signal them. For
>>>>>> example, besides the name, what is the difference between
>>>>>> KeyNotFound or ValueNotFound? none. So, I think that the
>>>>>> exception hierarchy should be grown from it uses, not created
>>>>>> based on how or where they are signaled.
>>>>>>
>>>>>> my 2 cents :-)
>>>>>>
>>>>>> On Wed, Apr 13, 2011 at 1:55 PM, Miguel
>>>>>> Cobá<miguel.coba(a)gmail.com <mailto:miguel.coba@gmail.com>>
>>>>>> wrote:
>>>>>>
>>>>>> El mié, 13-04-2011 a las 14:52 +0200, Camillo Bruni escribió:
>>>>>>
>>>>>>> And as Mariano pointed out, there should be a convention on
>>>>>>> the naming: I am still not sure about suffixing the exception
>>>>>>> classes
>>>>>>
>>>>>> with
>>>>>>>
>>>>>>> "Exception", but I guess this is a good thing to do. Though
>>>>>>> I
>>>>>>
>>>>>> must say
>>>>>>>
>>>>>>> that I omitted it so far ;) and just put the verb there, but
>>>>>>> that can be easily changed.
>>>>>>
>>>>>> I would say no to suffixes. Analogous to announcements, they
>>>>>> shouldn't have the suffix. The name should be descriptive
>>>>>> enough and intention revealing that the suffix isn't needed in
>>>>>> most cases. For example, I think that
>>>>>>
>>>>>> DividedByZero
>>>>>>
>>>>>> is better than
>>>>>>
>>>>>> DividedByZeroException
>>>>>>
>>>>>> and no information is lost with the sorter name. Instead,
>>>>>> DivideByZero isn't clear enough to indicate that is a event
>>>>>> that happened.
>>>>>>
>>>>>> What do you think?
>>>>>>
>>>>>> -- Miguel Cobá http://twitter.com/MiguelCobaMtz
>>>>>> http://miguel.leugim.com.mx
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> -- *Hernán Wilkinson Agile Software Development, Teaching&
>>>>>> Coaching Mobile: +54 - 911 - 4470 - 7207 email:
>>>>>> hernan.wilkinson(a)10Pines.com site:
>>>>>> http://www.10Pines.com<http://www.10pines.com/>*
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
>
April 13, 2011
Re: [Pharo-project] Meanwhile, at another vm
by Mariano Martinez Peck
On Wed, Apr 13, 2011 at 11:06 PM, Dave Mason <dmason(a)mason-rose.ca> wrote:
> From:
> http://www.jcp.org/en/jsr/detail?id=292
>
> "We will also investigate support for hotswapping, the capability to modify
> the structure of classes at run time."
>
> So, yes, they planned to "investigate" a version of become:
>
>
How is that phrase related to #become: ? Modyfing the structure of a
class at runtime has nothing to do with a #become:
> The DaVinci Machine
>
> http://openjdk.java.net/projects/mlvm/
>
> has an implementation:
>
> http://wiki.jvmlangsummit.com/images/4/41/DaVinciMachineTalk.pdf
>
> ../Dave
>
--
Mariano
http://marianopeck.wordpress.com
April 13, 2011
Re: [Pharo-project] Meanwhile, at another vm
by Dave Mason
From:
http://www.jcp.org/en/jsr/detail?id=292
"We will also investigate support for hotswapping, the capability to modify the structure of classes at run time."
So, yes, they planned to "investigate" a version of become:
The DaVinci Machine
http://openjdk.java.net/projects/mlvm/
has an implementation:
http://wiki.jvmlangsummit.com/images/4/41/DaVinciMachineTalk.pdf
../Dave
April 13, 2011
Re: [Pharo-project] Meanwhile, at another vm
by Philippe Marschall
On 13.04.2011 19:40, Stephan Eggermont wrote:
> JSR 292 explicitly talks about become: (calls it hotswap) and is supposed
> to make it possible to run Smalltalk efficiently on a jvm.
What I know as hotswap as hot swap would not help with #become:. My
understanding is that when "they" went from an object table to direct
pointers for memory access speed that made it more complicated to
implement #become: and certainly slower.
Cheers
Philippe
April 13, 2011
Re: [Pharo-project] Improving Pharo's Exception Hierarchy
by Toon Verwaest
I find the "managing the exception hierarchy" a bit strange... Do you
really have to manage anything more than just normal classes? Every
exception is related to a specific part of your code, just like other
classes. What's wrong with creating hundreds of small classes wherever
it's necessary? You might save a tiny bit of memory by using error codes
or symbols, but I don't really see much more of a gain there, while you
do gain from proper objects.
Being clear and modeling properly generally pays off in the long run.
And the bit of runtime memory you save isn't really worth your while...
Or am I missing something else? I didn't really follow the whole
conversation in-depth.
cheers,
Toon
On 04/13/2011 09:54 PM, Dale Henrichs wrote:
> Camillo,
>
> Hey, I _am_ old, but not _that_ old:) ... There are a couple of things
> that were invented in the Stone Age that have survived to today, so
> old ideas are not immediately bad, because they are old:)
>
> It feels like you are creating classes that are not much more than
> symbols ...
>
> I am not one to shy away from using classes when they are called for,
> but I am just making a practicality point ... we don't have a unique
> class for each character in the alphabet, but we could....we could
> have a unique class for every possible error condition or not ...
>
> I think it is simply a practical answer...
>
> I do maintain that you _should_ use some sort of test along the lines
> of: "Will anyone ever need to write a handler for the exception?" in
> your criteria for deciding when to create a class and when to use
> something like a "reason code" to disambiguate the signalling site...
>
> Dale
>
> On 04/13/2011 12:32 PM, Camillo Bruni wrote:
>> Perfect, I ll be there to bang heads ;).
>>
>> So without "Exception" pre- or suffix seems to be nice. However I
>> don't see the need of using symbols over real classes. This feels
>> indeed like going to stone age of error handling, thats what you have
>> polymorphism and ExceptionSets for.
>>
>> Anyway, the main idea is to make single exceptions recognizable and
>> not just use one single, basically meaningless, exception type.
>>
>> best regards, Camillo Bruni
>>
>>
>> On 2011-04-13, at 21:22, Sven Van Caekenberghe wrote:
>>
>>> Thanks a lot everybody for the reactions, this could become a nice
>>> discussion next Friday. All points raised are valid, I would like
>>> simple names and a compact multipurpose hierarchy too.
>>>
>>> On 13 Apr 2011, at 19:39, Dale Henrichs wrote:
>>>
>>>> Some thoughts from an old man (started programming before
>>>> exceptions of any kind were available:) ...
>>>>
>>>> In the old days, error numbers had a place in the universe ...
>>>> error numbers of a certain range indicated specific errors and
>>>> the "error handlers" could check for a range or a specific error
>>>> ...
>>>>
>>>> Today I think there is still a place for the notion of "error
>>>> numbers".
>>>>
>>>> In Smalltalk I would use Symbols instead of numbers, but the idea
>>>> would be to use a concrete exception class to identify broad
>>>> categories of error conditions (i.e., FileStreamError) and a
>>>> symbolic "reason code" to indicate the specific error (i.e.,
>>>> #fileDoesNotExist, #fileExists, #cannotDelete, etc.), that way an
>>>> error handler can be written for FileStreamError and then
>>>> specific action take with respect to which "reason code" is
>>>> involved, if such action is needed.
>>>>
>>>> The main advantage of using reasonCodes over using a "class per
>>>> error condition" is that you can reduce the size of the Exception
>>>> hierarchy to a manageable size (GemStone has hundreds of error
>>>> conditions, so we've resorted to using "reason codes" to manage
>>>> the size of the hierarchy).
>>>>
>>>> As Hernan hints, more often than not it is important to be very
>>>> specific about the error condition when signalling an error (a
>>>> unique error message per "per reason code" would be desirable),
>>>> but the there are very few places where the handler is going to
>>>> be that specific ...
>>>>
>>>> In other words, if it is likely that programmers in the course of
>>>> using an application will be writing specific error handlers to
>>>> distinguish between the KeyNotFound and ValueNotFound condition,
>>>> then classes should be created, otherwise, the NotFoundException
>>>> could be implemented with three reason codes: #keyNotFound,
>>>> #valueNotFound, and #elementNotFound and you'd get the best of
>>>> both worlds, explicit information at the signalling site and a
>>>> much smaller and more manageable Exception class hierarchy.
>>>>
>>>> Dale
>>>>
>>>> On 04/13/2011 10:15 AM, Hernan Wilkinson wrote:
>>>>> I think it is not a good idea to use the prefix Exception. We
>>>>> do not use the word "exception" in real life, so we should not
>>>>> do it on our systems. About the proposed hierarchy, the problem
>>>>> with having specific exceptions is that they are important for
>>>>> those who catch them, not for those who signal them. For
>>>>> example, besides the name, what is the difference between
>>>>> KeyNotFound or ValueNotFound? none. So, I think that the
>>>>> exception hierarchy should be grown from it uses, not created
>>>>> based on how or where they are signaled.
>>>>>
>>>>> my 2 cents :-)
>>>>>
>>>>> On Wed, Apr 13, 2011 at 1:55 PM, Miguel
>>>>> Cobá<miguel.coba(a)gmail.com <mailto:miguel.coba@gmail.com>>
>>>>> wrote:
>>>>>
>>>>> El mié, 13-04-2011 a las 14:52 +0200, Camillo Bruni escribió:
>>>>>
>>>>>> And as Mariano pointed out, there should be a convention on
>>>>>> the naming: I am still not sure about suffixing the exception
>>>>>> classes
>>>>> with
>>>>>> "Exception", but I guess this is a good thing to do. Though
>>>>>> I
>>>>> must say
>>>>>> that I omitted it so far ;) and just put the verb there, but
>>>>>> that can be easily changed.
>>>>>
>>>>> I would say no to suffixes. Analogous to announcements, they
>>>>> shouldn't have the suffix. The name should be descriptive
>>>>> enough and intention revealing that the suffix isn't needed in
>>>>> most cases. For example, I think that
>>>>>
>>>>> DividedByZero
>>>>>
>>>>> is better than
>>>>>
>>>>> DividedByZeroException
>>>>>
>>>>> and no information is lost with the sorter name. Instead,
>>>>> DivideByZero isn't clear enough to indicate that is a event
>>>>> that happened.
>>>>>
>>>>> What do you think?
>>>>>
>>>>> -- Miguel Cobá http://twitter.com/MiguelCobaMtz
>>>>> http://miguel.leugim.com.mx
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -- *Hernán Wilkinson Agile Software Development, Teaching&
>>>>> Coaching Mobile: +54 - 911 - 4470 - 7207 email:
>>>>> hernan.wilkinson(a)10Pines.com site:
>>>>> http://www.10Pines.com<http://www.10pines.com/>*
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
April 13, 2011
Re: [Pharo-project] About float: new chapter looking for reader and contributors
by Nicolas Cellier
Here is a small variation. It's not perfect, and most elements are
already in Stephane's text.
But maybe we can jump deeper in the first example that claims some explanations.
We can first explain that 0.1 will answer the Float nearest to (1/10).
Thanks to this important property, if we enter 0.1, it will be printed
0.1 and reinterpreted the same. A nice property to have!
However, what is fundamental is that this Float won't be equal to (1/10).
How is this so ? Hey we didn't learn that in school !
Well, Float have an internal representation in base 2, of the form
mantissa * (2 raisedTo: exponent).
There is no way to represent (1/10) in base 2 with a finite number of
bits... (like illustrated with 1.3 example, #significandAsInteger,
#exponent, #ulp and such kind of messages...).
A rounding operation has to occur to make this number fit in Float
internal representation ( it might be good to tell that Pharo Float
follow the IEEE 754 double precision standard with a link to
http://en.wikipedia.org/wiki/IEEE_754-1985 . This standard governs the
way most FPU work on this planet).
This rounding operation introduce a rounding error, and thus we don't
get exactly (1/10).
To know the exact internal representation of 0.1 the Smalltalk way is
as usual to send a message: 0.1 asTrueFraction.
The same goes with 0.2, it's not equal to (2/10), check it with 0.2
asTrueFraction.
So what goes on with this operation 0.1+0.2 ?
In fact you asked the system to perform following operation (0.1
asTrueFraction+0.2 asTrueFraction) asFloat.
(0.1 asTrueFraction+0.2 asTrueFraction) is an exact operation, but the
result again does not fit in Float internal representation:
(0.1 asTrueFraction+0.2 asTrueFraction) numerator highBit -> 54
(0.1 asTrueFraction+0.2 asTrueFraction) numerator lowBit -> 1
This means that 54 bits of mantissa are required to represent this
number. Float only have 53
Float precision -> 53
So converting it to aFloat requires another rounding operation, and
due to this rounding error,
(0.1 asTrueFraction+0.2 asTrueFraction) ~= (0.1 asTrueFraction+0.2
asTrueFraction) asFloat.
That's exactly how your IEEE-754 compliant FPU will work.
In the whole process, 3 rounding errors have been cumulated:
(1/10) asFloat -> 0.1 (the error is not yet visible, but it's here already)
(2/10) asFloat -> 0.2 (same)
(0.1 asTrueFraction+0.2 asTrueFraction) asFloat -> 0.30000000000000004
This is to be compared to 0.3, which has a single rounding error:
(3/10) asFloat -> 0.3
Due to these rounding errors, and the way they cumulate or annihilate,
both result might differ. And in this case, they differ.
This is a very important property of Float. Float are fast thanks to
hardware acceleration, and thanks to these rounding errors that keep
the number of significant bits from growing. But the counterpart is
that operations on Float are inexact. Due to this inexactness, it is
most often inadequate to rely on strict equality of Float, as this
very simple example illustrates. Instead, Float comparisons shall
better be tested with fuzzy tolerance.
Note that the nice thing with Pharo is that you immediately see that
(0.1+0.2) ~= 0.3 thanks to extraneous digits printed.
Pharo does not hide the horrible truth by shortening the printed
representation to 0.3 like some system do.
However, the decimal printed form does not show you the truth about
0.1 ~= (1/10). Inexactness is hidden. This is an implicit knowledge to
remember about Float, that you now learned with this lesson.
Remember, this is not a deficiency of Pharo. This is the way Float are
expected to work whatever the language.
Nicolas
2011/4/13 laurent laffont <laurent.laffont(a)gmail.com>:
>
>
>
> On Tue, Apr 12, 2011 at 6:07 PM, stephane ducasse <stephane.ducasse(a)free.fr>
> wrote:
>>
>> Hi guys
>>
>> I started to put in shape a chapter on floats based on the numerous
>> discussions we got over the years.
>> You can find it on github under the pharo by example book/Floats
>
>
> For me it's a good candidate for a ProfStef tutorial (text, evaluations,
> text, ...)
> Laurent
>
>>
>> Stef
>>
>
>
April 13, 2011