Skip to content

Commit c8c9edc

Browse files
authored
Merge pull request #270 from sshanks-kx/qtrpd
.Q.trp uses 'trap at' rather than 'trap'
2 parents bb33a71 + f411778 commit c8c9edc

File tree

3 files changed

+76
-34
lines changed

3 files changed

+76
-34
lines changed

docs/basics/debug.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ q)) extra right parens mark suspended execution/s
1414
\\ abort execution and exit debugger
1515
[.Q.bt](../ref/dotq.md#bt-backtrace) dump backtrace
1616
[&](#where) current frame information
17-
[.Q.trp](../ref/dotq.md#trp-extend-trap) extends [Trap](../ref/apply.md#trap) to collect backtrace
17+
[.Q.trp](../ref/dotq.md#trp-extend-trap-at) extends [Trap At](../ref/apply.md#trap-at) to collect backtrace
1818
[-e](cmdline.md#-e-error-traps) [\e](syscmds.md#e-error-trap-clients) error-trap mode
1919
</div>
2020

@@ -247,7 +247,7 @@ View calculations and system commands, including [`\l`](syscmds.md#l-load), corr
247247

248248
### Trap
249249

250-
[`.Q.trp[f;x;g]`](../ref/dotq.md#trp-extend-trap) extends trap (`@[f;x;g]`) to collect backtrace. Along with the error string, `g` gets called with the backtrace object as a second argument. You can format it with `.Q.sbt` to make it legible.
250+
[`.Q.trp[f;x;g]`](../ref/dotq.md#trp-extend-trap-at) extends `trap at` (`@[f;x;g]`) to collect backtrace. Along with the error string, `g` gets called with the backtrace object as a second argument. You can format it with `.Q.sbt` to make it legible.
251251

252252
```q
253253
q)f:{`hello+x}

docs/ref/dotq.md

Lines changed: 72 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,32 @@ _Tools_
3030
[s1 string representation](#s1-string-representation) [ld load and group](#ld-load-and-group)
3131
[sbt string backtrace](#sbt-string-backtrace) [lo load without](#lo-load-without)
3232
[sha1 SHA-1 encode](#sha1-sha-1-encode) [M chunk size](#m-chunk-size)
33-
[trp extend trap](#trp-extend-trap) [qp is partitioned](#qp-is-partitioned)
34-
[ts time and space](#ts-time-and-space) [qt is table](#qt-is-table)
35-
[u date based](#u-date-based)
36-
[V table to dict](#v-table-to-dict)
37-
[v value](#v-value) **Partitioned database state**
38-
[view subview](#view-subview) [bv build vp](#bv-build-vp)
39-
[cn count partitioned table](#cn-count-partitioned-table)
40-
**Constants** [D partitions](#d-partitions)
41-
[A a an alphabets](#a-upper-case-alphabet) [ind partitioned index](#ind-partitioned-index)
42-
[b6 bicameral alphanums](#b6-bicameral-alphanums) [MAP maps partitions](#map-maps-partitions)
43-
[n nA nums & alphanums](#n-nums) [par locate partition](#par-locate-partition)
44-
[PD partition locations](#pd-partition-locations)
45-
**Environment** [pd modified partition locns](#pd-modified-partition-locations)
46-
[K k version](#k-version-date) [pf partition field](#pf-partition-field)
47-
[opt command parameters](#opt-command-parameters) [pn partition counts](#pn-partition-counts)
48-
[w memory stats](#w-memory-stats) [pt partitioned tables](#pt-partitioned-tables)
49-
[x non-command parameters](#x-non-command-parameters) [PV partition values](#pv-partition-values)
50-
[pv modified partition values](#pv-modified-partition-values)
51-
**IPC** [qp is partitioned](#qp-is-partitioned)
52-
[addr IP address](#addr-ip-address) [vp missing partitions](#vp-missing-partitions)
53-
[fps fpn streaming algorithm](#fpn-streaming-algorithm)
54-
[fs fsn streaming algorithm](#fs-streaming-algorithm) **Segmented database state**
55-
[hg HTTP get](#hg-http-get) [P segments](#p-segments)
56-
[host hostname](#host-hostname) [u date based](#u-date-based)
57-
[hp HTTP post](#hp-http-post)
58-
**File I/O**
59-
[Cf create empty nested char file](#cf-create-empty-nested-char-file)
33+
[trp extend trap at](#trp-extend-trap-at) [qp is partitioned](#qp-is-partitioned)
34+
[trpd extend trap](#trpd-extend-trap) [qt is table](#qt-is-table)
35+
[ts time and space](#ts-time-and-space)
36+
[u date based](#u-date-based) **Partitioned database state**
37+
[V table to dict](#v-table-to-dict) [bv build vp](#bv-build-vp)
38+
[v value](#v-value) [cn count partitioned table](#cn-count-partitioned-table)
39+
[view subview](#view-subview) [D partitions](#d-partitions)
40+
[ind partitioned index](#ind-partitioned-index)
41+
**Constants** [MAP maps partitions](#map-maps-partitions)
42+
[A a an alphabets](#a-upper-case-alphabet) [par locate partition](#par-locate-partition)
43+
[b6 bicameral alphanums](#b6-bicameral-alphanums) [PD partition locations](#pd-partition-locations)
44+
[n nA nums & alphanums](#n-nums) [pd modified partition locns](#pd-modified-partition-locations)
45+
[pf partition field](#pf-partition-field)
46+
**Environment** [pn partition counts](#pn-partition-counts)
47+
[K k version](#k-version-date) [pt partitioned tables](#pt-partitioned-tables)
48+
[opt command parameters](#opt-command-parameters) [PV partition values](#pv-partition-values)
49+
[w memory stats](#w-memory-stats) [pv modified partition values](#pv-modified-partition-values)
50+
[x non-command parameters](#x-non-command-parameters) [qp is partitioned](#qp-is-partitioned)
51+
[vp missing partitions](#vp-missing-partitions)
52+
**IPC**
53+
[addr IP address](#addr-ip-address) **Segmented database state**
54+
[fps fpn streaming algorithm](#fpn-streaming-algorithm) [P segments](#p-segments)
55+
[fs fsn streaming algorithm](#fs-streaming-algorithm) [u date based](#u-date-based)
56+
[hg HTTP get](#hg-http-get)
57+
[host hostname](#host-hostname) **File I/O**
58+
[hp HTTP post](#hp-http-post) [Cf create empty nested char file](#cf-create-empty-nested-char-file)
6059
[Xf create file](#xf-create-file)
6160

6261
</div>
@@ -1692,7 +1691,7 @@ Returns a string representation of `x`.
16921691
.Q.sbt x
16931692
```
16941693

1695-
Where `x` is a [backtrace object](#trp-extend-trap) returns it as a string formatted for display.
1694+
Where `x` is a [backtrace object](#trp-extend-trap-at) returns it as a string formatted for display.
16961695

16971696
Since V3.5 2017.03.15.
16981697

@@ -1733,7 +1732,7 @@ q).Q.t?"j" / longs have datatype 7
17331732

17341733

17351734

1736-
## `trp` (extend trap)
1735+
## `trp` (extend trap at)
17371736

17381737
```syntax
17391738
.Q.trp[f;x;g]
@@ -1745,7 +1744,7 @@ Where
17451744
- `x` is its argument
17461745
- `g` is a binary function
17471746

1748-
extends [Trap](apply.md#trap) (`@[f;x;g]`) to collect backtrace: `g` gets called with arguments:
1747+
extends [Trap At](apply.md#trap-at) (`@[f;x;g]`) to collect backtrace: `g` gets called with arguments:
17491748

17501749
1. the error string
17511750
2. the backtrace object
@@ -1803,6 +1802,49 @@ Since V3.5 2017.03.15.
18031802
[Debugging](../basics/debug.md)
18041803

18051804

1805+
## `trpd` (extend trap)
1806+
1807+
```syntax
1808+
.Q.trpd[f;x;g]
1809+
```
1810+
1811+
Where
1812+
1813+
- `f` is a function of rank
1814+
- `x` is an atom or list of count with items in the domains of f
1815+
1816+
- `g` is a binary function
1817+
1818+
extends [Trap](apply.md#trap) (`.[f;x;g]`) to collect backtrace: `g` is called with arguments:
1819+
1820+
1. the error string
1821+
2. the backtrace object
1822+
1823+
You can format the backtrace object with `.Q.sbt`.
1824+
1825+
```q
1826+
q).Q.trpd[{x+y};(1;2);{2"error: ",x,"\nbacktrace:\n",.Q.sbt y;-1}]
1827+
3
1828+
q).Q.trpd[{x+y};(1;`2);{2"error: ",x,"\nbacktrace:\n",.Q.sbt y;-1}]
1829+
error: type
1830+
backtrace:
1831+
[2] {x+y}
1832+
^
1833+
[1] (.Q.trpd)
1834+
1835+
[0] .Q.trpd[{x+y};(1;`2);{2"error: ",x,"\nbacktrace:\n",.Q.sbt y;-1}]
1836+
^
1837+
-1
1838+
```
1839+
1840+
Use .Q.trp as a simpler form of .Q.trpd, for unary values.
1841+
1842+
Since 4.1 2024.03.12.
1843+
1844+
:fontawesome-solid-book-open:
1845+
[Debugging](../basics/debug.md)
1846+
1847+
18061848
## `ts` (time and space)
18071849

18081850
_Apply, with time and space_

docs/ref/signal.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ At any point during execution, the behavior of _signal_ (`'`) is determined by t
6969
<div markdown="1" class="typewriter">
7070
0 abort execution (set by [Trap or Trap At](apply.md#trap))
7171
1 suspend execution and run the debugger
72-
2 collect stack trace and abort (set by [.Q.trp](dotq.md#trp-extend-trap))
72+
2 collect stack trace and abort (set by [.Q.trp](dotq.md#trp-extend-trap-at))
7373
</div>
7474

75-
During abort, the stack is unwound up to the nearest [trap](apply.md#trap) (`@` or `.` or [`.Q.trp`](dotq.md#trp-extend-trap)). The error-trap mode is always initially set to
75+
During abort, the stack is unwound as far as the nearest [trap at](apply.md#trap-at) (`@` or `.` or [`.Q.trp`](dotq.md#trp-extend-trap-at)). The error-trap mode is always initially set to
7676

7777
```txt
7878
1 for console input

0 commit comments

Comments
 (0)