~ubuntu-branches/ubuntu/trusty/erlang/trusty

« back to all changes in this revision

Viewing changes to erts/doc/src/match_spec.xml

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2011-05-05 15:48:43 UTC
  • mfrom: (3.5.13 sid)
  • Revision ID: james.westby@ubuntu.com-20110505154843-0om6ekzg6m7ugj27
Tags: 1:14.b.2-dfsg-3ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Drop libwxgtk2.8-dev build dependency. Wx isn't in main, and not
    supposed to.
  - Drop erlang-wx binary.
  - Drop erlang-wx dependency from -megaco, -common-test, and -reltool, they
    do not really need wx. Also drop it from -debugger; the GUI needs wx,
    but it apparently has CLI bits as well, and is also needed by -megaco,
    so let's keep the package for now.
  - debian/patches/series: Do what I meant, and enable build-options.patch
    instead.
* Additional changes:
  - Drop erlang-wx from -et
* Dropped Changes:
  - patches/pcre-crash.patch: CVE-2008-2371: outer level option with
    alternatives caused crash. (Applied Upstream)
  - fix for ssl certificate verification in newSSL: 
    ssl_cacertfile_fix.patch (Applied Upstream)
  - debian/patches/series: Enable native.patch again, to get stripped beam
    files and reduce the package size again. (build-options is what
    actually accomplished this)
  - Remove build-options.patch on advice from upstream and because it caused
    odd build failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
<chapter>
5
5
  <header>
6
6
    <copyright>
7
 
      <year>1999</year><year>2009</year>
 
7
      <year>1999</year><year>2010</year>
8
8
      <holder>Ericsson AB. All Rights Reserved.</holder>
9
9
    </copyright>
10
10
    <legalnotice>
13
13
      compliance with the License. You should have received a copy of the
14
14
      Erlang Public License along with this software. If not, it can be
15
15
      retrieved online at http://www.erlang.org/.
16
 
    
 
16
 
17
17
      Software distributed under the License is distributed on an "AS IS"
18
18
      basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
19
19
      the License for the specific language governing rights and limitations
20
20
      under the License.
21
 
    
 
21
 
22
22
    </legalnotice>
23
23
 
24
24
    <title>Match specifications in Erlang</title>
60
60
 
61
61
  <section>
62
62
    <title>Grammar</title>
63
 
    <p>A match_spec can be described in this <em>informal</em> grammar:</p>
 
63
    <p>A match_spec used in tracing can be described in this <em>informal</em> grammar:</p>
64
64
    <list type="bulleted">
65
65
      <item>MatchExpression ::= [ MatchFunction, ... ]
66
66
      </item>
117
117
      <c><![CDATA[display]]></c> | <c><![CDATA[caller]]></c> | <c><![CDATA[set_tcw]]></c> |
118
118
      <c><![CDATA[silent]]></c></item>
119
119
    </list>
 
120
 
 
121
    <p>A match_spec used in ets can be described in this <em>informal</em> grammar:</p>
 
122
    <list type="bulleted">
 
123
      <item>MatchExpression ::= [ MatchFunction, ... ]
 
124
      </item>
 
125
      <item>MatchFunction ::= { MatchHead, MatchConditions, MatchBody }
 
126
      </item>
 
127
      <item>MatchHead ::=  MatchVariable | <c><![CDATA['_']]></c> | { MatchHeadPart, ... }
 
128
      </item>
 
129
      <item>MatchHeadPart ::= term() | MatchVariable | <c><![CDATA['_']]></c></item>
 
130
      <item>MatchVariable ::= '$&lt;number&gt;'
 
131
      </item>
 
132
      <item>MatchConditions ::= [ MatchCondition, ...] | <c><![CDATA[[]]]></c></item>
 
133
      <item>MatchCondition ::= { GuardFunction } |
 
134
       { GuardFunction, ConditionExpression, ... }
 
135
      </item>
 
136
      <item>BoolFunction ::= <c><![CDATA[is_atom]]></c> | <c><![CDATA[is_constant]]></c> |
 
137
      <c><![CDATA[is_float]]></c> | <c><![CDATA[is_integer]]></c> | <c><![CDATA[is_list]]></c> |
 
138
      <c><![CDATA[is_number]]></c> | <c><![CDATA[is_pid]]></c> | <c><![CDATA[is_port]]></c> |
 
