ZeroDivide.st
author Claus Gittinger <cg@exept.de>
Mon, 08 Jun 2015 21:22:21 +0200
changeset 18465 e9e4bb62235f
parent 14717 8bd5b56dd171
child 18017 7fef9e17913f
child 20458 55727803f73d
permissions -rw-r--r--
added isOrdered query
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7585
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
     1
"
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
     2
 COPYRIGHT (c) 2001 by eXept Software AG
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
     3
              All Rights Reserved
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
     4
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
     5
 This software is furnished under a license and may be used
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
     6
 only in accordance with the terms of that license and with the
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
     8
 be provided or otherwise made available to, or used by, any
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
     9
 other person.  No title to or ownership of the software is
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    10
 hereby transferred.
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    11
"
5947
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libbasic' }"
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
DomainError subclass:#ZeroDivide
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
	instanceVariableNames:''
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	classVariableNames:''
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
6218
f528bf2bcc5f category
Claus Gittinger <cg@exept.de>
parents: 5969
diff changeset
    18
	category:'Kernel-Exceptions-Errors'
5947
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
6218
f528bf2bcc5f category
Claus Gittinger <cg@exept.de>
parents: 5969
diff changeset
    21
!ZeroDivide class methodsFor:'documentation'!
f528bf2bcc5f category
Claus Gittinger <cg@exept.de>
parents: 5969
diff changeset
    22
7585
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    23
copyright
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    24
"
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    25
 COPYRIGHT (c) 2001 by eXept Software AG
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    26
              All Rights Reserved
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    27
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    28
 This software is furnished under a license and may be used
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    29
 only in accordance with the terms of that license and with the
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    31
 be provided or otherwise made available to, or used by, any
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    32
 other person.  No title to or ownership of the software is
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    33
 hereby transferred.
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    34
"
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    35
!
87d76b40f897 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7584
diff changeset
    36
6218
f528bf2bcc5f category
Claus Gittinger <cg@exept.de>
parents: 5969
diff changeset
    37
documentation
f528bf2bcc5f category
Claus Gittinger <cg@exept.de>
parents: 5969
diff changeset
    38
"
f528bf2bcc5f category
Claus Gittinger <cg@exept.de>
parents: 5969
diff changeset
    39
    Raised when a division by zero is attempted.
f528bf2bcc5f category
Claus Gittinger <cg@exept.de>
parents: 5969
diff changeset
    40
"
7584
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    41
!
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    42
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    43
examples
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    44
"
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    45
    the following leads into a debugger:
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    46
                                                                    [exBegin]
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    47
        |divisor|
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    48
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    49
        divisor := 0.
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    50
        Transcript showCR: ( 5 / divisor ).
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    51
                                                                    [exEnd]
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    52
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    53
10273
84eddf61acc5 Fix spelling in example comment
Stefan Vogel <sv@exept.de>
parents: 7585
diff changeset
    54
    the following does NOT lead into a debugger:
7584
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    55
                                                                    [exBegin]
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    56
        |divisor|
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    57
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    58
        divisor := 0.
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    59
        [
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    60
            Transcript showCR: ( 5 / divisor ).
10273
84eddf61acc5 Fix spelling in example comment
Stefan Vogel <sv@exept.de>
parents: 7585
diff changeset
    61
        ] on:ZeroDivide do:[
84eddf61acc5 Fix spelling in example comment
Stefan Vogel <sv@exept.de>
parents: 7585
diff changeset
    62
            Transcript flash.
84eddf61acc5 Fix spelling in example comment
Stefan Vogel <sv@exept.de>
parents: 7585
diff changeset
    63
        ]
7584
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    64
                                                                    [exEnd]
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    65
"
6218
f528bf2bcc5f category
Claus Gittinger <cg@exept.de>
parents: 5969
diff changeset
    66
! !
5947
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
6690
07ef28245da8 notifier now initialized here
Claus Gittinger <cg@exept.de>
parents: 6218
diff changeset
    68
!ZeroDivide class methodsFor:'initialization'!
07ef28245da8 notifier now initialized here
Claus Gittinger <cg@exept.de>
parents: 6218
diff changeset
    69
07ef28245da8 notifier now initialized here
Claus Gittinger <cg@exept.de>
parents: 6218
diff changeset
    70
initialize
07ef28245da8 notifier now initialized here
Claus Gittinger <cg@exept.de>
parents: 6218
diff changeset
    71
    NotifierString := 'division by zero'.
07ef28245da8 notifier now initialized here
Claus Gittinger <cg@exept.de>
parents: 6218
diff changeset
    72
! !
07ef28245da8 notifier now initialized here
Claus Gittinger <cg@exept.de>
parents: 6218
diff changeset
    73
5947
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
!ZeroDivide methodsFor:'accessing'!
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
14717
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    76
defaultResumeValue
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    77
    "no, we return infinity here, if ever proceeded"
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    78
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    79
    ^ parameter receiver class infinity
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    80
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    81
    "
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    82
     |a b|
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    83
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    84
     a := 5.
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    85
     b := 0.
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    86
     ZeroDivide handle:[:ex |
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    87
        Transcript showCR:('division by zero - dividend was: ' , ex dividend printString).
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    88
        ex proceed
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    89
     ] do:[
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    90
        a / b
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    91
     ]            
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    92
    "
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    93
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    94
    "
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    95
     |a b|
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    96
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    97
     a := 5.0.
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    98
     b := 0.0.
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
    99
     ZeroDivide handle:[:ex |
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
   100
        Transcript showCR:('division by zero - dividend was: ' , ex dividend printString).
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
   101
        ex proceed
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
   102
     ] do:[
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
   103
        a / b
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
   104
     ]            
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
   105
    "
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
   106
!
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
   107
5947
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
dividend
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
    "Return the number that was being divided by zero."
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
5969
ed98cd153ecc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5947
diff changeset
   111
    ^ parameter receiver
5947
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    "
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
     |a b|
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
     a := 5.
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
     b := 0.
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
     Integer divisionByZeroSignal handle:[:ex |
5969
ed98cd153ecc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5947
diff changeset
   119
        Transcript showCR:('division by zero - dividend was: ' , ex dividend printString)
5947
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
     ] do:[
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
        a // b
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
     ]
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
    "
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
! !
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
!ZeroDivide class methodsFor:'documentation'!
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
version
14717
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
   129
    ^ '$Header: /cvs/stx/stx/libbasic/ZeroDivide.st,v 1.8 2013-01-25 17:19:34 cg Exp $'
5947
45351eedb5a1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
! !
7584
2104df18c2af example
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
   131
14717
8bd5b56dd171 class: ZeroDivide
Claus Gittinger <cg@exept.de>
parents: 10273
diff changeset
   132
6690
07ef28245da8 notifier now initialized here
Claus Gittinger <cg@exept.de>
parents: 6218
diff changeset
   133
ZeroDivide initialize!