Query.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sat, 24 Oct 2009 16:48:19 +0100
branchjv
changeset 17732 a1892eeca6c0
parent 17711 39faaaf888b4
child 17734 406b1590afe8
permissions -rw-r--r--
trunk merged into jv branch
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
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
Notification subclass:#Query
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
	instanceVariableNames:''
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	classVariableNames:''
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	category:'Kernel-Exceptions'
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!Query class methodsFor:'documentation'!
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
copyright
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 (c) 2002 by eXept Software AG
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
              All Rights Reserved
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
 This software is furnished under a license and may be used
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 only in accordance with the terms of that license and with the
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 be provided or otherwise made available to, or used by, any
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 other person.  No title to or ownership of the software is
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 hereby transferred.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
"
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
!
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
documentation
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
    Query is an abstract superclass for queries.
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
    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
    42
    a default value.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    As a class based reimplementation, it replaces and obsoletes the old 
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    QuerySignal instance based mechanism.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
    Note:
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
        Query does not add/refine any functionality from its superclass.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
        It exists for the more descriptive class name only.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
11201
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    50
    Queries are like exceptions, except that they are not accepted
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    51
    by handlers for ordinary exceptions.
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    52
    I.e. a handler for a normal exception will not handle a query. 
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    53
    Thus, these bypass all normal exception handlers.
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    54
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    55
    However, if unhandled, no error is raised, instead it is simply ignored
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    56
    and nil is returned from the raise
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    57
    (as opposed to normal exceptions, which raise an unhandled exception error).
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    58
    Queries are also ignored, if a handler exists, but rejects.
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    59
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    60
    The main use of Queries is to implement an upQuery, which works even 
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    61
    if intermediate errorSignal handlers are present. 
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    62
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    63
    Code deep down in the calling hierarchy can post such an up-Query to ask
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    64
    for some information or to pass some information upward. 
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    65
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    66
    For example, the activityNotification mechanism is built on top of this:
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    67
    everyone can send such a notification which is either handled by someone
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    68
    up in the hierarchy (to show it in the windows info area) or simply
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    69
    ignored.
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    70
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    71
    Using Queries for this (instead of regular Signals) helps in documenting
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    72
    the intended usage of those signals.
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    73
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    74
    Another use of queries is to provide additional information to
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    75
    deeply nested methods, which is only required in the uncommon case;
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    76
    or if another parameter is required by some method, which was not planned
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    77
    for in the beginning, and you do not want to hand this value (via an
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    78
    additional argument) through all intermediate levels.
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    79
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    80
    A highly elegant solution to this problem is to provide a handler somewhere
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    81
    at the top of the calling hierarchy, and raise an upQuery from whereever
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    82
    that value is required.
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    83
    A concrete application can be found in the windowGroup-lastEvent
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    84
    queries. If anyone is interested in the windowEvent which was responible for 
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    85
    being invoked, all he needs to do is to raise the lastEventQuerySignal, 
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    86
    which returns that event.
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    87
    No intermediate methods are required to know anything about that.
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    88
    Another example is found in the way Metaclass asks for the nameSpace
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    89
    when new classes are to be installed. A Browser may simply answer such
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    90
    a query and provide a namespace (no need to pass that information down
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    91
    the calling chain).
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    92
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    93
    A final note (to C++ and Java fans):
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    94
        such upQueries are only possible, if the exception handling mechanism
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    95
        does not automatically unwind the stack for the handler invokation.
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    96
        Since the handler must be able to proceed the execution and return
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    97
        a value to the raiser ....
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    98
        ... another demonstration of why ST's exception mechanisms are superior.
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
    99
6432
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    [author:]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
        Claus Gittinger
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
    [see also:]
11201
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
   104
        Notification Warning Signal QuerySignal
Claus Gittinger <cg@exept.de>
parents: 8681
diff changeset
   105
        (``Exception handling and signals'': programming/exceptions.html)
