Query.st
author Claus Gittinger <cg@exept.de>
Tue, 09 Jul 2019 20:55:17 +0200
changeset 24417 03b083548da2
parent 23769 3f351898250c
permissions -rw-r--r--
#REFACTORING by exept class: Smalltalk class changed: #recursiveInstallAutoloadedClassesFrom:rememberIn:maxLevels:noAutoload:packageTop:showSplashInLevels: Transcript showCR:(... bindWith:...) -> Transcript showCR:... with:...
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6432
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 2002 by eXept Software AG
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
              All Rights Reserved
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libbasic' }"
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
19202
f310f0e159f9 comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 12088
diff changeset
    14
"{ NameSpace: Smalltalk }"
f310f0e159f9 comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 12088
diff changeset
    15
6432
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
Notification subclass:#Query
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	instanceVariableNames:''
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	classVariableNames:''
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	poolDictionaries:''
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	category:'Kernel-Exceptions'
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!Query class methodsFor:'documentation'!
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
copyright
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
"
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
 COPYRIGHT (c) 2002 by eXept Software AG
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
              All Rights Reserved
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 This software is furnished under a license and may be used
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 only in accordance with the terms of that license and with the
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 be provided or otherwise made available to, or used by, any
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 other person.  No title to or ownership of the software is
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 hereby transferred.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
"
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
!
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
documentation
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
"
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    Query is an abstract superclass for queries.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    A query is an exception which by default proceeds if unhandled and returns
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    a default value.
23769
3f351898250c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 23065
diff changeset
    45
    Subclasses might/should redefine 
3f351898250c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 23065
diff changeset
    46
        defaultResumeValue 
3f351898250c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 23065
diff changeset
    47
    on the instance side (by default, it answers nil if unhandled).
23065
7fe0bc418071 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22075
diff changeset
    48
    
6432
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
    As a class based reimplementation, it replaces and obsoletes the old 
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
    QuerySignal instance based mechanism.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
    Note:
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
        Query does not add/refine any functionality from its superclass.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
        It exists for the more descriptive class name only.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
11201
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    56
    Queries are like exceptions, except that they are not accepted
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    57
    by handlers for ordinary exceptions.
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    58
    I.e. a handler for a normal exception will not handle a query. 
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    59
    Thus, these bypass all normal exception handlers.
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    60
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    61
    However, if unhandled, no error is raised, instead it is simply ignored
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    62
    and nil is returned from the raise
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    63
    (as opposed to normal exceptions, which raise an unhandled exception error).
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    64
    Queries are also ignored, if a handler exists, but rejects.
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    65
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    66
    The main use of Queries is to implement an upQuery, which works even 
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    67
    if intermediate errorSignal handlers are present. 
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    68
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    69
    Code deep down in the calling hierarchy can post such an up-Query to ask
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    70
    for some information or to pass some information upward. 
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    71
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    72
    For example, the activityNotification mechanism is built on top of this:
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    73
    everyone can send such a notification which is either handled by someone
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    74
    up in the hierarchy (to show it in the windows info area) or simply
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    75
    ignored.
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    76
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    77
    Using Queries for this (instead of regular Signals) helps in documenting
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    78
    the intended usage of those signals.
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    79
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    80
    Another use of queries is to provide additional information to
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    81
    deeply nested methods, which is only required in the uncommon case;
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    82
    or if another parameter is required by some method, which was not planned
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    83
    for in the beginning, and you do not want to hand this value (via an
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    84
    additional argument) through all intermediate levels.
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    85
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    86
    A highly elegant solution to this problem is to provide a handler somewhere
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    87
    at the top of the calling hierarchy, and raise an upQuery from whereever
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    88
    that value is required.
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    89
    A concrete application can be found in the windowGroup-lastEvent
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    90
    queries. If anyone is interested in the windowEvent which was responible for 
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    91
    being invoked, all he needs to do is to raise the lastEventQuerySignal, 
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    92
    which returns that event.
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    93
    No intermediate methods are required to know anything about that.
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    94
    Another example is found in the way Metaclass asks for the nameSpace
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    95
    when new classes are to be installed. A Browser may simply answer such
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    96
    a query and provide a namespace (no need to pass that information down
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    97
    the calling chain).
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    98
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    99
    A final note (to C++ and Java fans):
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
   100
        such upQueries are only possible, if the exception handling mechanism
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
   101
        does not automatically unwind the stack for the handler invokation.
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
   102
        Since the handler must be able to proceed the execution and return
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
   103
        a value to the raiser ....
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
   104
        ... another demonstration of why ST's exception mechanisms are superior.
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
   105
6432
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
    [author:]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
        Claus Gittinger
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
    [see also:]
11201
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
   110
        Notification Warning Signal QuerySignal
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
   111
        (``Exception handling and signals'': programming/exceptions.html)