139
      <c><![CDATA[is_reference]]></c> | <c><![CDATA[is_tuple]]></c> | <c><![CDATA[is_binary]]></c> |
 
140
      <c><![CDATA[is_function]]></c> | <c><![CDATA[is_record]]></c> | <c><![CDATA[is_seq_trace]]></c> |
 
141
      <c><![CDATA['and']]></c> | <c><![CDATA['or']]></c> | <c><![CDATA['not']]></c> | <c><![CDATA['xor']]></c> |
 
142
      <c><![CDATA[andalso]]></c> | <c><![CDATA[orelse]]></c></item>
 
143
      <item>ConditionExpression ::= ExprMatchVariable | { GuardFunction } |
 
144
       { GuardFunction, ConditionExpression, ... } | TermConstruct
 
145
      </item>
 
146
      <item>ExprMatchVariable ::= MatchVariable (bound in the MatchHead) |
 
147
      <c><![CDATA['$_']]></c> | <c><![CDATA['$$']]></c></item>
 
148
      <item>TermConstruct = {{}} | {{ ConditionExpression, ... }} |
 
149
      <c><![CDATA[[]]]></c> | [ConditionExpression, ...] | NonCompositeTerm | Constant
 
150
      </item>
 
151
      <item>NonCompositeTerm ::= term() (not list or tuple)
 
152
      </item>
 
153
      <item>Constant ::= {<c><![CDATA[const]]></c>, term()}
 
154
      </item>
 
155
      <item>GuardFunction ::= BoolFunction | <c><![CDATA[abs]]></c> |
 
156
      <c><![CDATA[element]]></c> | <c><![CDATA[hd]]></c> | <c><![CDATA[length]]></c> | <c><![CDATA[node]]></c> |
 
157
      <c><![CDATA[round]]></c> | <c><![CDATA[size]]></c> | <c><![CDATA[tl]]></c> | <c><![CDATA[trunc]]></c> |
 
158
      <c><![CDATA['+']]></c> | <c><![CDATA['-']]></c> | <c><![CDATA['*']]></c> | <c><![CDATA['div']]></c> |
 
159
      <c><![CDATA['rem']]></c> | <c><![CDATA['band']]></c> | <c><![CDATA['bor']]></c> | <c><![CDATA['bxor']]></c> |
 
160
      <c><![CDATA['bnot']]></c> | <c><![CDATA['bsl']]></c> | <c><![CDATA['bsr']]></c> | <c><![CDATA['>']]></c> |
 
161
      <c><![CDATA['>=']]></c> | <c><![CDATA['<']]></c> | <c><![CDATA['=<']]></c> | <c><![CDATA['=:=']]></c> |
 
162
      <c><![CDATA['==']]></c> | <c><![CDATA['=/=']]></c> | <c><![CDATA['/=']]></c> | <c><![CDATA[self]]></c> |
 
163
      <c><![CDATA[get_tcw]]></c></item>
 
164
      <item>MatchBody ::= [ ConditionExpression, ... ]</item>
 
165
    </list>
120
166
  </section>
121
167
 
122
168
  <section>
360
406
      </p>
361
407
    <table>
362
408
      <row>
363
 
        <cell align="left" valign="middle">Expression\011\011</cell>
364
 
        <cell align="left" valign="middle">Variable bindings\011\011</cell>
365
 
        <cell align="left" valign="middle">Result\011</cell>
 
409
        <cell align="left" valign="middle">Expression           </cell>
 
410
        <cell align="left" valign="middle">Variable bindings            </cell>
 
411
        <cell align="left" valign="middle">Result       </cell>
366
412
      </row>
367
413
      <row>
368
 
        <cell align="left" valign="middle">{{'$1','$2'}}\011\011</cell>
 
414
        <cell align="left" valign="middle">{{'$1','$2'}}                </cell>
369
415
        <cell align="left" valign="middle">'$1' = a, '$2' = b</cell>
370
416
        <cell align="left" valign="middle">{a,b}</cell>
371
417
      </row>
372
418
      <row>
373
 
        <cell align="left" valign="middle">{const, {'$1', '$2'}}\011</cell>
 
419
        <cell align="left" valign="middle">{const, {'$1', '$2'}}        </cell>
374
420
        <cell align="left" valign="middle">doesn't matter</cell>