6432
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
"
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
!
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
examples
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
"
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
                                                                        [exBegin]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    Query answer:'hello'
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    do:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
        Transcript showCR:(Query query)
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
    ]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
                                                                        [exEnd]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
  an up-query from a deeply nested operation to a higher level:
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
  the example below demonstrates that a Query is not an Error
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
  (i.e. the Error-handler does not interfere with Queries)
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
                                                                        [exBegin]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
    |zero|
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
    zero := 0.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
    Query handle:[:ex |
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
        Transcript showCR:'query'.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
        ex proceedWith:true
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
    ] do:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
        'nesting'.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
        [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
            [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
                Error handle:[:ex |
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
                    Transcript showCR:'some error: ' , ex errorString.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
                    ex proceed
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
                ] do:[
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
                        1 // zero.  'an error which is caught in the handler'.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
                        (Query query) == true ifTrue:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
                            Transcript showCR:'query says: ok'.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
                        ] ifFalse:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
                            Transcript showCR:'query says: no'
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
                    ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
                ]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
            ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
        ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
    ]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
                                                                        [exEnd]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
  for lazy typists, a more compact interface for query-answerign
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
  is also provided (which is also easier to read):
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
                                                                        [exBegin]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
    Query answer:true do:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
        'nesting'.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
        [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
            [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
                (Query query) == true ifTrue:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
                    Transcript showCR:'query says: ok'.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
                ] ifFalse:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
                    Transcript showCR:'query says: no'
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
            ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
        ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
    ]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
                                                                        [exEnd]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
  an up-query from a deeply nested operation, for which there
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
  is no handler:
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
  (notice, this would not work with normal signals, which would raise
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
   another unhandled exception-exception;
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
   also notice the == check #raise's return value being true,
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
   instead of a simple ifTrue; this handles a nil-value from
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
   the unhandled query)
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
                                                                        [exBegin]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
    |zero|
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
    zero := 0.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
    [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
        'nesting'.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
        [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
            [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
                Error handle:[:ex |
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
                    Transcript showCR:'some error: ' , ex errorString.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
                    ex proceed
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
                ] do:[
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
                        1 // zero.  'an error which is caught in the handler'.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
                        (Query raise) == true ifTrue:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
                            Transcript showCR:'query says: ok'.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
                        ] ifFalse:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
                            Transcript showCR:'query says: no'
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
                    ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
                ]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
            ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
        ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
    ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
                                                                         [exEnd]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
  counter-example, just to show that things would not work this way
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
  with regular signals:
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
                                                                        [exBegin]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
    |signal|
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
    signal := Signal new.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
    'nesting deeply'.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
    [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
        [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
            [
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
                    [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
                        (signal raise) == true ifTrue:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
                            Transcript showCR:'query says: ok'.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
                        ] ifFalse:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
                            Transcript showCR:'query says: no'
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
                    ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
                ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
            ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
        ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
    ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
                                                                         [exEnd]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
   except, by handling the unhandled exception
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
   (but we think, that querySignals are easier to use and
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
    better document the intent):
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
                                                                        [exBegin]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
    |signal|
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
    signal := Signal new.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
    'nesting deeply'.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
    [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
        [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
            [
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
                    [
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
                        Signal noHandlerSignal handle:[:ex |
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
                            ex proceedWith:nil
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
                        ] do:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
                            (signal raise) == true ifTrue:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
                                Transcript showCR:'query says: ok'.
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
                            ] ifFalse:[
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
                                Transcript showCR:'query says: no'
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
                            ]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
                        ]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
                    ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
                ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
            ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
        ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
    ] value
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
                                                                         [exEnd]
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
"
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
! !
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
!Query class methodsFor:'initialization'!
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
initialize
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
    NotifierString := 'Query'.
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
    "
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
     self initialize
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
    "
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
17732
a1892eeca6c0 trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   264
!Query class methodsFor:'misc ui support'!
a1892eeca6c0 trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   265
a1892eeca6c0 trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   266
iconInBrowserSymbol
a1892eeca6c0 trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   267
    <resource: #programImage>
a1892eeca6c0 trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   268
a1892eeca6c0 trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   269
    ^ #queryClassBrowserIcon
a1892eeca6c0 trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   270
! !
a1892eeca6c0 trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   271
6433
fd6c95ecb2b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6432
diff changeset
   272
!Query class methodsFor:'documentation'!
fd6c95ecb2b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6432
diff changeset
   273
fd6c95ecb2b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6432
diff changeset
   274
version
17732
a1892eeca6c0 trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   275
    ^ '$Id: Query.st 10473 2009-10-24 15:48:19Z vranyj1 $'
a1892eeca6c0 trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   276
!
a1892eeca6c0 trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   277
a1892eeca6c0 trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   278
version_CVS
a1892eeca6c0 trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   279
    ^ '§Header: /cvs/stx/stx/libbasic/Query.st,v 1.13 2009/10/01 13:44:05 cg Exp §'
6433
fd6c95ecb2b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6432
diff changeset
   280
! !
8681
38aa963476a5 Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents: 6433
diff changeset
   281
6432
5a3c5155237e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
Query initialize!
17732
a1892eeca6c0 trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   283