6432
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
"
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
!
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
examples
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
"
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
                                                                        [exBegin]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
    Query answer:'hello'
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
    do:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
        Transcript showCR:(Query query)
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
    ]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
                                                                        [exEnd]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
  an up-query from a deeply nested operation to a higher level:
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
  the example below demonstrates that a Query is not an Error
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
  (i.e. the Error-handler does not interfere with Queries)
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
                                                                        [exBegin]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
    |zero|
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
    zero := 0.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
    Query handle:[:ex |
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
        Transcript showCR:'query'.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
        ex proceedWith:true
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
    ] do:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
        'nesting'.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
        [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
            [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
                Error handle:[:ex |
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
                    Transcript showCR:'some error: ' , ex errorString.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
                    ex proceed
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
                ] do:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
                    [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
                        1 // zero.  'an error which is caught in the handler'.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
                        (Query query) == true ifTrue:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
                            Transcript showCR:'query says: ok'.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
                        ] ifFalse:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
                            Transcript showCR:'query says: no'
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
                        ]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
                    ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
                ]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
            ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
        ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
    ]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
                                                                        [exEnd]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
  for lazy typists, a more compact interface for query-answerign
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
  is also provided (which is also easier to read):
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
                                                                        [exBegin]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
    Query answer:true do:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
        'nesting'.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
        [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
            [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
                (Query query) == true ifTrue:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
                    Transcript showCR:'query says: ok'.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
                ] ifFalse:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
                    Transcript showCR:'query says: no'
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
                ]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
            ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
        ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
    ]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
                                                                        [exEnd]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
  an up-query from a deeply nested operation, for which there
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
  is no handler:
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
  (notice, this would not work with normal signals, which would raise
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
   another unhandled exception-exception;
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
   also notice the == check #raise's return value being true,
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
   instead of a simple ifTrue; this handles a nil-value from
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
   the unhandled query)
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
                                                                        [exBegin]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
    |zero|
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
    zero := 0.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
    [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
        'nesting'.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
        [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
            [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
                Error handle:[:ex |
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
                    Transcript showCR:'some error: ' , ex errorString.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
                    ex proceed
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
                ] do:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
                    [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
                        1 // zero.  'an error which is caught in the handler'.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
                        (Query raise) == true ifTrue:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
                            Transcript showCR:'query says: ok'.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
                        ] ifFalse:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
                            Transcript showCR:'query says: no'
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
                        ]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
                    ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
                ]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
            ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
        ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
    ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
                                                                         [exEnd]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
  counter-example, just to show that things would not work this way
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
  with regular signals:
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
                                                                        [exBegin]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
    |signal|
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
    signal := Signal new.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
    'nesting deeply'.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
    [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
        [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
            [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
                [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
                    [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
                        (signal raise) == true ifTrue:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
                            Transcript showCR:'query says: ok'.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
                        ] ifFalse:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
                            Transcript showCR:'query says: no'
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
                        ]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
                    ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
                ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
            ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
        ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
    ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
                                                                         [exEnd]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
   except, by handling the unhandled exception
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
   (but we think, that querySignals are easier to use and
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
    better document the intent):
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
                                                                        [exBegin]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
    |signal|
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
    signal := Signal new.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
    'nesting deeply'.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
    [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
        [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
            [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
                [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
                    [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
                        Signal noHandlerSignal handle:[:ex |
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
                            ex proceedWith:nil
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
                        ] do:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
                            (signal raise) == true ifTrue:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
                                Transcript showCR:'query says: ok'.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
                            ] ifFalse:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
                                Transcript showCR:'query says: no'
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
                            ]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
                        ]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
                    ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
                ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
            ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
        ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
    ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
                                                                         [exEnd]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
"
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
! !
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
!Query class methodsFor:'initialization'!
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
initialize
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
    NotifierString := 'Query'.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
    "
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
     self initialize
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
    "
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
! !
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
12088
1300308ff1c4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11201
diff changeset
   270
22063
7ac1174d7135 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 19202
diff changeset
   271
!Query class methodsFor:'testing'!
7ac1174d7135 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 19202
diff changeset
   272
7ac1174d7135 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 19202
diff changeset
   273
isQuery
7ac1174d7135 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 19202
diff changeset
   274
    ^ true
7ac1174d7135 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 19202
diff changeset
   275
7ac1174d7135 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 19202
diff changeset
   276
    "Created: / 21-07-2017 / 00:43:54 / cg"
7ac1174d7135 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 19202
diff changeset
   277
! !
7ac1174d7135 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 19202
diff changeset
   278
22075
d95ce099f95f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22063
diff changeset
   279
!Query methodsFor:'testing'!
d95ce099f95f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22063
diff changeset
   280
d95ce099f95f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22063
diff changeset
   281
isQuery
d95ce099f95f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22063
diff changeset
   282
    ^ true
d95ce099f95f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22063
diff changeset
   283
d95ce099f95f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22063
diff changeset
   284
    "Created: / 22-07-2017 / 11:08:10 / cg"
d95ce099f95f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22063
diff changeset
   285
! !
d95ce099f95f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22063
diff changeset
   286
6433
fd6c95ecb2b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6432
diff changeset
   287
!Query class methodsFor:'documentation'!
fd6c95ecb2b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6432
diff changeset
   288
fd6c95ecb2b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6432
diff changeset
   289
version
19202
f310f0e159f9 comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 12088
diff changeset
   290
    ^ '$Header$'
12088
1300308ff1c4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11201
diff changeset
   291
!
1300308ff1c4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11201
diff changeset
   292
1300308ff1c4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11201
diff changeset
   293
version_CVS
19202
f310f0e159f9 comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 12088
diff changeset
   294
    ^ '$Header$'
6433
fd6c95ecb2b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6432
diff changeset
   295
! !
8681
38aa963476a5 Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents: 6433
diff changeset
   296
19202
f310f0e159f9 comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 12088
diff changeset
   297
6432
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
Query initialize!