375
421
        <cell align="left" valign="middle">{'$1', '$2'}</cell>
376
422
      </row>
377
423
      <row>
378
 
        <cell align="left" valign="middle">a\011\011\011</cell>
379
 
        <cell align="left" valign="middle">doesn't matter\011\011\011</cell>
 
424
        <cell align="left" valign="middle">a                    </cell>
 
425
        <cell align="left" valign="middle">doesn't matter                       </cell>
380
426
        <cell align="left" valign="middle">a</cell>
381
427
      </row>
382
428
      <row>
383
 
        <cell align="left" valign="middle">'$1'\011\011\011</cell>
384
 
        <cell align="left" valign="middle">'$1' = []\011\011\011</cell>
 
429
        <cell align="left" valign="middle">'$1'                 </cell>
 
430
        <cell align="left" valign="middle">'$1' = []                    </cell>
385
431
        <cell align="left" valign="middle">[]</cell>
386
432
      </row>
387
433
      <row>
388
 
        <cell align="left" valign="middle">['$1']\011\011\011</cell>
389
 
        <cell align="left" valign="middle">'$1' = []\011\011\011</cell>
 
434
        <cell align="left" valign="middle">['$1']                       </cell>
 
435
        <cell align="left" valign="middle">'$1' = []                    </cell>
390
436
        <cell align="left" valign="middle">[[]]</cell>
391
437
      </row>
392
438
      <row>
393
 
        <cell align="left" valign="middle">[{{a}}]\011\011\011</cell>
 
439
        <cell align="left" valign="middle">[{{a}}]                      </cell>
394
440
        <cell align="left" valign="middle">doesn't matter</cell>
395
441
        <cell align="left" valign="middle">[{a}]</cell>
396
442
      </row>
397
443
      <row>
398
 
        <cell align="left" valign="middle">42\011\011\011</cell>
 
444
        <cell align="left" valign="middle">42                   </cell>
399
445
        <cell align="left" valign="middle">doesn't matter</cell>
400
446
        <cell align="left" valign="middle">42</cell>
401
447
      </row>
402
448
      <row>
403
 
        <cell align="left" valign="middle">"hello"\011\011\011</cell>
 
449
        <cell align="left" valign="middle">"hello"                      </cell>
404
450
        <cell align="left" valign="middle">doesn't matter</cell>
405
451
        <cell align="left" valign="middle">"hello"</cell>
406
452
      </row>
407
453
      <row>
408
 
        <cell align="left" valign="middle">$1\011\011\011</cell>
 
454
        <cell align="left" valign="middle">$1                   </cell>
409
455
        <cell align="left" valign="middle">doesn't matter</cell>
410
456
        <cell align="left" valign="middle">49 (the ASCII value for the character '1')</cell>
411
457
      </row>
453
499
  <section>
454
500
    <title>Differences between match specifications in ETS and tracing</title>
455
501
    <p>ETS match specifications are there to produce a return
456
 
      value. Usually the expression contains one single
457
 
      <c><![CDATA[ActionTerm]]></c> which defines the return value without having
 
502
      value. Usually the <c><![CDATA[MatchBody]]></c> contains one single
 
503
      <c><![CDATA[ConditionExpression]]></c> which defines the return value without having
458
504
      any side effects. Calls with side effects are not allowed in the
459
505
      ETS context.</p>
460
506
    <p>When tracing there is no return value to produce, the
507
553
      a list which in turn begins with the second argument times
508
554
      two (i. e. [{[4,x],y},2] or [{[8], y, z},4])</p>
509
555
    <code type="none"><![CDATA[
510
 
[{['$1', '$2'],\011[{'=:=', {'*', 2, '$2'}, {hd, {element, 1, '$1'}}}],
511
 
  []}]\011
 
556
[{['$1', '$2'],[{'=:=', {'*', 2, '$2'}, {hd, {element, 1, '$1'}}}],
 
557
  []}]
512
558
    ]]></code>
513
559
    <p>Match three arguments. When all three are equal and are
514
560
      numbers, append the process dump to the trace message, else
530
576
      the atom 'strider' and the tuple arity is 3 and return the whole
531
577
      object.</p>
532
578
    <code type="none"><![CDATA[
533
 
[{{strider,'_'.'_'},
 
579
[{{strider,'_','_'},
534
580
  [],
535
581
  ['$_']}]
536
582
    ]]></code>