SCM

SCM Repository

[ihelp] Annotation of /src/manual/R-ints-ko.po
ViewVC logotype

Annotation of /src/manual/R-ints-ko.po

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1339 - (view) (download)

1 : gnustats 1339 # Korean translations for R-manual-translation-ko package
2 :     # Copyright (C) 2014 Chel Hee Lee
3 :     # This file is distributed under the same license as the R-manual-translation-ko package.
4 :     # Automatically generated, 2014.
5 :     #
6 :     msgid ""
7 :     msgstr ""
8 :     "Project-Id-Version: R-manual-translation-ko 0.3.0.1\n"
9 :     "Report-Msgid-Bugs-To: chl948@mail.usask.ca\n"
10 :     "POT-Creation-Date: 2014-12-23 00:16-0600\n"
11 :     "PO-Revision-Date: 2014-12-23 00:16-0600\n"
12 :     "Last-Translator: Chel Hee Lee <chl948@mail.usask.ca>\n"
13 :     "Language-Team: Chel Hee Lee <chl948@mail.usask.ca>\n"
14 :     "Language: ko\n"
15 :     "MIME-Version: 1.0\n"
16 :     "Content-Type: text/plain; charset=UTF-8\n"
17 :     "Content-Transfer-Encoding: 8bit\n"
18 :     "Plural-Forms: nplurals=1; plural=0;\n"
19 :    
20 :     #. type: top
21 :     #: R-ints.texi:4
22 :     #: R-ints.texi:33
23 :     #: R-ints.texi:51
24 :     #, no-wrap
25 :     msgid "R Internals"
26 :     msgstr ""
27 :    
28 :     #. type: dircategory
29 :     #: R-ints.texi:12
30 :     #, no-wrap
31 :     msgid "Programming"
32 :     msgstr ""
33 :    
34 :     #. type: menuentry
35 :     #: R-ints.texi:15
36 :     msgid "R Internals: (R-ints)"
37 :     msgstr ""
38 :    
39 :     #. type: menuentry
40 :     #: R-ints.texi:15
41 :     msgid "R Internals."
42 :     msgstr ""
43 :    
44 :     #. type: include
45 :     #: R-ints.texi:19
46 :     #, no-wrap
47 :     msgid "R-defs.texi"
48 :     msgstr ""
49 :    
50 :     #. type: include
51 :     #: R-ints.texi:20
52 :     #, no-wrap
53 :     msgid "version.texi"
54 :     msgstr ""
55 :    
56 :     #. type: copying
57 :     #: R-ints.texi:24
58 :     msgid "This manual is for R, version @value{VERSION}."
59 :     msgstr ""
60 :    
61 :     #. type: copying
62 :     #: R-ints.texi:26
63 :     msgid "@Rcopyright{1999}"
64 :     msgstr ""
65 :    
66 :     #. type: quotation
67 :     #: R-ints.texi:29
68 :     msgid "@permission{}"
69 :     msgstr ""
70 :    
71 :     #. type: subtitle
72 :     #: R-ints.texi:34
73 :     #, no-wrap
74 :     msgid "Version @value{VERSION}"
75 :     msgstr ""
76 :    
77 :     #. type: author
78 :     #: R-ints.texi:35
79 :     #, no-wrap
80 :     msgid "R Core Team"
81 :     msgstr ""
82 :    
83 :     #. type: node
84 :     #: R-ints.texi:50
85 :     #: R-ints.texi:78
86 :     #: R-ints.texi:1947
87 :     #: R-ints.texi:2333
88 :     #: R-ints.texi:2461
89 :     #: R-ints.texi:2612
90 :     #: R-ints.texi:2698
91 :     #: R-ints.texi:3585
92 :     #: R-ints.texi:3747
93 :     #: R-ints.texi:4119
94 :     #: R-ints.texi:4252
95 :     #: R-ints.texi:4266
96 :     #: R-ints.texi:4310
97 :     #: R-ints.texi:4477
98 :     #: R-ints.texi:4482
99 :     #, no-wrap
100 :     msgid "Top"
101 :     msgstr ""
102 :    
103 :     #. type: node
104 :     #: R-ints.texi:50
105 :     #: R-ints.texi:75
106 :     #: R-ints.texi:78
107 :     #: R-ints.texi:79
108 :     #: R-ints.texi:110
109 :     #: R-ints.texi:528
110 :     #: R-ints.texi:667
111 :     #: R-ints.texi:772
112 :     #: R-ints.texi:865
113 :     #: R-ints.texi:1021
114 :     #: R-ints.texi:1076
115 :     #: R-ints.texi:1121
116 :     #: R-ints.texi:1229
117 :     #: R-ints.texi:1307
118 :     #: R-ints.texi:1326
119 :     #: R-ints.texi:1376
120 :     #: R-ints.texi:1547
121 :     #: R-ints.texi:1701
122 :     #: R-ints.texi:1758
123 :     #: R-ints.texi:1796
124 :     #: R-ints.texi:1883
125 :     #: R-ints.texi:1947
126 :     #, no-wrap
127 :     msgid "R Internal Structures"
128 :     msgstr ""
129 :    
130 :     #. type: node
131 :     #: R-ints.texi:50
132 :     #, no-wrap
133 :     msgid "(dir)"
134 :     msgstr ""
135 :    
136 :     #. type: ifnottex
137 :     #: R-ints.texi:55
138 :     msgid "This is a guide to the internal structures of @R{} and coding standards for the core team working on @R{} itself."
139 :     msgstr ""
140 :    
141 :     #. type: node
142 :     #: R-ints.texi:75
143 :     #: R-ints.texi:78
144 :     #: R-ints.texi:1947
145 :     #: R-ints.texi:2207
146 :     #: R-ints.texi:2233
147 :     #: R-ints.texi:2241
148 :     #: R-ints.texi:2300
149 :     #: R-ints.texi:2333
150 :     #, no-wrap
151 :     msgid ".Internal vs .Primitive"
152 :     msgstr ""
153 :    
154 :     #. type: node
155 :     #: R-ints.texi:75
156 :     #: R-ints.texi:1947
157 :     #: R-ints.texi:2333
158 :     #: R-ints.texi:2334
159 :     #: R-ints.texi:2356
160 :     #: R-ints.texi:2373
161 :     #: R-ints.texi:2419
162 :     #: R-ints.texi:2449
163 :     #: R-ints.texi:2456
164 :     #: R-ints.texi:2461
165 :     #, no-wrap
166 :     msgid "Internationalization in the R sources"
167 :     msgstr ""
168 :    
169 :     #. type: node
170 :     #: R-ints.texi:75
171 :     #: R-ints.texi:2333
172 :     #: R-ints.texi:2461
173 :     #: R-ints.texi:2515
174 :     #: R-ints.texi:2586
175 :     #: R-ints.texi:2612
176 :     #, no-wrap
177 :     msgid "Package Structure"
178 :     msgstr ""
179 :    
180 :     #. type: node
181 :     #: R-ints.texi:75
182 :     #: R-ints.texi:2461
183 :     #: R-ints.texi:2612
184 :     #: R-ints.texi:2613
185 :     #: R-ints.texi:2698
186 :     #, no-wrap
187 :     msgid "Files"
188 :     msgstr ""
189 :    
190 :     #. type: node
191 :     #: R-ints.texi:75
192 :     #: R-ints.texi:2612
193 :     #: R-ints.texi:2698
194 :     #: R-ints.texi:2824
195 :     #: R-ints.texi:2825
196 :     #: R-ints.texi:3399
197 :     #: R-ints.texi:3488
198 :     #: R-ints.texi:3580
199 :     #: R-ints.texi:3585
200 :     #, no-wrap
201 :     msgid "Graphics Devices"
202 :     msgstr ""
203 :    
204 :     #. type: node
205 :     #: R-ints.texi:75
206 :     #: R-ints.texi:2698
207 :     #: R-ints.texi:3585
208 :     #: R-ints.texi:3586
209 :     #: R-ints.texi:3611
210 :     #: R-ints.texi:3747
211 :     #, no-wrap
212 :     msgid "GUI consoles"
213 :     msgstr ""
214 :    
215 :     #. type: node
216 :     #: R-ints.texi:75
217 :     #: R-ints.texi:3585
218 :     #: R-ints.texi:3747
219 :     #: R-ints.texi:3748
220 :     #: R-ints.texi:4119
221 :     #, no-wrap
222 :     msgid "Tools"
223 :     msgstr ""
224 :    
225 :     #. type: node
226 :     #: R-ints.texi:75
227 :     #: R-ints.texi:3747
228 :     #: R-ints.texi:4119
229 :     #: R-ints.texi:4120
230 :     #: R-ints.texi:4252
231 :     #, no-wrap
232 :     msgid "R coding standards"
233 :     msgstr ""
234 :    
235 :     #. type: node
236 :     #: R-ints.texi:75
237 :     #: R-ints.texi:4119
238 :     #: R-ints.texi:4252
239 :     #: R-ints.texi:4253
240 :     #: R-ints.texi:4266
241 :     #, no-wrap
242 :     msgid "Testing R code"
243 :     msgstr ""
244 :    
245 :     #. type: node
246 :     #: R-ints.texi:75
247 :     #: R-ints.texi:4252
248 :     #: R-ints.texi:4266
249 :     #: R-ints.texi:4267
250 :     #: R-ints.texi:4310
251 :     #, no-wrap
252 :     msgid "Use of TeX dialects"
253 :     msgstr ""
254 :    
255 :     #. type: node
256 :     #: R-ints.texi:75
257 :     #: R-ints.texi:4266
258 :     #: R-ints.texi:4310
259 :     #: R-ints.texi:4311
260 :     #: R-ints.texi:4323
261 :     #: R-ints.texi:4396
262 :     #: R-ints.texi:4448
263 :     #: R-ints.texi:4477
264 :     #, no-wrap
265 :     msgid "Current and future directions"
266 :     msgstr ""
267 :    
268 :     #. type: node
269 :     #: R-ints.texi:75
270 :     #: R-ints.texi:4310
271 :     #: R-ints.texi:4477
272 :     #: R-ints.texi:4478
273 :     #: R-ints.texi:4482
274 :     #, no-wrap
275 :     msgid "Function and variable index"
276 :     msgstr ""
277 :    
278 :     #. type: unnumbered
279 :     #: R-ints.texi:75
280 :     #: R-ints.texi:4477
281 :     #: R-ints.texi:4482
282 :     #: R-ints.texi:4483
283 :     #, no-wrap
284 :     msgid "Concept index"
285 :     msgstr ""
286 :    
287 :     #. type: Plain text
288 :     #: R-ints.texi:84
289 :     msgid "This chapter is the beginnings of documentation about @R{} internal structures. It is written for the core team and others studying the code in the @file{src/main} directory."
290 :     msgstr ""
291 :    
292 :     #. type: Plain text
293 :     #: R-ints.texi:89
294 :     msgid "It is a work-in-progress and should be checked against the current version of the source code. Versions for @R{} 2.x.y contain historical comments about when features were introduced: this version is for the 3.x.y series."
295 :     msgstr ""
296 :    
297 :     #. type: node
298 :     #: R-ints.texi:108
299 :     #: R-ints.texi:110
300 :     #: R-ints.texi:111
301 :     #: R-ints.texi:146
302 :     #: R-ints.texi:225
303 :     #: R-ints.texi:372
304 :     #: R-ints.texi:511
305 :     #: R-ints.texi:528
306 :     #, no-wrap
307 :     msgid "SEXPs"
308 :     msgstr ""
309 :    
310 :     #. type: node
311 :     #: R-ints.texi:108
312 :     #: R-ints.texi:110
313 :     #: R-ints.texi:528
314 :     #: R-ints.texi:529
315 :     #: R-ints.texi:579
316 :     #: R-ints.texi:608
317 :     #: R-ints.texi:641
318 :     #: R-ints.texi:667
319 :     #, no-wrap
320 :     msgid "Environments and variable lookup"
321 :     msgstr ""
322 :    
323 :     #. type: node
324 :     #: R-ints.texi:108
325 :     #: R-ints.texi:528
326 :     #: R-ints.texi:667
327 :     #: R-ints.texi:668
328 :     #: R-ints.texi:772
329 :     #, no-wrap
330 :     msgid "Attributes"
331 :     msgstr ""
332 :    
333 :     #. type: node
334 :     #: R-ints.texi:108
335 :     #: R-ints.texi:667
336 :     #: R-ints.texi:772
337 :     #: R-ints.texi:773
338 :     #: R-ints.texi:865
339 :     #, no-wrap
340 :     msgid "Contexts"
341 :     msgstr ""
342 :    
343 :     #. type: node
344 :     #: R-ints.texi:108
345 :     #: R-ints.texi:772
346 :     #: R-ints.texi:865
347 :     #: R-ints.texi:866
348 :     #: R-ints.texi:948
349 :     #: R-ints.texi:993
350 :     #: R-ints.texi:1021
351 :     #, no-wrap
352 :     msgid "Argument evaluation"
353 :     msgstr ""
354 :    
355 :     #. type: node
356 :     #: R-ints.texi:108
357 :     #: R-ints.texi:865
358 :     #: R-ints.texi:1021
359 :     #: R-ints.texi:1022
360 :     #: R-ints.texi:1076
361 :     #, no-wrap
362 :     msgid "Autoprinting"
363 :     msgstr ""
364 :    
365 :     #. type: node
366 :     #: R-ints.texi:108
367 :     #: R-ints.texi:1021
368 :     #: R-ints.texi:1076
369 :     #: R-ints.texi:1121
370 :     #, no-wrap
371 :     msgid "The write barrier"
372 :     msgstr ""
373 :    
374 :     #. type: node
375 :     #: R-ints.texi:108
376 :     #: R-ints.texi:1076
377 :     #: R-ints.texi:1121
378 :     #: R-ints.texi:1122
379 :     #: R-ints.texi:1229
380 :     #, no-wrap
381 :     msgid "Serialization Formats"
382 :     msgstr ""
383 :    
384 :     #. type: node
385 :     #: R-ints.texi:108
386 :     #: R-ints.texi:1121
387 :     #: R-ints.texi:1229
388 :     #: R-ints.texi:1230
389 :     #: R-ints.texi:1307
390 :     #, no-wrap
391 :     msgid "Encodings for CHARSXPs"
392 :     msgstr ""
393 :    
394 :     #. type: node
395 :     #: R-ints.texi:108
396 :     #: R-ints.texi:1229
397 :     #: R-ints.texi:1307
398 :     #: R-ints.texi:1308
399 :     #: R-ints.texi:1326
400 :     #, no-wrap
401 :     msgid "The CHARSXP cache"
402 :     msgstr ""
403 :    
404 :     #. type: node
405 :     #: R-ints.texi:108
406 :     #: R-ints.texi:1307
407 :     #: R-ints.texi:1326
408 :     #: R-ints.texi:1327
409 :     #: R-ints.texi:1376
410 :     #, no-wrap
411 :     msgid "Warnings and errors"
412 :     msgstr ""
413 :    
414 :     #. type: node
415 :     #: R-ints.texi:108
416 :     #: R-ints.texi:1326
417 :     #: R-ints.texi:1376
418 :     #: R-ints.texi:1377
419 :     #: R-ints.texi:1390
420 :     #: R-ints.texi:1411
421 :     #: R-ints.texi:1428
422 :     #: R-ints.texi:1479
423 :     #: R-ints.texi:1547
424 :     #, no-wrap
425 :     msgid "S4 objects"
426 :     msgstr ""
427 :    
428 :     #. type: node
429 :     #: R-ints.texi:108
430 :     #: R-ints.texi:1376
431 :     #: R-ints.texi:1547
432 :     #: R-ints.texi:1548
433 :     #: R-ints.texi:1680
434 :     #: R-ints.texi:1701
435 :     #, no-wrap
436 :     msgid "Memory allocators"
437 :     msgstr ""
438 :    
439 :     #. type: node
440 :     #: R-ints.texi:108
441 :     #: R-ints.texi:1547
442 :     #: R-ints.texi:1701
443 :     #: R-ints.texi:1702
444 :     #: R-ints.texi:1712
445 :     #: R-ints.texi:1739
446 :     #: R-ints.texi:1758
447 :     #, no-wrap
448 :     msgid "Internal use of global and base environments"
449 :     msgstr ""
450 :    
451 :     #. type: node
452 :     #: R-ints.texi:108
453 :     #: R-ints.texi:1701
454 :     #: R-ints.texi:1758
455 :     #: R-ints.texi:1759
456 :     #: R-ints.texi:1796
457 :     #, no-wrap
458 :     msgid "Modules"
459 :     msgstr ""
460 :    
461 :     #. type: node
462 :     #: R-ints.texi:108
463 :     #: R-ints.texi:1758
464 :     #: R-ints.texi:1796
465 :     #: R-ints.texi:1797
466 :     #: R-ints.texi:1805
467 :     #: R-ints.texi:1856
468 :     #: R-ints.texi:1883
469 :     #, no-wrap
470 :     msgid "Visibility"
471 :     msgstr ""
472 :    
473 :     #. type: section
474 :     #: R-ints.texi:108
475 :     #: R-ints.texi:1796
476 :     #: R-ints.texi:1883
477 :     #: R-ints.texi:1884
478 :     #, no-wrap
479 :     msgid "Lazy loading"
480 :     msgstr ""
481 :    
482 :     #. type: cindex
483 :     #: R-ints.texi:113
484 :     #, no-wrap
485 :     msgid "SEXP"
486 :     msgstr ""
487 :    
488 :     #. type: cindex
489 :     #: R-ints.texi:114
490 :     #, no-wrap
491 :     msgid "SEXPRREC"
492 :     msgstr ""
493 :    
494 :     #. type: Plain text
495 :     #: R-ints.texi:122
496 :     msgid "What @R{} users think of as @emph{variables} or @emph{objects} are symbols which are bound to a value. The value can be thought of as either a @code{SEXP} (a pointer), or the structure it points to, a @code{SEXPREC} (and there are alternative forms used for vectors, namely @code{VECSXP} pointing to @code{VECTOR_SEXPREC} structures). So the basic building blocks of @R{} objects are often called @emph{nodes}, meaning @code{SEXPREC}s or @code{VECTOR_SEXPREC}s."
497 :     msgstr ""
498 :    
499 :     #. type: Plain text
500 :     #: R-ints.texi:126
501 :     msgid "Note that the internal structure of the @code{SEXPREC} is not made available to @R{} Extensions: rather @code{SEXP} is an opaque pointer, and the internals can only be accessed by the functions provided."
502 :     msgstr ""
503 :    
504 :     #. type: cindex
505 :     #: R-ints.texi:127
506 :     #, no-wrap
507 :     msgid "node"
508 :     msgstr ""
509 :    
510 :     #. type: Plain text
511 :     #: R-ints.texi:135
512 :     msgid "Both types of node structure have as their first three fields a 32-bit @code{sxpinfo} header and then three pointers (to the attributes and the previous and next node in a doubly-linked list), and then some further fields. On a 32-bit platform a node@footnote{strictly, a @code{SEXPREC} node; @code{VECTOR_SEXPREC} nodes are slightly smaller but followed by data in the node.} occupies 28 bytes: on a 64-bit platform typically 56 bytes (depending on alignment constraints)."
513 :     msgstr ""
514 :    
515 :     #. type: Plain text
516 :     #: R-ints.texi:138
517 :     msgid "The first five bits of the @code{sxpinfo} header specify one of up to 32 @code{SEXPTYPE}s."
518 :     msgstr ""
519 :    
520 :     #. type: node
521 :     #: R-ints.texi:144
522 :     #: R-ints.texi:146
523 :     #: R-ints.texi:147
524 :     #: R-ints.texi:225
525 :     #, no-wrap
526 :     msgid "SEXPTYPEs"
527 :     msgstr ""
528 :    
529 :     #. type: node
530 :     #: R-ints.texi:144
531 :     #: R-ints.texi:146
532 :     #: R-ints.texi:225
533 :     #: R-ints.texi:226
534 :     #: R-ints.texi:372
535 :     #, no-wrap
536 :     msgid "Rest of header"
537 :     msgstr ""
538 :    
539 :     #. type: node
540 :     #: R-ints.texi:144
541 :     #: R-ints.texi:225
542 :     #: R-ints.texi:372
543 :     #: R-ints.texi:511
544 :     #, no-wrap
545 :     msgid "The 'data'"
546 :     msgstr ""
547 :    
548 :     #. type: subsection
549 :     #: R-ints.texi:144
550 :     #: R-ints.texi:372
551 :     #: R-ints.texi:511
552 :     #: R-ints.texi:512
553 :     #, no-wrap
554 :     msgid "Allocation classes"
555 :     msgstr ""
556 :    
557 :     #. type: multitable
558 :     #: R-ints.texi:149
559 :     #: R-ints.texi:160
560 :     #, no-wrap
561 :     msgid "SEXPTYPE"
562 :     msgstr ""
563 :    
564 :     #. type: Plain text
565 :     #: R-ints.texi:155
566 :     msgid "Currently @code{SEXPTYPE}s 0:10 and 13:25 are in use. Values 11 and 12 were used for internal factors and ordered factors and have since been withdrawn. Note that the @code{SEXPTYPE} numbers are stored in @code{save}d objects and that the ordering of the types is used, so the gap cannot easily be reused."
567 :     msgstr ""
568 :    
569 :     #. type: cindex
570 :     #: R-ints.texi:156
571 :     #, no-wrap
572 :     msgid "SEXPTYPE table"
573 :     msgstr ""
574 :    
575 :     #. type: multitable
576 :     #: R-ints.texi:160
577 :     msgid "@headitem no"
578 :     msgstr ""
579 :    
580 :     #. type: multitable
581 :     #: R-ints.texi:160
582 :     msgid "Description"
583 :     msgstr ""
584 :    
585 :     #. type: item
586 :     #: R-ints.texi:160
587 :     #, no-wrap
588 :     msgid "@code{0} @tab @code{NILSXP} @tab @code{NULL}"
589 :     msgstr ""
590 :    
591 :     #. type: item
592 :     #: R-ints.texi:161
593 :     #, no-wrap
594 :     msgid "@code{1} @tab @code{SYMSXP} @tab symbols"
595 :     msgstr ""
596 :    
597 :     #. type: item
598 :     #: R-ints.texi:162
599 :     #, no-wrap
600 :     msgid "@code{2} @tab @code{LISTSXP} @tab pairlists"
601 :     msgstr ""
602 :    
603 :     #. type: item
604 :     #: R-ints.texi:163
605 :     #, no-wrap
606 :     msgid "@code{3} @tab @code{CLOSXP} @tab closures"
607 :     msgstr ""
608 :    
609 :     #. type: item
610 :     #: R-ints.texi:164
611 :     #, no-wrap
612 :     msgid "@code{4} @tab @code{ENVSXP} @tab environments"
613 :     msgstr ""
614 :    
615 :     #. type: item
616 :     #: R-ints.texi:165
617 :     #, no-wrap
618 :     msgid "@code{5} @tab @code{PROMSXP} @tab promises"
619 :     msgstr ""
620 :    
621 :     #. type: item
622 :     #: R-ints.texi:166
623 :     #, no-wrap
624 :     msgid "@code{6} @tab @code{LANGSXP} @tab language objects"
625 :     msgstr ""
626 :    
627 :     #. type: item
628 :     #: R-ints.texi:167
629 :     #, no-wrap
630 :     msgid "@code{7} @tab @code{SPECIALSXP} @tab special functions"
631 :     msgstr ""
632 :    
633 :     #. type: item
634 :     #: R-ints.texi:168
635 :     #, no-wrap
636 :     msgid "@code{8} @tab @code{BUILTINSXP} @tab builtin functions"
637 :     msgstr ""
638 :    
639 :     #. type: item
640 :     #: R-ints.texi:169
641 :     #, no-wrap
642 :     msgid "@code{9} @tab @code{CHARSXP} @tab internal character strings"
643 :     msgstr ""
644 :    
645 :     #. type: item
646 :     #: R-ints.texi:170
647 :     #, no-wrap
648 :     msgid "@code{10} @tab @code{LGLSXP} @tab logical vectors"
649 :     msgstr ""
650 :    
651 :     #. type: item
652 :     #: R-ints.texi:171
653 :     #, no-wrap
654 :     msgid "@code{13} @tab @code{INTSXP} @tab integer vectors"
655 :     msgstr ""
656 :    
657 :     #. type: item
658 :     #: R-ints.texi:172
659 :     #, no-wrap
660 :     msgid "@code{14} @tab @code{REALSXP} @tab numeric vectors"
661 :     msgstr ""
662 :    
663 :     #. type: item
664 :     #: R-ints.texi:173
665 :     #, no-wrap
666 :     msgid "@code{15} @tab @code{CPLXSXP} @tab complex vectors"
667 :     msgstr ""
668 :    
669 :     #. type: item
670 :     #: R-ints.texi:174
671 :     #, no-wrap
672 :     msgid "@code{16} @tab @code{STRSXP} @tab character vectors"
673 :     msgstr ""
674 :    
675 :     #. type: item
676 :     #: R-ints.texi:175
677 :     #, no-wrap
678 :     msgid "@code{17} @tab @code{DOTSXP} @tab dot-dot-dot object"
679 :     msgstr ""
680 :    
681 :     #. type: item
682 :     #: R-ints.texi:176
683 :     #, no-wrap
684 :     msgid "@code{18} @tab @code{ANYSXP} @tab make ``any'' args work"
685 :     msgstr ""
686 :    
687 :     #. type: item
688 :     #: R-ints.texi:177
689 :     #, no-wrap
690 :     msgid "@code{19} @tab @code{VECSXP} @tab list (generic vector)"
691 :     msgstr ""
692 :    
693 :     #. type: item
694 :     #: R-ints.texi:178
695 :     #, no-wrap
696 :     msgid "@code{20} @tab @code{EXPRSXP} @tab expression vector"
697 :     msgstr ""
698 :    
699 :     #. type: item
700 :     #: R-ints.texi:179
701 :     #, no-wrap
702 :     msgid "@code{21} @tab @code{BCODESXP} @tab byte code"
703 :     msgstr ""
704 :    
705 :     #. type: item
706 :     #: R-ints.texi:180
707 :     #, no-wrap
708 :     msgid "@code{22} @tab @code{EXTPTRSXP} @tab external pointer"
709 :     msgstr ""
710 :    
711 :     #. type: item
712 :     #: R-ints.texi:181
713 :     #, no-wrap
714 :     msgid "@code{23} @tab @code{WEAKREFSXP} @tab weak reference"
715 :     msgstr ""
716 :    
717 :     #. type: item
718 :     #: R-ints.texi:182
719 :     #, no-wrap
720 :     msgid "@code{24} @tab @code{RAWSXP} @tab raw vector"
721 :     msgstr ""
722 :    
723 :     #. type: item
724 :     #: R-ints.texi:183
725 :     #, no-wrap
726 :     msgid "@code{25} @tab @code{S4SXP} @tab S4 classes not of simple type"
727 :     msgstr ""
728 :    
729 :     #. type: cindex
730 :     #: R-ints.texi:187
731 :     #, no-wrap
732 :     msgid "atomic vector type"
733 :     msgstr ""
734 :    
735 :     #. type: Plain text
736 :     #: R-ints.texi:196
737 :     msgid "Many of these will be familiar from @R{} level: the atomic vector types are @code{LGLSXP}, @code{INTSXP}, @code{REALSXP}, @code{CPLXSP}, @code{STRSXP} and @code{RAWSXP}. Lists are @code{VECSXP} and names (also known as symbols) are @code{SYMSXP}. Pairlists (@code{LISTSXP}, the name going back to the origins of @R{} as a Scheme-like language) are rarely seen at @R{} level, but are for example used for argument lists. Character vectors are effectively lists all of whose elements are @code{CHARSXP}, a type that is rarely visible at @R{} level."
738 :     msgstr ""
739 :    
740 :     #. type: cindex
741 :     #: R-ints.texi:197
742 :     #, no-wrap
743 :     msgid "language object"
744 :     msgstr ""
745 :    
746 :     #. type: cindex
747 :     #: R-ints.texi:198
748 :     #, no-wrap
749 :     msgid "argument list"
750 :     msgstr ""
751 :    
752 :     #. type: Plain text
753 :     #: R-ints.texi:208
754 :     msgid "Language objects (@code{LANGSXP}) are calls (including formulae and so on). Internally they are pairlists with first element a reference@footnote{a pointer to a function or a symbol to look up the function by name, or a language object to be evaluated to give a function.} to the function to be called with remaining elements the actual arguments for the call (and with the tags if present giving the specified argument names). Although this is not enforced, many places in the code assume that the pairlist is of length one or more, often without checking."
755 :     msgstr ""
756 :    
757 :     #. type: cindex
758 :     #: R-ints.texi:209
759 :     #, no-wrap
760 :     msgid "expression"
761 :     msgstr ""
762 :    
763 :     #. type: Plain text
764 :     #: R-ints.texi:212
765 :     msgid "Expressions are of type @code{EXPRSXP}: they are a vector of (usually language) objects most often seen as the result of @code{parse()}."
766 :     msgstr ""
767 :    
768 :     #. type: cindex
769 :     #: R-ints.texi:213
770 :     #, no-wrap
771 :     msgid "function"
772 :     msgstr ""
773 :    
774 :     #. type: Plain text
775 :     #: R-ints.texi:219
776 :     msgid "The functions are of types @code{CLOSXP}, @code{SPECIALSXP} and @code{BUILTINSXP}: where @code{SEXPTYPE}s are stored in an integer these are sometimes lumped into a pseudo-type @code{FUNSXP} with code 99. Functions defined via @code{function} are of type @code{CLOSXP} and have formals, body and environment."
777 :     msgstr ""
778 :    
779 :     #. type: cindex
780 :     #: R-ints.texi:220
781 :     #, no-wrap
782 :     msgid "S4 type"
783 :     msgstr ""
784 :    
785 :     #. type: Plain text
786 :     #: R-ints.texi:223
787 :     msgid "The @code{SEXPTYPE} @code{S4SXP} is for S4 objects which do not consist solely of a simple type such as an atomic vector or function."
788 :     msgstr ""
789 :    
790 :     #. type: Plain text
791 :     #: R-ints.texi:229
792 :     msgid "The @code{sxpinfo} header is defined as a 32-bit C structure by"
793 :     msgstr ""
794 :    
795 :     #. type: example
796 :     #: R-ints.texi:243
797 :     #, no-wrap
798 :     msgid ""
799 :     "struct sxpinfo_struct @{\n"
800 :     " SEXPTYPE type : 5; /* @r{discussed above} */\n"
801 :     " unsigned int obj : 1; /* @r{is this an object with a class attribute?} */\n"
802 :     " unsigned int named : 2; /* @r{used to control copying} */\n"
803 :     " unsigned int gp : 16; /* @r{general purpose, see below} */\n"
804 :     " unsigned int mark : 1; /* @r{mark object as `in use' in GC} */\n"
805 :     " unsigned int debug : 1;\n"
806 :     " unsigned int trace : 1;\n"
807 :     " unsigned int spare : 1; /* @r{debug once} */\n"
808 :     " unsigned int gcgen : 1; /* @r{generation for GC} */\n"
809 :     " unsigned int gccls : 3; /* @r{class of node for GC} */\n"
810 :     "@}; /* Tot: 32 */\n"
811 :     msgstr ""
812 :    
813 :     #. type: findex
814 :     #: R-ints.texi:245
815 :     #, no-wrap
816 :     msgid "debug bit"
817 :     msgstr ""
818 :    
819 :     #. type: Plain text
820 :     #: R-ints.texi:251
821 :     msgid "The @code{debug} bit is used for closures and environments. For closures it is set by @code{debug()} and unset by @code{undebug()}, and indicates that evaluations of the function should be run under the browser. For environments it indicates whether the browsing is in single-step mode."
822 :     msgstr ""
823 :    
824 :     #. type: findex
825 :     #: R-ints.texi:252
826 :     #, no-wrap
827 :     msgid "trace bit"
828 :     msgstr ""
829 :    
830 :     #. type: Plain text
831 :     #: R-ints.texi:255
832 :     msgid "The @code{trace} bit is used for functions for @code{trace()} and for other objects when tracing duplications (see @code{tracemem})."
833 :     msgstr ""
834 :    
835 :     #. type: findex
836 :     #: R-ints.texi:256
837 :     #, no-wrap
838 :     msgid "spare bit"
839 :     msgstr ""
840 :    
841 :     #. type: Plain text
842 :     #: R-ints.texi:259
843 :     msgid "The @code{spare} bit is used for closures to mark them for one time debugging."
844 :     msgstr ""
845 :    
846 :     #. type: findex
847 :     #: R-ints.texi:260
848 :     #, no-wrap
849 :     msgid "named bit"
850 :     msgstr ""
851 :    
852 :     #. type: findex
853 :     #: R-ints.texi:261
854 :     #: R-ints.texi:886
855 :     #: R-ints.texi:2129
856 :     #, no-wrap
857 :     msgid "NAMED"
858 :     msgstr ""
859 :    
860 :     #. type: findex
861 :     #: R-ints.texi:262
862 :     #, no-wrap
863 :     msgid "SET_NAMED"
864 :     msgstr ""
865 :    
866 :     #. type: cindex
867 :     #: R-ints.texi:263
868 :     #: R-ints.texi:716
869 :     #, no-wrap
870 :     msgid "copying semantics"
871 :     msgstr ""
872 :    
873 :     #. type: Plain text
874 :     #: R-ints.texi:267
875 :     msgid "The @code{named} field is set and accessed by the @code{SET_NAMED} and @code{NAMED} macros, and take values @code{0}, @code{1} and @code{2}. @R{} has a `call by value' illusion, so an assignment like"
876 :     msgstr ""
877 :    
878 :     #. type: example
879 :     #: R-ints.texi:269
880 :     #, no-wrap
881 :     msgid "b <- a\n"
882 :     msgstr ""
883 :    
884 :     #. type: Plain text
885 :     #: R-ints.texi:284
886 :     msgid "appears to make a copy of @code{a} and refer to it as @code{b}. However, if neither @code{a} nor @code{b} are subsequently altered there is no need to copy. What really happens is that a new symbol @code{b} is bound to the same value as @code{a} and the @code{named} field on the value object is set (in this case to @code{2}). When an object is about to be altered, the @code{named} field is consulted. A value of @code{2} means that the object must be duplicated before being changed. (Note that this does not say that it is necessary to duplicate, only that it should be duplicated whether necessary or not.) A value of @code{0} means that it is known that no other @code{SEXP} shares data with this object, and so it may safely be altered. A value of @code{1} is used for situations like"
887 :     msgstr ""
888 :    
889 :     #. type: example
890 :     #: R-ints.texi:287
891 :     #, no-wrap
892 :     msgid "dim(a) <- c(7, 2)\n"
893 :     msgstr ""
894 :    
895 :     #. type: Plain text
896 :     #: R-ints.texi:292
897 :     msgid "where in principle two copies of @code{a} exist for the duration of the computation as (in principle)"
898 :     msgstr ""
899 :    
900 :     #. type: example
901 :     #: R-ints.texi:295
902 :     #, no-wrap
903 :     msgid "a <- `dim<-`(a, c(7, 2))\n"
904 :     msgstr ""
905 :    
906 :     #. type: Plain text
907 :     #: R-ints.texi:300
908 :     msgid "but for no longer, and so some primitive functions can be optimized to avoid a copy in this case."
909 :     msgstr ""
910 :    
911 :     #. type: Plain text
912 :     #: R-ints.texi:304
913 :     msgid "The @code{gp} bits are by definition `general purpose'. We label these from 0 to 15. Bits 0--5 and bits 14--15 have been used as described below (mainly from detective work on the sources)."
914 :     msgstr ""
915 :    
916 :     #. type: findex
917 :     #: R-ints.texi:305
918 :     #, no-wrap
919 :     msgid "gp bits"
920 :     msgstr ""
921 :    
922 :     #. type: findex
923 :     #: R-ints.texi:306
924 :     #, no-wrap
925 :     msgid "LEVELS"
926 :     msgstr ""
927 :    
928 :     #. type: findex
929 :     #: R-ints.texi:307
930 :     #, no-wrap
931 :     msgid "SETLEVELS"
932 :     msgstr ""
933 :    
934 :     #. type: Plain text
935 :     #: R-ints.texi:314
936 :     msgid "The bits can be accessed and set by the @code{LEVELS} and @code{SETLEVELS} macros, which names appear to date back to the internal factor and ordered types and are now used in only a few places in the code. The @code{gp} field is serialized/unserialized for the @code{SEXPTYPE}s other than @code{NILSXP}, @code{SYMSXP} and @code{ENVSXP}."
937 :     msgstr ""
938 :    
939 :     #. type: Plain text
940 :     #: R-ints.texi:320
941 :     msgid "Bits 14 and 15 of @code{gp} are used for `fancy bindings'. Bit 14 is used to lock a binding or an environment, and bit 15 is used to indicate an active binding. (For the definition of an `active binding' see the header comments in file @file{src/main/envir.c}.) Bit 15 is used for an environment to indicate if it participates in the global cache."
942 :     msgstr ""
943 :    
944 :     #. type: findex
945 :     #: R-ints.texi:321
946 :     #, no-wrap
947 :     msgid "ARGSUSED"
948 :     msgstr ""
949 :    
950 :     #. type: findex
951 :     #: R-ints.texi:322
952 :     #, no-wrap
953 :     msgid "SET_ARGUSED"
954 :     msgstr ""
955 :    
956 :     #. type: Plain text
957 :     #: R-ints.texi:325
958 :     msgid "The macros @code{ARGUSED} and @code{SET_ARGUSED} are used when matching actual and formal function arguments, and take the values 0, 1 and 2."
959 :     msgstr ""
960 :    
961 :     #. type: findex
962 :     #: R-ints.texi:326
963 :     #: R-ints.texi:963
964 :     #, no-wrap
965 :     msgid "MISSING"
966 :     msgstr ""
967 :    
968 :     #. type: findex
969 :     #: R-ints.texi:327
970 :     #, no-wrap
971 :     msgid "SET_MISSING"
972 :     msgstr ""
973 :    
974 :     #. type: Plain text
975 :     #: R-ints.texi:334
976 :     msgid "The macros @code{MISSING} and @code{SET_MISSING} are used for pairlists of arguments. Four bits are reserved, but only two are used (and exactly what for is not explained). It seems that bit 0 is used by @code{matchArgs} to mark missingness on the returned argument list, and bit 1 is used to mark the use of a default value for an argument copied to the evaluation frame of a closure."
977 :     msgstr ""
978 :    
979 :     #. type: findex
980 :     #: R-ints.texi:335
981 :     #, no-wrap
982 :     msgid "DDVAL"
983 :     msgstr ""
984 :    
985 :     #. type: findex
986 :     #: R-ints.texi:336
987 :     #, no-wrap
988 :     msgid "SET_DDVAL"
989 :     msgstr ""
990 :    
991 :     #. type: cindex
992 :     #: R-ints.texi:337
993 :     #: R-ints.texi:996
994 :     #, no-wrap
995 :     msgid "... argument"
996 :     msgstr ""
997 :    
998 :     #. type: Plain text
999 :     #: R-ints.texi:342
1000 :     msgid "Bit 0 is used by macros @code{DDVAL} and @code{SET_DDVAL}. This indicates that a @code{SYMSXP} is one of the symbols @code{..n} which are implicitly created when @code{...} is processed, and so indicates that it may need to be looked up in a @code{DOTSXP}."
1001 :     msgstr ""
1002 :    
1003 :     #. type: findex
1004 :     #: R-ints.texi:343
1005 :     #, no-wrap
1006 :     msgid "PRSEEN"
1007 :     msgstr ""
1008 :    
1009 :     #. type: cindex
1010 :     #: R-ints.texi:344
1011 :     #, no-wrap
1012 :     msgid "promise"
1013 :     msgstr ""
1014 :    
1015 :     #. type: Plain text
1016 :     #: R-ints.texi:348
1017 :     msgid "Bit 0 is used for @code{PRSEEN}, a flag to indicate if a promise has already been seen during the evaluation of the promise (and so to avoid recursive loops)."
1018 :     msgstr ""
1019 :    
1020 :     #. type: Plain text
1021 :     #: R-ints.texi:352
1022 :     msgid "Bit 0 is used for @code{HASHASH}, on the @code{PRINTNAME} of the @code{TAG} of the frame of an environment. (This bit is not serialized for @code{CHARSXP} objects.)"
1023 :     msgstr ""
1024 :    
1025 :     #. type: Plain text
1026 :     #: R-ints.texi:355
1027 :     msgid "Bits 0 and 1 are used for weak references (to indicate `ready to finalize', `finalize on exit')."
1028 :     msgstr ""
1029 :    
1030 :     #. type: Plain text
1031 :     #: R-ints.texi:358
1032 :     msgid "Bit 0 is used by the condition handling system (on a @code{VECSXP}) to indicate a calling handler."
1033 :     msgstr ""
1034 :    
1035 :     #. type: Plain text
1036 :     #: R-ints.texi:360
1037 :     msgid "Bit 4 is turned on to mark S4 objects."
1038 :     msgstr ""
1039 :    
1040 :     #. type: Plain text
1041 :     #: R-ints.texi:366
1042 :     msgid "Bits 1, 2, 3, 5 and 6 are used for a @code{CHARSXP} to denote its encoding. Bit 1 indicates that the @code{CHARSXP} should be treated as a set of bytes, not necessarily representing a character in any known encoding. Bits 2, 3 and 6 are used to indicate that it is known to be in Latin-1, UTF-8 or @acronym{ASCII} respectively."
1043 :     msgstr ""
1044 :    
1045 :     #. type: Plain text
1046 :     #: R-ints.texi:371
1047 :     msgid "Bit 5 for a @code{CHARSXP} indicates that it is hashed by its address, that is @code{NA_STRING} or is in the @code{CHARSXP} cache (this is not serialized). Only exceptionally is a @code{CHARSXP} not hashed, and this should never happen in end-user code."
1048 :     msgstr ""
1049 :    
1050 :     #. type: subsection
1051 :     #: R-ints.texi:373
1052 :     #, no-wrap
1053 :     msgid "The `data'"
1054 :     msgstr ""
1055 :    
1056 :     #. type: Plain text
1057 :     #: R-ints.texi:378
1058 :     msgid "A @code{SEXPREC} is a C structure containing the 32-bit header as described above, three pointers (to the attributes, previous and next node) and the node data, a union"
1059 :     msgstr ""
1060 :    
1061 :     #. type: example
1062 :     #: R-ints.texi:388
1063 :     #, no-wrap
1064 :     msgid ""
1065 :     "union @{\n"
1066 :     " struct primsxp_struct primsxp;\n"
1067 :     " struct symsxp_struct symsxp;\n"
1068 :     " struct listsxp_struct listsxp;\n"
1069 :     " struct envsxp_struct envsxp;\n"
1070 :     " struct closxp_struct closxp;\n"
1071 :     " struct promsxp_struct promsxp;\n"
1072 :     "@} u;\n"
1073 :     msgstr ""
1074 :    
1075 :     #. type: Plain text
1076 :     #: R-ints.texi:393
1077 :     msgid "All of these alternatives apart from the first (an @code{int}) are three pointers, so the union occupies three words."
1078 :     msgstr ""
1079 :    
1080 :     #. type: cindex
1081 :     #: R-ints.texi:394
1082 :     #, no-wrap
1083 :     msgid "vector type"
1084 :     msgstr ""
1085 :    
1086 :     #. type: Plain text
1087 :     #: R-ints.texi:411
1088 :     msgid "The vector types are @code{RAWSXP}, @code{CHARSXP}, @code{LGLSXP}, @code{INTSXP}, @code{REALSXP}, @code{CPLXSXP}, @code{STRSXP}, @code{VECSXP}, @code{EXPRSXP} and @code{WEAKREFSXP}. Remember that such types are a @code{VECTOR_SEXPREC}, which again consists of the header and the same three pointers, but followed by two integers giving the length and `true length'@footnote{This is almost unused. The only current use is for hash tables of environments (@code{VECSXP}s), where @code{length} is the size of the table and @code{truelength} is the number of primary slots in use, and for the reference hash tables in serialization (@code{VECSXP}s), where @code{truelength} is the number of slots in use.} of the vector, and then followed by the data (aligned as required: on most 32-bit systems with a 24-byte @code{VECTOR_SEXPREC} node the data can follow immediately after the node). The data are a block of memory of the appropriate length to store `true length' elements (rounded up to a multiple of 8 bytes, with the 8-byte blocks being the `Vcells' referred in the documentation for @code{gc()})."
1089 :     msgstr ""
1090 :    
1091 :     #. type: Plain text
1092 :     #: R-ints.texi:414
1093 :     msgid "The `data' for the various types are given in the table below. A lot of this is interpretation, i.e. the types are not checked."
1094 :     msgstr ""
1095 :    
1096 :     #. type: item
1097 :     #: R-ints.texi:416
1098 :     #, no-wrap
1099 :     msgid "NILSXP"
1100 :     msgstr ""
1101 :    
1102 :     #. type: table
1103 :     #: R-ints.texi:419
1104 :     msgid "There is only one object of type @code{NILSXP}, @code{R_NilValue}, with no data."
1105 :     msgstr ""
1106 :    
1107 :     #. type: item
1108 :     #: R-ints.texi:420
1109 :     #, no-wrap
1110 :     msgid "SYMSXP"
1111 :     msgstr ""
1112 :    
1113 :     #. type: table
1114 :     #: R-ints.texi:426
1115 :     msgid "Pointers to three nodes, the name, value and internal, accessed by @code{PRINTNAME} (a @code{CHARSXP}), @code{SYMVALUE} and @code{INTERNAL}. (If the symbol's value is a @code{.Internal} function, the last is a pointer to the appropriate @code{SEXPREC}.) Many symbols have @code{SYMVALUE} @code{R_UnboundValue}."
1116 :     msgstr ""
1117 :    
1118 :     #. type: item
1119 :     #: R-ints.texi:427
1120 :     #, no-wrap
1121 :     msgid "LISTSXP"
1122 :     msgstr ""
1123 :    
1124 :     #. type: table
1125 :     #: R-ints.texi:430
1126 :     msgid "Pointers to the CAR, CDR (usually a @code{LISTSXP} or @code{NULL}) and TAG (a @code{SYMSXP} or @code{NULL})."
1127 :     msgstr ""
1128 :    
1129 :     #. type: item
1130 :     #: R-ints.texi:431
1131 :     #, no-wrap
1132 :     msgid "CLOSXP"
1133 :     msgstr ""
1134 :    
1135 :     #. type: table
1136 :     #: R-ints.texi:433
1137 :     msgid "Pointers to the formals (a pairlist), the body and the environment."
1138 :     msgstr ""
1139 :    
1140 :     #. type: item
1141 :     #: R-ints.texi:434
1142 :     #, no-wrap
1143 :     msgid "ENVSXP"
1144 :     msgstr ""
1145 :    
1146 :     #. type: table
1147 :     #: R-ints.texi:438
1148 :     msgid "Pointers to the frame, enclosing environment and hash table (@code{NULL} or a @code{VECSXP}). A frame is a tagged pairlist with tag the symbol and CAR the bound value."
1149 :     msgstr ""
1150 :    
1151 :     #. type: item
1152 :     #: R-ints.texi:439
1153 :     #, no-wrap
1154 :     msgid "PROMSXP"
1155 :     msgstr ""
1156 :    
1157 :     #. type: table
1158 :     #: R-ints.texi:443
1159 :     msgid "Pointers to the value, expression and environment (in which to evaluate the expression). Once an promise has been evaluated, the environment is set to @code{NULL}."
1160 :     msgstr ""
1161 :    
1162 :     #. type: item
1163 :     #: R-ints.texi:444
1164 :     #, no-wrap
1165 :     msgid "LANGSXP"
1166 :     msgstr ""
1167 :    
1168 :     #. type: table
1169 :     #: R-ints.texi:451
1170 :     msgid "A special type of @code{LISTSXP} used for function calls. (The CAR references the function (perhaps via a symbol or language object), and the CDR the argument list with tags for named arguments.) @R{}-level documentation references to `expressions' / `language objects' are mainly @code{LANGSXP}s, but can be symbols (@code{SYMSXP}s) or expression vectors (@code{EXPRSXP}s)."
1171 :     msgstr ""
1172 :    
1173 :     #. type: item
1174 :     #: R-ints.texi:452
1175 :     #, no-wrap
1176 :     msgid "SPECIALSXP"
1177 :     msgstr ""
1178 :    
1179 :     #. type: itemx
1180 :     #: R-ints.texi:453
1181 :     #, no-wrap
1182 :     msgid "BUILTINSXP"
1183 :     msgstr ""
1184 :    
1185 :     #. type: table
1186 :     #: R-ints.texi:456
1187 :     msgid "An integer giving the offset into the table of primitives/@code{.Internal}s."
1188 :     msgstr ""
1189 :    
1190 :     #. type: item
1191 :     #: R-ints.texi:457
1192 :     #, no-wrap
1193 :     msgid "CHARSXP"
1194 :     msgstr ""
1195 :    
1196 :     #. type: table
1197 :     #: R-ints.texi:460
1198 :     msgid "@code{length}, @code{truelength} followed by a block of bytes (allowing for the @code{nul} terminator)."
1199 :     msgstr ""
1200 :    
1201 :     #. type: item
1202 :     #: R-ints.texi:461
1203 :     #, no-wrap
1204 :     msgid "LGLSXP"
1205 :     msgstr ""
1206 :    
1207 :     #. type: itemx
1208 :     #: R-ints.texi:462
1209 :     #, no-wrap
1210 :     msgid "INTSXP"
1211 :     msgstr ""
1212 :    
1213 :     #. type: table
1214 :     #: R-ints.texi:465
1215 :     msgid "@code{length}, @code{truelength} followed by a block of C @code{int}s (which are 32 bits on all @R{} platforms)."
1216 :     msgstr ""
1217 :    
1218 :     #. type: item
1219 :     #: R-ints.texi:466
1220 :     #, no-wrap
1221 :     msgid "REALSXP"
1222 :     msgstr ""
1223 :    
1224 :     #. type: table
1225 :     #: R-ints.texi:468
1226 :     msgid "@code{length}, @code{truelength} followed by a block of C @code{double}s."
1227 :     msgstr ""
1228 :    
1229 :     #. type: item
1230 :     #: R-ints.texi:469
1231 :     #, no-wrap
1232 :     msgid "CPLXSXP"
1233 :     msgstr ""
1234 :    
1235 :     #. type: table
1236 :     #: R-ints.texi:472
1237 :     msgid "@code{length}, @code{truelength} followed by a block of C99 @code{double complex}s."
1238 :     msgstr ""
1239 :    
1240 :     #. type: item
1241 :     #: R-ints.texi:473
1242 :     #, no-wrap
1243 :     msgid "STRSXP"
1244 :     msgstr ""
1245 :    
1246 :     #. type: table
1247 :     #: R-ints.texi:476
1248 :     msgid "@code{length}, @code{truelength} followed by a block of pointers (@code{SEXP}s pointing to @code{CHARSXP}s)."
1249 :     msgstr ""
1250 :    
1251 :     #. type: item
1252 :     #: R-ints.texi:477
1253 :     #, no-wrap
1254 :     msgid "DOTSXP"
1255 :     msgstr ""
1256 :    
1257 :     #. type: table
1258 :     #: R-ints.texi:480
1259 :     msgid "A special type of @code{LISTSXP} for the value bound to a @code{...} symbol: a pairlist of promises."
1260 :     msgstr ""
1261 :    
1262 :     #. type: item
1263 :     #: R-ints.texi:481
1264 :     #, no-wrap
1265 :     msgid "ANYSXP"
1266 :     msgstr ""
1267 :    
1268 :     #. type: table
1269 :     #: R-ints.texi:484
1270 :     msgid "This is used as a place holder for any type: there are no actual objects of this type."
1271 :     msgstr ""
1272 :    
1273 :     #. type: item
1274 :     #: R-ints.texi:485
1275 :     #, no-wrap
1276 :     msgid "VECSXP"
1277 :     msgstr ""
1278 :    
1279 :     #. type: itemx
1280 :     #: R-ints.texi:486
1281 :     #, no-wrap
1282 :     msgid "EXPRSXP"
1283 :     msgstr ""
1284 :    
1285 :     #. type: table
1286 :     #: R-ints.texi:490
1287 :     msgid "@code{length}, @code{truelength} followed by a block of pointers. These are internally identical (and identical to @code{STRSXP}) but differ in the interpretations placed on the elements."
1288 :     msgstr ""
1289 :    
1290 :     #. type: item
1291 :     #: R-ints.texi:491
1292 :     #, no-wrap
1293 :     msgid "BCODESXP"
1294 :     msgstr ""
1295 :    
1296 :     #. type: table
1297 :     #: R-ints.texi:493
1298 :     msgid "For the `byte-code' objects generated by the compiler."
1299 :     msgstr ""
1300 :    
1301 :     #. type: item
1302 :     #: R-ints.texi:494
1303 :     #, no-wrap
1304 :     msgid "EXTPTRSXP"
1305 :     msgstr ""
1306 :    
1307 :     #. type: table
1308 :     #: R-ints.texi:497
1309 :     msgid "Has three pointers, to the pointer, the protection value (an @R{} object which if alive protects this object) and a tag (a @code{SYMSXP}?)."
1310 :     msgstr ""
1311 :    
1312 :     #. type: item
1313 :     #: R-ints.texi:498
1314 :     #, no-wrap
1315 :     msgid "WEAKREFSXP"
1316 :     msgstr ""
1317 :    
1318 :     #. type: table
1319 :     #: R-ints.texi:503
1320 :     msgid "A @code{WEAKREFSXP} is a special @code{VECSXP} of length 4, with elements @samp{key}, @samp{value}, @samp{finalizer} and @samp{next}. The @samp{key} is @code{NULL}, an environment or an external pointer, and the @samp{finalizer} is a function or @code{NULL}."
1321 :     msgstr ""
1322 :    
1323 :     #. type: item
1324 :     #: R-ints.texi:504
1325 :     #, no-wrap
1326 :     msgid "RAWSXP"
1327 :     msgstr ""
1328 :    
1329 :     #. type: table
1330 :     #: R-ints.texi:506
1331 :     msgid "@code{length}, @code{truelength} followed by a block of bytes."
1332 :     msgstr ""
1333 :    
1334 :     #. type: item
1335 :     #: R-ints.texi:507
1336 :     #, no-wrap
1337 :     msgid "S4SXP"
1338 :     msgstr ""
1339 :    
1340 :     #. type: table
1341 :     #: R-ints.texi:509
1342 :     msgid "two unused pointers and a tag."
1343 :     msgstr ""
1344 :    
1345 :     #. type: cindex
1346 :     #: R-ints.texi:514
1347 :     #, no-wrap
1348 :     msgid "allocation classes"
1349 :     msgstr ""
1350 :    
1351 :     #. type: Plain text
1352 :     #: R-ints.texi:526
1353 :     msgid "As we have seen, the field @code{gccls} in the header is three bits to label up to 8 classes of nodes. Non-vector nodes are of class 0, and `small' vector nodes are of classes 1 to 5, with a class for custom allocator vector nodes 6 and `large' vector nodes being of class 7. The `small' vector nodes are able to store vector data of up to 8, 16, 32, 64 and 128 bytes: larger vectors are @code{malloc}-ed individually whereas the `small' nodes are allocated from pages of about 2000 bytes. Vector nodes allocated using custom allocators (via @code{allocVector3}) are not counted in the gc memory usage statistics since their memory semantics is not under R's control and may be non-standard (e.g., memory could be partially shared across nodes)."
1354 :     msgstr ""
1355 :    
1356 :     #. type: cindex
1357 :     #: R-ints.texi:531
1358 :     #, no-wrap
1359 :     msgid "environment"
1360 :     msgstr ""
1361 :    
1362 :     #. type: cindex
1363 :     #: R-ints.texi:532
1364 :     #, no-wrap
1365 :     msgid "variable lookup"
1366 :     msgstr ""
1367 :    
1368 :     #. type: Plain text
1369 :     #: R-ints.texi:538
1370 :     msgid "What users think of as `variables' are symbols which are bound to objects in `environments'. The word `environment' is used ambiguously in @R{} to mean @emph{either} the frame of an @code{ENVSXP} (a pairlist of symbol-value pairs) @emph{or} an @code{ENVSXP}, a frame plus an enclosure."
1371 :     msgstr ""
1372 :    
1373 :     #. type: cindex
1374 :     #: R-ints.texi:539
1375 :     #, no-wrap
1376 :     msgid "user databases"
1377 :     msgstr ""
1378 :    
1379 :     #. type: Plain text
1380 :     #: R-ints.texi:544
1381 :     msgid "There are additional places that `variables' can be looked up, called `user databases' in comments in the code. These seem undocumented in the @R{} sources, but apparently refer to the @pkg{RObjectTable} package at @uref{http://www.omegahat.org/RObjectTables/}."
1382 :     msgstr ""
1383 :    
1384 :     #. type: cindex
1385 :     #: R-ints.texi:545
1386 :     #: R-ints.texi:1715
1387 :     #, no-wrap
1388 :     msgid "base environment"
1389 :     msgstr ""
1390 :    
1391 :     #. type: cindex
1392 :     #: R-ints.texi:546
1393 :     #: R-ints.texi:1716
1394 :     #, no-wrap
1395 :     msgid "environment, base"
1396 :     msgstr ""
1397 :    
1398 :     #. type: Plain text
1399 :     #: R-ints.texi:558
1400 :     msgid "The base environment is special. There is an @code{ENVSXP} environment with enclosure the empty environment @code{R_EmptyEnv}, but the frame of that environment is not used. Rather its bindings are part of the global symbol table, being those symbols in the global symbol table whose values are not @code{R_UnboundValue}. When @R{} is started the internal functions are installed (by C code) in the symbol table, with primitive functions having values and @code{.Internal} functions having what would be their values in the field accessed by the @code{INTERNAL} macro. Then @code{.Platform} and @code{.Machine} are computed and the base package is loaded into the base environment followed by the system profile."
1401 :     msgstr ""
1402 :    
1403 :     #. type: Plain text
1404 :     #: R-ints.texi:561
1405 :     msgid "The frames of environments (and the symbol table) are normally hashed for faster access (including insertion and deletion)."
1406 :     msgstr ""
1407 :    
1408 :     #. type: Plain text
1409 :     #: R-ints.texi:572
1410 :     msgid "By default @R{} maintains a (hashed) global cache of `variables' (that is symbols and their bindings) which have been found, and this refers only to environments which have been marked to participate, which consists of the global environment (aka the user workspace), the base environment plus environments@footnote{Remember that attaching a list or a saved image actually creates and populates an environment and attaches that.} which have been @code{attach}ed. When an environment is either @code{attach}ed or @code{detach}ed, the names of its symbols are flushed from the cache. The cache is used whenever searching for variables from the global environment (possibly as part of a recursive search)."
1411 :     msgstr ""
1412 :    
1413 :     #. type: node
1414 :     #: R-ints.texi:577
1415 :     #: R-ints.texi:579
1416 :     #: R-ints.texi:580
1417 :     #: R-ints.texi:608
1418 :     #, no-wrap
1419 :     msgid "Search paths"
1420 :     msgstr ""
1421 :    
1422 :     #. type: node
1423 :     #: R-ints.texi:577
1424 :     #: R-ints.texi:579
1425 :     #: R-ints.texi:608
1426 :     #: R-ints.texi:609
1427 :     #: R-ints.texi:641
1428 :     #, no-wrap
1429 :     msgid "Namespaces"
1430 :     msgstr ""
1431 :    
1432 :     #. type: subsection
1433 :     #: R-ints.texi:577
1434 :     #: R-ints.texi:608
1435 :     #: R-ints.texi:641
1436 :     #: R-ints.texi:642
1437 :     #, no-wrap
1438 :     msgid "Hash table"
1439 :     msgstr ""
1440 :    
1441 :     #. type: cindex
1442 :     #: R-ints.texi:582
1443 :     #, no-wrap
1444 :     msgid "search path"
1445 :     msgstr ""
1446 :    
1447 :     #. type: Plain text
1448 :     #: R-ints.texi:589
1449 :     msgid "@Sl{} has the notion of a `search path': the lookup for a `variable' leads (possibly through a series of frames) to the `session frame' the `working directory' and then along the search path. The search path is a series of databases (as returned by @code{search()}) which contain the system functions (but not necessarily at the end of the path, as by default the equivalent of packages are added at the end)."
1450 :     msgstr ""
1451 :    
1452 :     #. type: Plain text
1453 :     #: R-ints.texi:596
1454 :     msgid "@R{} has a variant on the @Sl{} model. There is a search path (also returned by @code{search()}) which consists of the global environment (aka user workspace) followed by environments which have been attached and finally the base environment. Note that unlike @Sl{} it is not possible to attach environments before the workspace nor after the base environment."
1455 :     msgstr ""
1456 :    
1457 :     #. type: Plain text
1458 :     #: R-ints.texi:607
1459 :     msgid "However, the notion of variable lookup is more general in @R{}, hence the plural in the title of this subsection. Since environments have enclosures, from any environment there is a search path found by looking in the frame, then the frame of its enclosure and so on. Since loops are not allowed, this process will eventually terminate: it can terminate at either the base environment or the empty environment. (It can be conceptually simpler to think of the search always terminating at the empty environment, but with an optimization to stop at the base environment.) So the `search path' describes the chain of environments which is traversed once the search reaches the global environment."
1460 :     msgstr ""
1461 :    
1462 :     #. type: cindex
1463 :     #: R-ints.texi:611
1464 :     #, no-wrap
1465 :     msgid "namespace"
1466 :     msgstr ""
1467 :    
1468 :     #. type: Plain text
1469 :     #: R-ints.texi:618
1470 :     msgid "Namespaces are environments associated with packages (and once again the base package is special and will be considered separately). A package @code{@var{pkg}} with a namespace defines two environments @code{namespace:@var{pkg}} and @code{package:@var{pkg}}: it is @code{package:@var{pkg}} that can be @code{attach}ed and form part of the search path."
1471 :     msgstr ""
1472 :    
1473 :     #. type: Plain text
1474 :     #: R-ints.texi:630
1475 :     msgid "The objects defined by the @R{} code in the package are symbols with bindings in the @code{namespace:@var{pkg}} environment. The @code{package:@var{pkg}} environment is populated by selected symbols from the @code{namespace:@var{pkg}} environment (the exports). The enclosure of this environment is an environment populated with the explicit imports from other namespaces, and the enclosure of @emph{that} environment is the base namespace. (So the illusion of the imports being in the namespace environment is created via the environment tree.) The enclosure of the base namespace is the global environment, so the search from a package namespace goes via the (explicit and implicit) imports to the standard `search path'."
1476 :     msgstr ""
1477 :    
1478 :     #. type: cindex
1479 :     #: R-ints.texi:631
1480 :     #, no-wrap
1481 :     msgid "base namespace"
1482 :     msgstr ""
1483 :    
1484 :     #. type: cindex
1485 :     #: R-ints.texi:632
1486 :     #, no-wrap
1487 :     msgid "namespace, base"
1488 :     msgstr ""
1489 :    
1490 :     #. type: findex
1491 :     #: R-ints.texi:633
1492 :     #, no-wrap
1493 :     msgid "R_BaseNamespace"
1494 :     msgstr ""
1495 :    
1496 :     #. type: Plain text
1497 :     #: R-ints.texi:640
1498 :     msgid "The base namespace environment @code{R_BaseNamespace} is another @code{ENVSXP} that is special-cased. It is effectively the same thing as the base environment @code{R_BaseEnv} @emph{except} that its enclosure is the global environment rather than the empty environment: the internal code diverts lookups in its frame to the global symbol table."
1499 :     msgstr ""
1500 :    
1501 :     #. type: Plain text
1502 :     #: R-ints.texi:651
1503 :     msgid "Environments in @R{} usually have a hash table, and nowadays that is the default in @code{new.env()}. It is stored as a @code{VECSXP} where @code{length} is used for the allocated size of the table and @code{truelength} is the number of primary slots in use---the pointer to the @code{VECSXP} is part of the header of a @code{SEXP} of type @code{ENVSXP}, and this points to @code{R_NilValue} if the environment is not hashed."
1504 :     msgstr ""
1505 :    
1506 :     #. type: Plain text
1507 :     #: R-ints.texi:653
1508 :     msgid "For the pros and cons of hashing, see a basic text on Computer Science."
1509 :     msgstr ""
1510 :    
1511 :     #. type: Plain text
1512 :     #: R-ints.texi:659
1513 :     msgid "The code to implement hashed environments is in @file{src/main/envir.c}. Unless set otherwise (e.g.@: by the @code{size} argument of @code{new.env()}) the initial table size is @code{29}. The table will be resized by a factor of 1.2 once the load factor (the proportion of primary slots in use) reaches 85%."
1514 :     msgstr ""
1515 :    
1516 :     #. type: Plain text
1517 :     #: R-ints.texi:665
1518 :     msgid "The hash chains are stored as pairlist elements of the @code{VECSXP}: items are inserted at the front of the pairlist. Hashing is principally designed for fast searching of environments, which are from time to time added to but rarely deleted from, so items are not actually deleted but have their value set to @code{R_UnboundValue}."
1519 :     msgstr ""
1520 :    
1521 :     #. type: cindex
1522 :     #: R-ints.texi:670
1523 :     #, no-wrap
1524 :     msgid "attributes"
1525 :     msgstr ""
1526 :    
1527 :     #. type: findex
1528 :     #: R-ints.texi:671
1529 :     #, no-wrap
1530 :     msgid "ATTRIB"
1531 :     msgstr ""
1532 :    
1533 :     #. type: findex
1534 :     #: R-ints.texi:672
1535 :     #, no-wrap
1536 :     msgid "SET_ATTRIB"
1537 :     msgstr ""
1538 :    
1539 :     #. type: findex
1540 :     #: R-ints.texi:673
1541 :     #, no-wrap
1542 :     msgid "DUPLICATE_ATTRIB"
1543 :     msgstr ""
1544 :    
1545 :     #. type: Plain text
1546 :     #: R-ints.texi:685
1547 :     msgid "As we have seen, every @code{SEXPREC} has a pointer to the attributes of the node (default @code{R_NilValue}). The attributes can be accessed/set by the macros/functions @code{ATTRIB} and @code{SET_ATTRIB}, but such direct access is normally only used to check if the attributes are @code{NULL} or to reset them. Otherwise access goes through the functions @code{getAttrib} and @code{setAttrib} which impose restrictions on the attributes. One thing to watch is that if you copy attributes from one object to another you may (un)set the @code{\"class\"} attribute and so need to copy the object and S4 bits as well. There is a macro/function @code{DUPLICATE_ATTRIB} to automate this."
1548 :     msgstr ""
1549 :    
1550 :     #. type: Plain text
1551 :     #: R-ints.texi:689
1552 :     msgid "Note that the `attributes' of a @code{CHARSXP} are used as part of the management of the @code{CHARSXP} cache: of course @code{CHARSXP}'s are not user-visible but C-level code might look at their attributes."
1553 :     msgstr ""
1554 :    
1555 :     #. type: Plain text
1556 :     #: R-ints.texi:701
1557 :     msgid "The code assumes that the attributes of a node are either @code{R_NilValue} or a pairlist of non-zero length (and this is checked by @code{SET_ATTRIB}). The attributes are named (via tags on the pairlist). The replacement function @code{attributes<-} ensures that @code{\"dim\"} precedes @code{\"dimnames\"} in the pairlist. Attribute @code{\"dim\"} is one of several that is treated specially: the values are checked, and any @code{\"names\"} and @code{\"dimnames\"} attributes are removed. Similarly, you cannot set @code{\"dimnames\"} without having set @code{\"dim\"}, and the value assigned must be a list of the correct length and with elements of the correct lengths (and all zero-length elements are replaced by @code{NULL})."
1558 :     msgstr ""
1559 :    
1560 :     #. type: Plain text
1561 :     #: R-ints.texi:715
1562 :     msgid "The other attributes which are given special treatment are @code{\"names\"}, @code{\"class\"}, @code{\"tsp\"}, @code{\"comment\"} and @code{\"row.names\"}. For pairlist-like objects the names are not stored as an attribute but (as symbols) as the tags: however the @R{} interface makes them look like conventional attributes, and for one-dimensional arrays they are stored as the first element of the @code{\"dimnames\"} attribute. The C code ensures that the @code{\"tsp\"} attribute is an @code{REALSXP}, the frequency is positive and the implied length agrees with the number of rows of the object being assigned to. Classes and comments are restricted to character vectors, and assigning a zero-length comment or class removes the attribute. Setting or removing a @code{\"class\"} attribute sets the object bit appropriately. Integer row names are converted to and from the internal compact representation."
1563 :     msgstr ""
1564 :    
1565 :     #. type: Plain text
1566 :     #: R-ints.texi:725
1567 :     msgid "Care needs to be taken when adding attributes to objects of the types with non-standard copying semantics. There is only one object of type @code{NILSXP}, @code{R_NilValue}, and that should never have attributes (and this is enforced in @code{installAttrib}). For environments, external pointers and weak references, the attributes should be relevant to all uses of the object: it is for example reasonable to have a name for an environment, and also a @code{\"path\"} attribute for those environments populated from @R{} code in a package."
1568 :     msgstr ""
1569 :    
1570 :     #. type: cindex
1571 :     #: R-ints.texi:726
1572 :     #, no-wrap
1573 :     msgid "attributes, preserving"
1574 :     msgstr ""
1575 :    
1576 :     #. type: cindex
1577 :     #: R-ints.texi:727
1578 :     #, no-wrap
1579 :     msgid "preserving attributes"
1580 :     msgstr ""
1581 :    
1582 :     #. type: Plain text
1583 :     #: R-ints.texi:734
1584 :     msgid "When should attributes be preserved under operations on an object? Becker, Chambers & Wilks (1988, pp. 144--6) give some guidance. Scalar functions (those which operate element-by-element on a vector and whose output is similar to the input) should preserve attributes (except perhaps class, and if they do preserve class they need to preserve the @code{OBJECT} and S4 bits). Binary operations normally call"
1585 :     msgstr ""
1586 :    
1587 :     #. type: findex
1588 :     #: R-ints.texi:734
1589 :     #, no-wrap
1590 :     msgid "copyMostAttributes"
1591 :     msgstr ""
1592 :    
1593 :     #. type: Plain text
1594 :     #: R-ints.texi:740
1595 :     msgid "@code{copyMostAttributes} to copy most attributes from the longer argument (and if they are of the same length from both, preferring the values on the first). Here `most' means all except the @code{names}, @code{dim} and @code{dimnames} which are set appropriately by the code for the operator."
1596 :     msgstr ""
1597 :    
1598 :     #. type: Plain text
1599 :     #: R-ints.texi:746
1600 :     msgid "Subsetting (other than by an empty index) generally drops all attributes except @code{names}, @code{dim} and @code{dimnames} which are reset as appropriate. On the other hand, subassignment generally preserves such attributes even if the length is changed. Coercion drops all attributes. For example:"
1601 :     msgstr ""
1602 :    
1603 :     #. type: example
1604 :     #: R-ints.texi:769
1605 :     #, no-wrap
1606 :     msgid ""
1607 :     "> x <- structure(1:8, names=letters[1:8], comm=\"a comment\")\n"
1608 :     "> x[]\n"
1609 :     "a b c d e f g h\n"
1610 :     "1 2 3 4 5 6 7 8\n"
1611 :     "attr(,\"comm\")\n"
1612 :     "[1] \"a comment\"\n"
1613 :     "> x[1:3]\n"
1614 :     "a b c\n"
1615 :     "1 2 3\n"
1616 :     "> x[3] <- 3\n"
1617 :     "> x\n"
1618 :     "a b c d e f g h\n"
1619 :     "1 2 3 4 5 6 7 8\n"
1620 :     "attr(,\"comm\")\n"
1621 :     "[1] \"a comment\"\n"
1622 :     "> x[9] <- 9\n"
1623 :     "> x\n"
1624 :     "a b c d e f g h\n"
1625 :     "1 2 3 4 5 6 7 8 9\n"
1626 :     "attr(,\"comm\")\n"
1627 :     "[1] \"a comment\"\n"
1628 :     msgstr ""
1629 :    
1630 :     #. type: cindex
1631 :     #: R-ints.texi:775
1632 :     #, no-wrap
1633 :     msgid "context"
1634 :     msgstr ""
1635 :    
1636 :     #. type: Plain text
1637 :     #: R-ints.texi:781
1638 :     msgid "@emph{Contexts} are the internal mechanism used to keep track of where a computation has got to (and from where), so that control-flow constructs can work and reasonable information can be produced on error conditions (such as @emph{via} traceback), and otherwise (the @code{sys.@var{xxx}} functions)."
1639 :     msgstr ""
1640 :    
1641 :     #. type: Plain text
1642 :     #: R-ints.texi:783
1643 :     msgid "Execution contexts are a stack of C @code{structs}:"
1644 :     msgstr ""
1645 :    
1646 :     #. type: example
1647 :     #: R-ints.texi:805
1648 :     #, no-wrap
1649 :     msgid ""
1650 :     "typedef struct RCNTXT @{\n"
1651 :     " struct RCNTXT *nextcontext; /* @r{The next context up the chain} */\n"
1652 :     " int callflag; /* @r{The context `type'} */\n"
1653 :     " JMP_BUF cjmpbuf; /* @r{C stack and register information} */\n"
1654 :     " int cstacktop; /* @r{Top of the pointer protection stack} */\n"
1655 :     " int evaldepth; /* @r{Evaluation depth at inception} */\n"
1656 :     " SEXP promargs; /* @r{Promises supplied to closure} */\n"
1657 :     " SEXP callfun; /* @r{The closure called} */\n"
1658 :     " SEXP sysparent; /* @r{Environment the closure was called from} */\n"
1659 :     " SEXP call; /* @r{The call that effected this context} */\n"
1660 :     " SEXP cloenv; /* @r{The environment} */\n"
1661 :     " SEXP conexit; /* @r{Interpreted @code{on.exit} code} */\n"
1662 :     " void (*cend)(void *); /* @r{C @code{on.exit} thunk} */\n"
1663 :     " void *cenddata; /* @r{Data for C @code{on.exit} thunk} */\n"
1664 :     " char *vmax; /* @r{Top of the @code{R_alloc} stack} */\n"
1665 :     " int intsusp; /* @r{Interrupts are suspended} */\n"
1666 :     " SEXP handlerstack; /* @r{Condition handler stack} */\n"
1667 :     " SEXP restartstack; /* @r{Stack of available restarts} */\n"
1668 :     " struct RPRSTACK *prstack; /* @r{Stack of pending promises} */\n"
1669 :     "@} RCNTXT, *context;\n"
1670 :     msgstr ""
1671 :    
1672 :     #. type: Plain text
1673 :     #: R-ints.texi:810
1674 :     msgid "plus additional fields for the byte-code compiler. The `types' are from"
1675 :     msgstr ""
1676 :    
1677 :     #. type: example
1678 :     #: R-ints.texi:825
1679 :     #, no-wrap
1680 :     msgid ""
1681 :     "enum @{\n"
1682 :     " CTXT_TOPLEVEL = 0, /* @r{toplevel context} */\n"
1683 :     " CTXT_NEXT = 1, /* @r{target for @code{next}} */\n"
1684 :     " CTXT_BREAK = 2, /* @r{target for @code{break}} */\n"
1685 :     " CTXT_LOOP = 3, /* @r{@code{break} or @code{next} target} */\n"
1686 :     " CTXT_FUNCTION = 4, /* @r{function closure} */\n"
1687 :     " CTXT_CCODE = 8, /* @r{other functions that need error cleanup} */\n"
1688 :     " CTXT_RETURN = 12, /* @r{@code{return()} from a closure} */\n"
1689 :     " CTXT_BROWSER = 16, /* @r{return target on exit from browser} */\n"
1690 :     " CTXT_GENERIC = 20, /* @r{rather, running an S3 method} */\n"
1691 :     " CTXT_RESTART = 32, /* @r{a call to @code{restart} was made from a closure} */\n"
1692 :     " CTXT_BUILTIN = 64 /* @r{builtin internal function} */\n"
1693 :     "@};\n"
1694 :     msgstr ""
1695 :    
1696 :     #. type: Plain text
1697 :     #: R-ints.texi:830
1698 :     msgid "where the @code{CTXT_FUNCTION} bit is on wherever function closures are involved."
1699 :     msgstr ""
1700 :    
1701 :     #. type: Plain text
1702 :     #: R-ints.texi:837
1703 :     msgid "Contexts are created by a call to @code{begincontext} and ended by a call to @code{endcontext}: code can search up the stack for a particular type of context via @code{findcontext} (and jump there) or jump to a specific context via @code{R_JumpToContext}. @code{R_ToplevelContext} is the `idle' state (normally the command prompt), and @code{R_GlobalContext} is the top of the stack."
1704 :     msgstr ""
1705 :    
1706 :     #. type: Plain text
1707 :     #: R-ints.texi:840
1708 :     msgid "Note that whilst calls to closures and builtins set a context, those to special internal functions never do."
1709 :     msgstr ""
1710 :    
1711 :     #. type: findex
1712 :     #: R-ints.texi:841
1713 :     #, no-wrap
1714 :     msgid "UseMethod"
1715 :     msgstr ""
1716 :    
1717 :     #. type: cindex
1718 :     #: R-ints.texi:842
1719 :     #, no-wrap
1720 :     msgid "method dispatch"
1721 :     msgstr ""
1722 :    
1723 :     #. type: Plain text
1724 :     #: R-ints.texi:848
1725 :     msgid "Dispatching from a S3 generic (via @code{UseMethod} or its internal equivalent) or calling @code{NextMethod} sets the context type to @code{CTXT_GENERIC}. This is used to set the @code{sysparent} of the method call to that of the @code{generic}, so the method appears to have been called in place of the generic rather than from the generic."
1726 :     msgstr ""
1727 :    
1728 :     #. type: Plain text
1729 :     #: R-ints.texi:852
1730 :     msgid "The @R{} @code{sys.frame} and @code{sys.call} functions work by counting calls to closures (type @code{CTXT_FUNCTION}) from either end of the context stack."
1731 :     msgstr ""
1732 :    
1733 :     #. type: Plain text
1734 :     #: R-ints.texi:857
1735 :     msgid "Note that the @code{sysparent} element of the structure is not the same thing as @code{sys.parent()}. Element @code{sysparent} is primarily used in managing changes of the function being evaluated, i.e. by @code{Recall} and method dispatch."
1736 :     msgstr ""
1737 :    
1738 :     #. type: Plain text
1739 :     #: R-ints.texi:863
1740 :     msgid "@code{CTXT_CCODE} contexts are currently used in @code{cat()}, @code{load()}, @code{scan()} and @code{write.table()} (to close the connection on error), by @code{PROTECT}, serialization (to recover from errors, e.g.@: free buffers) and within the error handling code (to raise the C stack limit and reset some variables)."
1741 :     msgstr ""
1742 :    
1743 :     #. type: cindex
1744 :     #: R-ints.texi:868
1745 :     #, no-wrap
1746 :     msgid "argument evaluation"
1747 :     msgstr ""
1748 :    
1749 :     #. type: Plain text
1750 :     #: R-ints.texi:875
1751 :     msgid "As we have seen, functions in @R{} come in three types, closures (@code{SEXPTYPE} @code{CLOSXP}), specials (@code{SPECIALSXP}) and builtins (@code{BUILTINSXP}). In this section we consider when (and if) the actual arguments of function calls are evaluated. The rules are different for the internal (special/builtin) and @R{}-level functions (closures)."
1752 :     msgstr ""
1753 :    
1754 :     #. type: Plain text
1755 :     #: R-ints.texi:886
1756 :     msgid "For a call to a closure, the actual and formal arguments are matched and a matched call (another @code{LANGSXP}) is constructed. This process first replaces the actual argument list by a list of promises to the values supplied. It then constructs a new environment which contains the names of the formal parameters matched to actual or default values: all the matched values are promises, the defaults as promises to be evaluated in the environment just created. That environment is then used for the evaluation of the body of the function, and promises will be forced (and hence actual or default arguments evaluated) when they are encountered."
1757 :     msgstr ""
1758 :    
1759 :     #. type: Plain text
1760 :     #: R-ints.texi:890
1761 :     msgid "(Evaluating a promise sets @code{NAMED = 2} on its value, so if the argument was a symbol its binding is regarded as having multiple references during the evaluation of the closure call.)"
1762 :     msgstr ""
1763 :    
1764 :     #. type: Plain text
1765 :     #: R-ints.texi:906
1766 :     msgid "If the closure is an S3 generic (that is, contains a call to @code{UseMethod}) the evaluation process is the same until the @code{UseMethod} call is encountered. At that point the argument on which to do dispatch (normally the first) will be evaluated if it has not been already. If a method has been found which is a closure, a new evaluation environment is created for it containing the matched arguments of the method plus any new variables defined so far during the evaluation of the body of the generic. (Note that this means changes to the values of the formal arguments in the body of the generic are discarded when calling the method, but @emph{actual} argument promises which have been forced retain the values found when they were forced. On the other hand, missing arguments have values which are promises to use the default supplied by the method and not by the generic.) If the method found is a primitive it is called with the matched argument list of promises (possibly already forced) used for the generic."
1767 :     msgstr ""
1768 :    
1769 :     #. type: cindex
1770 :     #: R-ints.texi:907
1771 :     #, no-wrap
1772 :     msgid "builtin function"
1773 :     msgstr ""
1774 :    
1775 :     #. type: cindex
1776 :     #: R-ints.texi:908
1777 :     #, no-wrap
1778 :     msgid "special function"
1779 :     msgstr ""
1780 :    
1781 :     #. type: cindex
1782 :     #: R-ints.texi:909
1783 :     #, no-wrap
1784 :     msgid "primitive function"
1785 :     msgstr ""
1786 :    
1787 :     #. type: cindex
1788 :     #: R-ints.texi:910
1789 :     #, no-wrap
1790 :     msgid ".Internal function"
1791 :     msgstr ""
1792 :    
1793 :     #. type: Plain text
1794 :     #: R-ints.texi:919
1795 :     msgid "The essential difference@footnote{There is currently one other difference: when profiling builtin functions are counted as function calls but specials are not.} between special and builtin functions is that the arguments of specials are not evaluated before the C code is called, and those of builtins are. Note that being a special/builtin is separate from being primitive or @code{.Internal}: @code{quote} is a special primitive, @code{+} is a builtin primitive, @code{cbind} is a special @code{.Internal} and @code{grep} is a builtin @code{.Internal}."
1796 :     msgstr ""
1797 :    
1798 :     #. type: cindex
1799 :     #: R-ints.texi:920
1800 :     #, no-wrap
1801 :     msgid "generic, internal"
1802 :     msgstr ""
1803 :    
1804 :     #. type: findex
1805 :     #: R-ints.texi:921
1806 :     #, no-wrap
1807 :     msgid "DispatchOrEval"
1808 :     msgstr ""
1809 :    
1810 :     #. type: Plain text
1811 :     #: R-ints.texi:931
1812 :     msgid "Many of the internal functions are internal generics, which for specials means that they do not evaluate their arguments on call, but the C code starts with a call to @code{DispatchOrEval}. The latter evaluates the first argument, and looks for a method based on its class. (If S4 dispatch is on, S4 methods are looked for first, even for S3 classes.) If it finds a method, it dispatches to that method with a call based on promises to evaluate the remaining arguments. If no method is found, the remaining arguments are evaluated before return to the internal generic."
1813 :     msgstr ""
1814 :    
1815 :     #. type: cindex
1816 :     #: R-ints.texi:932
1817 :     #, no-wrap
1818 :     msgid "generic, generic"
1819 :     msgstr ""
1820 :    
1821 :     #. type: findex
1822 :     #: R-ints.texi:933
1823 :     #, no-wrap
1824 :     msgid "DispatchGeneric"
1825 :     msgstr ""
1826 :    
1827 :     #. type: Plain text
1828 :     #: R-ints.texi:942
1829 :     msgid "The other way that internal functions can be generic is to be group generic. Most such functions are builtins (so immediately evaluate all their arguments), and all contain a call to the C function @code{DispatchGeneric}. There are some peculiarities over the number of arguments for the @code{\"Math\"} group generic, with some members allowing only one argument, some having two (with a default for the second) and @code{trunc} allows one or more but the default method only accepts one."
1830 :     msgstr ""
1831 :    
1832 :     #. type: node
1833 :     #: R-ints.texi:946
1834 :     #: R-ints.texi:948
1835 :     #: R-ints.texi:949
1836 :     #: R-ints.texi:993
1837 :     #, no-wrap
1838 :     msgid "Missingness"
1839 :     msgstr ""
1840 :    
1841 :     #. type: subsection
1842 :     #: R-ints.texi:946
1843 :     #: R-ints.texi:948
1844 :     #: R-ints.texi:993
1845 :     #: R-ints.texi:994
1846 :     #, no-wrap
1847 :     msgid "Dot-dot-dot arguments"
1848 :     msgstr ""
1849 :    
1850 :     #. type: cindex
1851 :     #: R-ints.texi:951
1852 :     #, no-wrap
1853 :     msgid "missingness"
1854 :     msgstr ""
1855 :    
1856 :     #. type: Plain text
1857 :     #: R-ints.texi:958
1858 :     msgid "Actual arguments to (non-internal) @R{} functions can be fewer than are required to match the formal arguments of the function. Having unmatched formal arguments will not matter if the argument is never used (by lazy evaluation), but when the argument is evaluated, either its default value is evaluated (within the evaluation environment of the function) or an error is thrown with a message along the lines of"
1859 :     msgstr ""
1860 :    
1861 :     #. type: example
1862 :     #: R-ints.texi:961
1863 :     #, no-wrap
1864 :     msgid "argument \"foobar\" is missing, with no default\n"
1865 :     msgstr ""
1866 :    
1867 :     #. type: findex
1868 :     #: R-ints.texi:964
1869 :     #, no-wrap
1870 :     msgid "R_MissingArg"
1871 :     msgstr ""
1872 :    
1873 :     #. type: Plain text
1874 :     #: R-ints.texi:974
1875 :     msgid "Internally missingness is handled by two mechanisms. The object @code{R_MissingArg} is used to indicate that a formal argument has no (default) value. When matching the actual arguments to the formal arguments, a new argument list is constructed from the formals all of whose values are @code{R_MissingArg} with the first @code{MISSING} bit set. Then whenever a formal argument is matched to an actual argument, the corresponding member of the new argument list has its value set to that of the matched actual argument, and if that is not @code{R_MissingArg} the missing bit is unset."
1876 :     msgstr ""
1877 :    
1878 :     #. type: Plain text
1879 :     #: R-ints.texi:978
1880 :     msgid "This new argument list is used to form the evaluation frame for the function, and if named arguments are subsequently given a new value (before they are evaluated) the missing bit is cleared."
1881 :     msgstr ""
1882 :    
1883 :     #. type: Plain text
1884 :     #: R-ints.texi:987
1885 :     msgid "Missingness of arguments can be interrogated via the @code{missing()} function. An argument is clearly missing if its missing bit is set or if the value is @code{R_MissingArg}. However, missingness can be passed on from function to function, for using a formal argument as an actual argument in a function call does not count as evaluation. So @code{missing()} has to examine the value (a promise) of a non-yet-evaluated formal argument to see if it might be missing, which might involve investigating a promise and so on @dots{}."
1886 :     msgstr ""
1887 :    
1888 :     #. type: Plain text
1889 :     #: R-ints.texi:992
1890 :     msgid "Special primitives also need to handle missing arguments, and in some case (e.g.@: @code{log}) that is why they are special and not builtin. This is usually done by testing if an argument's value is @code{R_MissingArg}."
1891 :     msgstr ""
1892 :    
1893 :     #. type: Plain text
1894 :     #: R-ints.texi:999
1895 :     msgid "Dot-dot-dot arguments are convenient when writing functions, but complicate the internal code for argument evaluation."
1896 :     msgstr ""
1897 :    
1898 :     #. type: Plain text
1899 :     #: R-ints.texi:1006
1900 :     msgid "The formals of a function with a @code{...} argument represent that as a single argument like any other argument, with tag the symbol @code{R_DotsSymbol}. When the actual arguments are matched to the formals, the value of the @code{...} argument is of @code{SEXPTYPE} @code{DOTSXP}, a pairlist of promises (as used for matched arguments) but distinguished by the @code{SEXPTYPE}."
1901 :     msgstr ""
1902 :    
1903 :     #. type: Plain text
1904 :     #: R-ints.texi:1014
1905 :     msgid "Recall that the evaluation frame for a function initially contains the @code{@var{name}=@var{value}} pairs from the matched call, and hence this will be true for @code{...} as well. The value of @code{...} is a (special) pairlist whose elements are referred to by the special symbols @code{..1}, @code{..2}, @dots{} which have the @code{DDVAL} bit set: when one of these is encountered it is looked up (via @code{ddfindVar}) in the value of the @code{...} symbol in the evaluation frame."
1906 :     msgstr ""
1907 :    
1908 :     #. type: Plain text
1909 :     #: R-ints.texi:1016
1910 :     msgid "Values of arguments matched to a @code{...} argument can be missing."
1911 :     msgstr ""
1912 :    
1913 :     #. type: Plain text
1914 :     #: R-ints.texi:1020
1915 :     msgid "Special primitives may need to handle @code{...} arguments: see for example the internal code of @code{switch} in file @file{src/main/builtin.c}."
1916 :     msgstr ""
1917 :    
1918 :     #. type: cindex
1919 :     #: R-ints.texi:1024
1920 :     #, no-wrap
1921 :     msgid "autoprinting"
1922 :     msgstr ""
1923 :    
1924 :     #. type: findex
1925 :     #: R-ints.texi:1025
1926 :     #, no-wrap
1927 :     msgid "R_Visible"
1928 :     msgstr ""
1929 :    
1930 :     #. type: Plain text
1931 :     #: R-ints.texi:1033
1932 :     msgid "Whether the returned value of a top-level @R{} expression is printed is controlled by the global boolean variable @code{R_Visible}. This is set (to true or false) on entry to all primitive and internal functions based on the @code{eval} column of the table in file @file{src/main/names.c}: the appropriate setting can be extracted by the macro @code{PRIMPRINT}."
1933 :     msgstr ""
1934 :    
1935 :     #. type: findex
1936 :     #: R-ints.texi:1033
1937 :     #, no-wrap
1938 :     msgid "PRIMPRINT"
1939 :     msgstr ""
1940 :    
1941 :     #. type: findex
1942 :     #: R-ints.texi:1035
1943 :     #, no-wrap
1944 :     msgid "invisible"
1945 :     msgstr ""
1946 :    
1947 :     #. type: Plain text
1948 :     #: R-ints.texi:1039
1949 :     msgid "The @R{} primitive function @code{invisible} makes use of this mechanism: it just sets @code{R_Visible = FALSE} before entry and returns its argument."
1950 :     msgstr ""
1951 :    
1952 :     #. type: Plain text
1953 :     #: R-ints.texi:1051
1954 :     msgid "For most functions the intention will be that the setting of @code{R_Visible} when they are entered is the setting used when they return, but there need to be exceptions. The @R{} functions @code{identify}, @code{options}, @code{system} and @code{writeBin} determine whether the result should be visible from the arguments or user action. Other functions themselves dispatch functions which may change the visibility flag: examples@footnote{the other current example is left brace, which is implemented as a primitive.} are @code{.Internal}, @code{do.call}, @code{eval}, @code{withVisible}, @code{if}, @code{NextMethod}, @code{Recall}, @code{recordGraphics}, @code{standardGeneric}, @code{switch} and @code{UseMethod}."
1955 :     msgstr ""
1956 :    
1957 :     #. type: Plain text
1958 :     #: R-ints.texi:1056
1959 :     msgid "`Special' primitive and internal functions evaluate their arguments internally @emph{after} @code{R_Visible} has been set, and evaluation of the arguments (e.g.@: an assignment as in PR#9263)) can change the value of the flag."
1960 :     msgstr ""
1961 :    
1962 :     #. type: Plain text
1963 :     #: R-ints.texi:1066
1964 :     msgid "The @code{R_Visible} flag can also get altered during the evaluation of a function, with comments in the code about @code{warning}, @code{writeChar} and graphics functions calling @code{GText} (PR#7397). (Since the C-level function @code{eval} sets @code{R_Visible}, this could apply to any function calling it. Since it is called when evaluating promises, even object lookup can change @code{R_Visible}.) Internal and primitive functions force the documented setting of @code{R_Visible} on return, unless the C code is allowed to change it (the exceptions above are indicated by @code{PRIMPRINT} having value 2)."
1965 :     msgstr ""
1966 :    
1967 :     #. type: Plain text
1968 :     #: R-ints.texi:1074
1969 :     msgid "The actual autoprinting is done by @code{PrintValueEnv} in file @file{print.c}. If the object to be printed has the S4 bit set and S4 methods dispatch is on, @code{show} is called to print the object. Otherwise, if the object bit is set (so the object has a @code{\"class\"} attribute), @code{print} is called to dispatch methods: for objects without a class the internal code of @code{print.default} is called."
1970 :     msgstr ""
1971 :    
1972 :     #. type: section
1973 :     #: R-ints.texi:1077
1974 :     #, no-wrap
1975 :     msgid "The write barrier and the garbage collector"
1976 :     msgstr ""
1977 :    
1978 :     #. type: cindex
1979 :     #: R-ints.texi:1079
1980 :     #, no-wrap
1981 :     msgid "write barrier"
1982 :     msgstr ""
1983 :    
1984 :     #. type: cindex
1985 :     #: R-ints.texi:1080
1986 :     #, no-wrap
1987 :     msgid "garbage collector"
1988 :     msgstr ""
1989 :    
1990 :     #. type: Plain text
1991 :     #: R-ints.texi:1085
1992 :     msgid "@R{} has long had a generational garbage collector, and bit @code{gcgen} in the @code{sxpinfo} header is used in the implementation of this. This is used in conjunction with the @code{mark} bit to identify two previous generations."
1993 :     msgstr ""
1994 :    
1995 :     #. type: Plain text
1996 :     #: R-ints.texi:1094
1997 :     msgid "There are three levels of collections. Level 0 collects only the youngest generation, level 1 collects the two youngest generations and level 2 collects all generations. After 20 level-0 collections the next collection is at level 1, and after 5 level-1 collections at level 2. Further, if a level-@var{n} collection fails to provide 20% free space (for each of nodes and the vector heap), the next collection will be at level @var{n+1}. (The @R{}-level function @code{gc()} performs a level-2 collection.)"
1998 :     msgstr ""
1999 :    
2000 :     #. type: Plain text
2001 :     #: R-ints.texi:1104
2002 :     msgid "A generational collector needs to efficiently `age' the objects, especially list-like objects (including @code{STRSXP}s). This is done by ensuring that the elements of a list are regarded as at least as old as the list @emph{when they are assigned}. This is handled by the functions @code{SET_VECTOR_ELT} and @code{SET_STRING_ELT}, which is why they are functions and not macros. Ensuring the integrity of such operations is termed the @dfn{write barrier} and is done by making the @code{SEXP} opaque and only providing access via functions (which cannot be used as lvalues in assignments in C)."
2003 :     msgstr ""
2004 :    
2005 :     #. type: Plain text
2006 :     #: R-ints.texi:1116
2007 :     msgid "All code in @R{} extensions is by default behind the write barrier. The only way to obtain direct access to the internals of the @code{SEXPREC}s is to define @samp{USE_RINTERNALS} before including header file @file{Rinternals.h}, which is normally defined in @file{Defn.h}. To enable a check on the way that the access is used, @R{} can be compiled with flag @option{--enable-strict-barrier} which ensures that header @file{Defn.h} does not define @samp{USE_RINTERNALS} and hence that @code{SEXP} is opaque in most of @R{} itself. (There are some necessary exceptions: foremost in file @file{memory.c} where the accessor functions are defined and also in file @file{size.c} which needs access to the sizes of the internal structures.)"
2008 :     msgstr ""
2009 :    
2010 :     #. type: Plain text
2011 :     #: R-ints.texi:1120
2012 :     msgid "For background papers see @uref{http://www.stat.uiowa.edu/~luke/R/barrier.html} and @uref{http://www.stat.uiowa.edu/~luke/R/gengcnotes.html}."
2013 :     msgstr ""
2014 :    
2015 :     #. type: cindex
2016 :     #: R-ints.texi:1124
2017 :     #, no-wrap
2018 :     msgid "serialization"
2019 :     msgstr ""
2020 :    
2021 :     #. type: Plain text
2022 :     #: R-ints.texi:1134
2023 :     msgid "Serialized versions of @R{} objects are used by @code{load}/@code{save} and also at a slightly lower level by @code{saveRDS}/@code{readRDS} (and their earlier `internal' dot-name versions) and @code{serialize}/@code{unserialize}. These differ in what they serialize to (a file, a connection, a raw vector) and whether they are intended to serialize a single object or a collection of objects (typically the workspace). @code{save} writes a header at the beginning of the file (a single LF-terminated line) which the lower-level versions do not."
2024 :     msgstr ""
2025 :    
2026 :     #. type: Plain text
2027 :     #: R-ints.texi:1143
2028 :     msgid "@code{save} and @code{saveRDS} allow various forms of compression, and @command{gzip} compression is the default (except for @acronym{ASCII} saves). Compression is applied to the whole file stream, including the headers, so serialized files can be uncompressed or re-compressed by external programs. Both @code{load} and @code{readRDS} can read @command{gzip}, @command{bzip2} and @command{xz} forms of compression when reading from a file, and @command{gzip} compression when reading from a connection."
2029 :     msgstr ""
2030 :    
2031 :     #. type: Plain text
2032 :     #: R-ints.texi:1150
2033 :     msgid "@R{} has used the same serialization format since @R{} 1.4.0 in December 2001. Earlier formats are still supported via @code{load} and @code{save} but such formats are not described here. The current serialization format is called `version 2', and has been expanded in back-compatible ways since its inception, for example to support additional @code{SEXPTYPE}s."
2034 :     msgstr ""
2035 :    
2036 :     #. type: Plain text
2037 :     #: R-ints.texi:1164
2038 :     msgid "@code{save} works by writing a single-line header (typically @code{RDX2\\n} for a binary save: the only other current value is @code{RDA2\\n} for @code{save(files=TRUE)}), then creating a tagged pairlist of the objects to be saved and serializing that single object. @code{load} reads the header line, unserializes a single object (a pairlist or a vector list) and assigns the elements of the object in the specified environment. The header line serves two purposes in @R{}: it identifies the serialization format so @code{load} can switch to the appropriate reader code, and the linefeed allows the detection of files which have been subjected to a non-binary transfer which re-mapped line endings. It can also be thought of as a `magic number' in the sense used by the @command{file} program (although @R{} save files are not yet by default known to that program)."
2039 :     msgstr ""
2040 :    
2041 :     #. type: Plain text
2042 :     #: R-ints.texi:1175
2043 :     msgid "Serialization in @R{} needs to take into account that objects may contain references to environments, which then have enclosing environments and so on. (Environments recognized as package or name space environments are saved by name.) There are `reference objects' which are not duplicated on copy and should remain shared on unserialization. These are weak references, external pointers and environments other than those associated with packages, namespaces and the global environment. These are handled via a hash table, and references after the first are written out as a reference marker indexed by the table entry."
2044 :     msgstr ""
2045 :    
2046 :     #. type: Plain text
2047 :     #: R-ints.texi:1185
2048 :     msgid "Version-2 serialization first writes a header indicating the format (normally @samp{X\\n} for an XDR format binary save, but @samp{A\\n}, ASCII, and @samp{B\\n}, native word-order binary, can also occur) and then three integers giving the version of the format and two @R{} versions (packed by the @code{R_Version} macro from @file{Rversion.h}). (Unserialization interprets the two versions as the version of @R{} which wrote the file followed by the minimal version of @R{} needed to read the format.) Serialization then writes out the object recursively using function @code{WriteItem} in file @file{src/main/serialize.c}."
2049 :     msgstr ""
2050 :    
2051 :     #. type: Plain text
2052 :     #: R-ints.texi:1190
2053 :     msgid "Some objects are written as if they were @code{SEXPTYPE}s: such pseudo-@code{SEXPTYPE}s cover @code{R_NilValue}, @code{R_EmptyEnv}, @code{R_BaseEnv}, @code{R_GlobalEnv}, @code{R_UnboundValue}, @code{R_MissingArg} and @code{R_BaseNamespace}."
2054 :     msgstr ""
2055 :    
2056 :     #. type: Plain text
2057 :     #: R-ints.texi:1209
2058 :     msgid "For all @code{SEXPTYPE}s except @code{NILSXP}, @code{SYMSXP} and @code{ENVSXP} serialization starts with an integer with the @code{SEXPTYPE} in bits 0:7@footnote{only bits 0:4 are currently used for @code{SEXPTYPE}s but values 241:255 are used for pseudo-@code{SEXPTYPE}s.} followed by the object bit, two bits indicating if there are any attributes and if there is a tag (for the pairlist types), an unused bit and then the @code{gp} field@footnote{Currently the only relevant bits are 0:1, 4, 14:15.} in bits 12:27. Pairlist-like objects write their attributes (if any), tag (if any), CAR and then CDR (using tail recursion): other objects write their attributes after themselves. Atomic vector objects write their length followed by the data: generic vector-list objects write their length followed by a call to @code{WriteItem} for each element. The code for @code{CHARSXP}s special-cases @code{NA_STRING} and writes it as length @code{-1} with no data. Lengths no more than @code{2^31 - 1} are written in that way and larger lengths (which only occur on 64-bit systems) as @code{-1} followed by the upper and lower 32-bits as integers (regarded as unsigned)."
2059 :     msgstr ""
2060 :    
2061 :     #. type: Plain text
2062 :     #: R-ints.texi:1216
2063 :     msgid "Environments are treated in several ways: as we have seen, some are written as specific pseudo-@code{SEXPTYPE}s. Package and namespace environments are written with pseudo-@code{SEXPTYPE}s followed by the name. `Normal' environments are written out as @code{ENVSXP}s with an integer indicating if the environment is locked followed by the enclosure, frame, `tag' (the hash table) and attributes."
2064 :     msgstr ""
2065 :    
2066 :     #. type: Plain text
2067 :     #: R-ints.texi:1221
2068 :     msgid "In the `XDR' format integers and doubles are written in bigendian order: however the format is not fully XDR (as defined in RFC 1832) as byte quantities (such as the contents of @code{CHARSXP} and @code{RAWSXP} types) are written as-is and not padded to a multiple of four bytes."
2069 :     msgstr ""
2070 :    
2071 :     #. type: Plain text
2072 :     #: R-ints.texi:1228
2073 :     msgid "The `ASCII' format writes 7-bit characters. Integers are formatted with @code{%d} (except that @code{NA_integer_} is written as @code{NA}), doubles formatted with @code{%.16g} (plus @code{NA}, @code{Inf} and @code{-Inf}) and bytes with @code{%02x}. Strings are written using standard escapes (e.g.@: @code{\\t} and @code{\\013}) for non-printing and non-@acronym{ASCII} bytes."
2074 :     msgstr ""
2075 :    
2076 :     #. type: Plain text
2077 :     #: R-ints.texi:1233
2078 :     msgid "Character data in @R{} are stored in the sexptype @code{CHARSXP}."
2079 :     msgstr ""
2080 :    
2081 :     #. type: Plain text
2082 :     #: R-ints.texi:1245
2083 :     msgid "There is support for encodings other than that of the current locale, in particular UTF-8 and the multi-byte encodings used on Windows for CJK languages. A limited means to indicate the encoding of a @code{CHARSXP} is @emph{via} two of the `general purpose' bits which are used to declare the encoding to be either Latin-1 or UTF-8. (Note that it is possible for a character vector to contain elements in different encodings.) Both printing and plotting notice the declaration and convert the string to the current locale (possibly using @code{<xx>} to display in hexadecimal bytes that are not valid in the current locale). Many (but not all) of the character manipulation functions will either preserve the declaration or re-encode the character string."
2084 :     msgstr ""
2085 :    
2086 :     #. type: Plain text
2087 :     #: R-ints.texi:1248
2088 :     msgid "Strings that refer to the OS such as file names need to be passed through a wide-character interface on some OSes (e.g. Windows)."
2089 :     msgstr ""
2090 :    
2091 :     #. type: Plain text
2092 :     #: R-ints.texi:1255
2093 :     msgid "When are character strings declared to be of known encoding? One way is to do so directly via @code{Encoding}. The parser declares the encoding if this is known, either via the @code{encoding} argument to @code{parse} or from the locale within which parsing is being done at the @R{} command line. (Other ways are recorded on the help page for @code{Encoding}.)"
2094 :     msgstr ""
2095 :    
2096 :     #. type: Plain text
2097 :     #: R-ints.texi:1260
2098 :     msgid "It is not necessary to declare the encoding of @acronym{ASCII} strings as they will work in any locale. @acronym{ASCII} strings should never have a marked encoding, as any encoding will be ignored when entering such strings into the @code{CHARSXP} cache."
2099 :     msgstr ""
2100 :    
2101 :     #. type: Plain text
2102 :     #: R-ints.texi:1273
2103 :     msgid "The rationale behind considering only UTF-8 and Latin-1 was that most systems are capable of producing UTF-8 strings and this is the nearest we have to a universal format. For those that do not (for example those lacking a powerful enough @code{iconv}), it is likely that they work in Latin-1, the old @R{} assumption. The the parser can return a UTF-8-encoded string if it encounters a @samp{\\uxxx} escape for a Unicode point that cannot be represented in the current charset. (This needs MBCS support, and was only enabled@footnote{See define @code{USE_UTF8_IF_POSSIBLE} in file @file{src/main/gram.c}.} on Windows.) This is enabled for all platforms, and a @samp{\\uxxx} or @samp{\\Uxxxxxxxx} escape ensures that the parsed string will be marked as UTF-8."
2104 :     msgstr ""
2105 :    
2106 :     #. type: Plain text
2107 :     #: R-ints.texi:1278
2108 :     msgid "Most of the character manipulation functions now preserve UTF-8 encodings: there are some notes as to which at the top of file @file{src/main/character.c} and in file @file{src/library/base/man/Encoding.Rd}."
2109 :     msgstr ""
2110 :    
2111 :     #. type: Plain text
2112 :     #: R-ints.texi:1289
2113 :     msgid "Graphics devices are offered the possibility of handing UTF-8-encoded strings without re-encoding to the native character set, by setting @code{hasTextUTF8} to be @samp{TRUE} and supplying functions @code{textUTF8} and @code{strWidthUTF8} that expect UTF-8-encoded inputs. Normally the symbol font is encoded in Adobe Symbol encoding, but that can be re-encoded to UTF-8 by setting @code{wantSymbolUTF8} to @samp{TRUE}. The Windows' port of cairographics has a rather peculiar assumption: it wants the symbol font to be encoded in UTF-8 as if it were encoded in Latin-1 rather than Adobe Symbol: this is selected by @code{wantSymbolUTF8 = NA_LOGICAL}."
2114 :     msgstr ""
2115 :    
2116 :     #. type: Plain text
2117 :     #: R-ints.texi:1301
2118 :     msgid "Windows has no UTF-8 locales, but rather expects to work with UCS-2@footnote{or UTF-16 if support for surrogates is enabled in the OS, which it is not normally so at least for Western versions of Windows, despite some claims to the contrary on the Microsoft website.} strings. @R{} (being written in standard C) would not work internally with UCS-2 without extensive changes. The @file{Rgui} console@footnote{but not the GraphApp toolkit.} uses UCS-2 internally, but communicates with the @R{} engine in the native encoding. To allow UTF-8 strings to be printed in UTF-8 in @file{Rgui.exe}, an escape convention is used (see header file @file{rgui_UTF8.h}) which is used by @code{cat}, @code{print} and autoprinting."
2119 :     msgstr ""
2120 :    
2121 :     #. type: Plain text
2122 :     #: R-ints.texi:1306
2123 :     msgid "`Unicode' (UCS-2LE) files are common in the Windows world, and @code{readLines} and @code{scan} will read them into UTF-8 strings on Windows if the encoding is declared explicitly on an unopened connection passed to those functions."
2124 :     msgstr ""
2125 :    
2126 :     #. type: findex
2127 :     #: R-ints.texi:1310
2128 :     #, no-wrap
2129 :     msgid "mkChar"
2130 :     msgstr ""
2131 :    
2132 :     #. type: Plain text
2133 :     #: R-ints.texi:1318
2134 :     msgid "There is a global cache for @code{CHARSXP}s created by @code{mkChar} --- the cache ensures that most @code{CHARSXP}s with the same contents share storage (`contents' including any declared encoding). Not all @code{CHARSXP}s are part of the cache -- notably @samp{NA_STRING} is not. @code{CHARSXP}s reloaded from the @code{save} formats of @R{} prior to 0.99.0 are not cached (since the code used is frozen and very few examples still exist)."
2135 :     msgstr ""
2136 :    
2137 :     #. type: findex
2138 :     #: R-ints.texi:1319
2139 :     #, no-wrap
2140 :     msgid "mkCharLenCE"
2141 :     msgstr ""
2142 :    
2143 :     #. type: Plain text
2144 :     #: R-ints.texi:1324
2145 :     msgid "The cache records the encoding of the string as well as the bytes: all requests to create a @code{CHARSXP} should be @emph{via} a call to @code{mkCharLenCE}. Any encoding given in @code{mkCharLenCE} call will be ignored if the string's bytes are all @acronym{ASCII} characters."
2146 :     msgstr ""
2147 :    
2148 :     #. type: findex
2149 :     #: R-ints.texi:1329
2150 :     #, no-wrap
2151 :     msgid "warning"
2152 :     msgstr ""
2153 :    
2154 :     #. type: findex
2155 :     #: R-ints.texi:1330
2156 :     #, no-wrap
2157 :     msgid "warningcall"
2158 :     msgstr ""
2159 :    
2160 :     #. type: findex
2161 :     #: R-ints.texi:1331
2162 :     #, no-wrap
2163 :     msgid "error"
2164 :     msgstr ""
2165 :    
2166 :     #. type: findex
2167 :     #: R-ints.texi:1332
2168 :     #, no-wrap
2169 :     msgid "errorcall"
2170 :     msgstr ""
2171 :    
2172 :     #. type: Plain text
2173 :     #: R-ints.texi:1342
2174 :     msgid "Each of @code{warning} and @code{stop} have two C-level equivalents, @code{warning}, @code{warningcall}, @code{error} and @code{errorcall}. The relationship between the pairs is similar: @code{warning} tries to fathom out a suitable call, and then calls @code{warningcall} with that call as the first argument if it succeeds, and with @code{call = R_NilValue} if it does not. When @code{warningcall} is called, it includes the deparsed call in its printout unless @code{call = R_NilValue}."
2175 :     msgstr ""
2176 :    
2177 :     #. type: Plain text
2178 :     #: R-ints.texi:1354
2179 :     msgid "@code{warning} and @code{error} look at the context stack. If the topmost context is not of type @code{CTXT_BUILTIN}, it is used to provide the call, otherwise the next context provides the call. This means that when these functions are called from a primitive or @code{.Internal}, the imputed call will not be to primitive/@code{.Internal} but to the function calling the primitive/@code{.Internal} . This is exactly what one wants for a @code{.Internal}, as this will give the call to the closure wrapper. (Further, for a @code{.Internal}, the call is the argument to @code{.Internal}, and so may not correspond to any @R{} function.) However, it is unlikely to be what is needed for a primitive."
2180 :     msgstr ""
2181 :    
2182 :     #. type: Plain text
2183 :     #: R-ints.texi:1363
2184 :     msgid "The upshot is that that @code{warningcall} and @code{errorcall} should normally be used for code called from a primitive, and @code{warning} and @code{error} should be used for code called from a @code{.Internal} (and necessarily from @code{.Call}, @code{.C} and so on, where the call is not passed down). However, there are two complications. One is that code might be called from either a primitive or a @code{.Internal}, in which case probably @code{warningcall} is more appropriate. The other involves replacement functions, where the call was once of the form"
2185 :     msgstr ""
2186 :    
2187 :     #. type: example
2188 :     #: R-ints.texi:1366
2189 :     #, no-wrap
2190 :     msgid ""
2191 :     "> length(x) <- y ~ x\n"
2192 :     "Error in \"length<-\"(`*tmp*`, value = y ~ x) : invalid value\n"
2193 :     msgstr ""
2194 :    
2195 :     #. type: Plain text
2196 :     #: R-ints.texi:1373
2197 :     msgid "which is unpalatable to the end user. For replacement functions there will be a suitable context at the top of the stack, so @code{warning} should be used. (The results for @code{.Internal} replacement functions such as @code{substr<-} are not ideal.)"
2198 :     msgstr ""
2199 :    
2200 :     #. type: Plain text
2201 :     #: R-ints.texi:1382
2202 :     msgid "[This section is currently a preliminary draft and should not be taken as definitive. The description assumes that @env{R_NO_METHODS_TABLES} has not been set.]"
2203 :     msgstr ""
2204 :    
2205 :     #. type: node
2206 :     #: R-ints.texi:1388
2207 :     #: R-ints.texi:1390
2208 :     #: R-ints.texi:1391
2209 :     #: R-ints.texi:1411
2210 :     #, no-wrap
2211 :     msgid "Representation of S4 objects"
2212 :     msgstr ""
2213 :    
2214 :     #. type: node
2215 :     #: R-ints.texi:1388
2216 :     #: R-ints.texi:1390
2217 :     #: R-ints.texi:1411
2218 :     #: R-ints.texi:1412
2219 :     #: R-ints.texi:1428
2220 :     #, no-wrap
2221 :     msgid "S4 classes"
2222 :     msgstr ""
2223 :    
2224 :     #. type: node
2225 :     #: R-ints.texi:1388
2226 :     #: R-ints.texi:1411
2227 :     #: R-ints.texi:1428
2228 :     #: R-ints.texi:1429
2229 :     #: R-ints.texi:1479
2230 :     #, no-wrap
2231 :     msgid "S4 methods"
2232 :     msgstr ""
2233 :    
2234 :     #. type: subsection
2235 :     #: R-ints.texi:1388
2236 :     #: R-ints.texi:1428
2237 :     #: R-ints.texi:1479
2238 :     #: R-ints.texi:1480
2239 :     #, no-wrap
2240 :     msgid "Mechanics of S4 dispatch"
2241 :     msgstr ""
2242 :    
2243 :     #. type: Plain text
2244 :     #: R-ints.texi:1398
2245 :     msgid "S4 objects can be of any @code{SEXPTYPE}. They are either an object of a simple type (such as an atomic vector or function) with S4 class information or of type @code{S4SXP}. In all cases, the `S4 bit' (bit 4 of the `general purpose' field) is set, and can be tested by the macro/function @code{IS_S4_OBJECT}."
2246 :     msgstr ""
2247 :    
2248 :     #. type: Plain text
2249 :     #: R-ints.texi:1407
2250 :     msgid "S4 objects are created via @code{new()}@footnote{This can also create non-S4 objects, as in @code{new(\"integer\")}.} and thence via the C function @code{R_do_new_object}. This duplicates the prototype of the class, adds a class attribute and sets the S4 bit. All S4 class attributes should be character vectors of length one with an attribute giving (as a character string) the name of the package (or @code{.GlobalEnv}) containing the class definition. Since S4 objects have a class attribute, the @code{OBJECT} bit is set."
2251 :     msgstr ""
2252 :    
2253 :     #. type: Plain text
2254 :     #: R-ints.texi:1410
2255 :     msgid "It is currently unclear what should happen if the class attribute is removed from an S4 object, or if this should be allowed."
2256 :     msgstr ""
2257 :    
2258 :     #. type: Plain text
2259 :     #: R-ints.texi:1417
2260 :     msgid "S4 classes are stored as @R{} objects in the environment in which they are created, with names @code{.__C__@var{classname}}: as such they are not listed by default by @code{ls}."
2261 :     msgstr ""
2262 :    
2263 :     #. type: Plain text
2264 :     #: R-ints.texi:1420
2265 :     msgid "The objects are S4 objects of class @code{\"classRepresentation\"} which is defined in the @pkg{methods} package."
2266 :     msgstr ""
2267 :    
2268 :     #. type: Plain text
2269 :     #: R-ints.texi:1427
2270 :     msgid "Since these are just objects, they are subject to the normal scoping rules and can be imported and exported from namespaces like other objects. The directives @code{importClassesFrom} and @code{exportClasses} are merely convenient ways to refer to class objects without needing to know their internal `metaname' (although @code{exportClasses} does a little sanity checking via @code{isClass})."
2271 :     msgstr ""
2272 :    
2273 :     #. type: Plain text
2274 :     #: R-ints.texi:1436
2275 :     msgid "Details of methods are stored in S4 objects of class @code{\"MethodsList\"}. They have a non-syntactic name of the form @code{.__M__@var{generic}:@var{package}} for all methods defined in the current environment for the named generic derived from a specific package (which might be @code{.GlobalEnv})."
2276 :     msgstr ""
2277 :    
2278 :     #. type: Plain text
2279 :     #: R-ints.texi:1441
2280 :     msgid "There is also environment @code{.__T__@var{generic}:@var{package}} which has names the signatures of the methods defined, and values the corresponding method functions. This is often referred to as a `methods table'."
2281 :     msgstr ""
2282 :    
2283 :     #. type: Plain text
2284 :     #: R-ints.texi:1445
2285 :     msgid "When a package without a namespace is attached these objects become visible on the search path. @code{library} calls @code{methods:::cacheMetaData} to update the internal tables."
2286 :     msgstr ""
2287 :    
2288 :     #. type: Plain text
2289 :     #: R-ints.texi:1452
2290 :     msgid "During an @R{} session there is an environment associated with each non-primitive generic containing objects @code{.AllMTable}, @code{.Generic}, @code{.Methods}, @code{.MTable}, @code{.SigArgs} and @code{.SigLength}. @code{.MTable} and @code{AllMTable} are merged methods tables containing all the methods defined directly and via inheritance respectively. @code{.Methods} is a merged methods list."
2291 :     msgstr ""
2292 :    
2293 :     #. type: Plain text
2294 :     #: R-ints.texi:1461
2295 :     msgid "Exporting methods from a namespace is more complicated than exporting a class. Note first that you do not export a method, but rather the directive @code{exportMethods} will export all the methods defined in the namespace for a specified generic: the code also adds to the list of generics any that are exported directly. For generics which are listed via @code{exportMethods} or exported themselves, the corresponding @code{\"MethodsList\"} and environment are exported and so will appear (as hidden objects) in the package environment."
2296 :     msgstr ""
2297 :    
2298 :     #. type: Plain text
2299 :     #: R-ints.texi:1464
2300 :     msgid "Methods for primitives which are internally S4 generic (see below) are always exported, whether mentioned in the @file{NAMESPACE} file or not."
2301 :     msgstr ""
2302 :    
2303 :     #. type: Plain text
2304 :     #: R-ints.texi:1473
2305 :     msgid "Methods can be imported either via the directive @code{importMethodsFrom} or via importing a namespace by @code{import}. Also, if a generic is imported via @code{importFrom}, its methods are also imported. In all cases the generic will be imported if it is in the namespace, so @code{importMethodsFrom} is most appropriate for methods defined on generics in other packages. Since methods for a generic could be imported from several different packages, the methods tables are merged."
2306 :     msgstr ""
2307 :    
2308 :     #. type: Plain text
2309 :     #: R-ints.texi:1477
2310 :     msgid "When a package with a namespace is attached @code{methods:::cacheMetaData} is called to update the internal tables: only the visible methods will be cached."
2311 :     msgstr ""
2312 :    
2313 :     #. type: Plain text
2314 :     #: R-ints.texi:1484
2315 :     msgid "This subsection does not discuss how S4 methods are chosen: see @uref{http://@/developer.@/r-project.org/howMethodsWork.pdf}."
2316 :     msgstr ""
2317 :    
2318 :     #. type: Plain text
2319 :     #: R-ints.texi:1499
2320 :     msgid "For all but primitive functions, setting a method on an existing function that is not itself S4 generic creates a new object in the current environment which is a call to @code{standardGeneric} with the old definition as the default method. Such S4 generics can also be created @emph{via} a call to @code{setGeneric}@footnote{although this is not recommended as it is less future-proof.} and are standard closures in the @R{} language, with environment the environment within which they are created. With the advent of namespaces this is somewhat problematic: if @code{myfn} was previously in a package with a name space there will be two functions called @code{myfn} on the search paths, and which will be called depends on which search path is in use. This is starkest for functions in the base namespace, where the original will be found ahead of the newly created function from any other package with a namespace."
2321 :     msgstr ""
2322 :    
2323 :     #. type: Plain text
2324 :     #: R-ints.texi:1509
2325 :     msgid "Primitive functions are treated quite differently, for efficiency reasons: this results in different semantics. @code{setGeneric} is disallowed for primitive functions. The @pkg{methods} namespace contains a list @code{.BasicFunsList} named by primitive functions: the entries are either @code{FALSE} or a standard S4 generic showing the effective definition. When @code{setMethod} (or @code{setReplaceMethod}) is called, it either fails (if the list entry is @code{FALSE}) or a method is set on the effective generic given in the list."
2326 :     msgstr ""
2327 :    
2328 :     #. type: Plain text
2329 :     #: R-ints.texi:1526
2330 :     msgid "Actual dispatch of S4 methods for almost all primitives piggy-backs on the S3 dispatch mechanism, so S4 methods can only be dispatched for primitives which are internally S3 generic. When a primitive that is internally S3 generic is called with a first argument which is an S4 object and S4 dispatch is on (that is, the @pkg{methods} namespace is loaded), @code{DispatchOrEval} calls @code{R_possible_dispatch} (defined in file @file{src/main/objects.c}). (Members of the S3 group generics, which includes all the generic operators, are treated slightly differently: the first two arguments are checked and @code{DispatchGroup} is called.) @code{R_possible_dispatch} first checks an internal table to see if any S4 methods are set for that generic (and S4 dispatch is currently enabled for that generic), and if so proceeds to S4 dispatch using methods stored in another internal table. All primitives are in the base namespace, and this mechanism means that S4 methods can be set for (some) primitives and will always be used, in contrast to setting methods on non-primitives."
2331 :     msgstr ""
2332 :    
2333 :     #. type: Plain text
2334 :     #: R-ints.texi:1529
2335 :     msgid "The exception is @code{%*%}, which is S4 generic but not S3 generic as its C code contains a direct call to @code{R_possible_dispatch}."
2336 :     msgstr ""
2337 :    
2338 :     #. type: Plain text
2339 :     #: R-ints.texi:1535
2340 :     msgid "The primitive @code{as.double} is special, as @code{as.numeric} and @code{as.real} are copies of it. The @pkg{methods} package code partly refers to generics by name and partly by function, and maps @code{as.double} and @code{as.real} to @code{as.numeric} (since that is the name used by packages exporting methods for it)."
2341 :     msgstr ""
2342 :    
2343 :     #. type: Plain text
2344 :     #: R-ints.texi:1539
2345 :     msgid "Some elements of the language are implemented as primitives, for example @code{@}}. This includes the subset and subassignment `functions' and they are S4 generic, again piggybacking on S3 dispatch."
2346 :     msgstr ""
2347 :    
2348 :     #. type: Plain text
2349 :     #: R-ints.texi:1546
2350 :     msgid "@code{.BasicFunsList} is generated when @pkg{methods} is installed, by computing all primitives, initially disallowing methods on all and then setting generics for members of @code{.GenericArgsEnv}, the S4 group generics and a short exceptions list in file @file{BasicFunsList.R}: this currently contains the subsetting and subassignment operators and an override for @code{c}."
2351 :     msgstr ""
2352 :    
2353 :     #. type: Plain text
2354 :     #: R-ints.texi:1567
2355 :     msgid "@R{}'s memory allocation is almost all done via routines in file @file{src/main/memory.c}. It is important to keep track of where memory is allocated, as the Windows port (by default) makes use of a memory allocator that differs from @code{malloc} etc as provided by MinGW. Specifically, there are entry points @code{Rm_malloc}, @code{Rm_free}, @code{Rm_calloc} and @code{Rm_free} provided by file @file{src/gnuwin32/malloc.c}. This was done for two reasons. The primary motivation was performance: the allocator provided by MSVCRT @emph{via} MinGW was far too slow at handling the many small allocations that the allocation system for @code{SEXPREC}s uses. As a side benefit, we can set a limit on the amount of allocated memory: this is useful as whereas Windows does provide virtual memory it is relatively far slower than many other @R{} platforms and so limiting @R{}'s use of swapping is highly advantageous. The high-performance allocator is only called from @file{src/main/memory.c}, @file{src/main/regex.c}, @file{src/extra/pcre} and @file{src/extra/xdr}: note that this means that it is not used in packages."
2356 :     msgstr ""
2357 :    
2358 :     #. type: Plain text
2359 :     #: R-ints.texi:1571
2360 :     msgid "The rest of @R{} should where possible make use of the allocators made available by file @file{src/main/memory.c}, which are also the methods recommended in"
2361 :     msgstr ""
2362 :    
2363 :     #. type: ref{#1}
2364 :     #: R-ints.texi:1573
2365 :     msgid "Memory allocation, , Memory allocation, R-exts, Writing R Extensions"
2366 :     msgstr ""
2367 :    
2368 :     #. type: ifclear
2369 :     #: R-ints.texi:1576
2370 :     msgid "`Writing R Extensions'"
2371 :     msgstr ""
2372 :    
2373 :     #. type: findex
2374 :     #: R-ints.texi:1577
2375 :     #, no-wrap
2376 :     msgid "R_alloc"
2377 :     msgstr ""
2378 :    
2379 :     #. type: findex
2380 :     #: R-ints.texi:1578
2381 :     #, no-wrap
2382 :     msgid "Calloc"
2383 :     msgstr ""
2384 :    
2385 :     #. type: findex
2386 :     #: R-ints.texi:1579
2387 :     #, no-wrap
2388 :     msgid "Realloc"
2389 :     msgstr ""
2390 :    
2391 :     #. type: findex
2392 :     #: R-ints.texi:1580
2393 :     #, no-wrap
2394 :     msgid "Free"
2395 :     msgstr ""
2396 :    
2397 :     #. type: Plain text
2398 :     #: R-ints.texi:1585
2399 :     msgid "for use in @R{} packages, namely the use of @code{R_alloc}, @code{Calloc}, @code{Realloc} and @code{Free}. Memory allocated by @code{R_alloc} is freed by the garbage collector once the `watermark' has been reset by calling"
2400 :     msgstr ""
2401 :    
2402 :     #. type: findex
2403 :     #: R-ints.texi:1585
2404 :     #, no-wrap
2405 :     msgid "vmaxset"
2406 :     msgstr ""
2407 :    
2408 :     #. type: Plain text
2409 :     #: R-ints.texi:1589
2410 :     msgid "@code{vmaxset}. This is done automatically by the wrapper code calling primitives and @code{.Internal} functions (and also by the wrapper code to @code{.Call} and @code{.External}), but"
2411 :     msgstr ""
2412 :    
2413 :     #. type: findex
2414 :     #: R-ints.texi:1589
2415 :     #, no-wrap
2416 :     msgid "vmaxget"
2417 :     msgstr ""
2418 :    
2419 :     #. type: Plain text
2420 :     #: R-ints.texi:1593
2421 :     msgid "@code{vmaxget} and @code{vmaxset} can be used to reset the watermark from within internal code if the memory is only required for a short time."
2422 :     msgstr ""
2423 :    
2424 :     #. type: findex
2425 :     #: R-ints.texi:1594
2426 :     #, no-wrap
2427 :     msgid "alloca"
2428 :     msgstr ""
2429 :    
2430 :     #. type: Plain text
2431 :     #: R-ints.texi:1599
2432 :     msgid "All of the methods of memory allocation mentioned so far are relatively expensive. All @R{} platforms support @code{alloca}, and in almost all cases@footnote{but apparently not on Windows.} this is managed by the compiler, allocates memory on the C stack and is very efficient."
2433 :     msgstr ""
2434 :    
2435 :     #. type: Plain text
2436 :     #: R-ints.texi:1606
2437 :     msgid "There are two disadvantages in using @code{alloca}. First, it is fragile and care is needed to avoid writing (or even reading) outside the bounds of the allocation block returned. Second, it increases the danger of overflowing the C stack. It is suggested that it is only used for smallish allocations (up to tens of thousands of bytes), and that"
2438 :     msgstr ""
2439 :    
2440 :     #. type: findex
2441 :     #: R-ints.texi:1607
2442 :     #, no-wrap
2443 :     msgid "R_CheckStack"
2444 :     msgstr ""
2445 :    
2446 :     #. type: example
2447 :     #: R-ints.texi:1610
2448 :     #, no-wrap
2449 :     msgid " R_CheckStack();\n"
2450 :     msgstr ""
2451 :    
2452 :     #. type: Plain text
2453 :     #: R-ints.texi:1617
2454 :     msgid "is called immediately after the allocation (as @R{}'s stack checking mechanism will warn far enough from the stack limit to allow for modest use of alloca). (@code{do_makeunique} in file @file{src/main/unique.c} provides an example of both points.)"
2455 :     msgstr ""
2456 :    
2457 :     #. type: Plain text
2458 :     #: R-ints.texi:1619
2459 :     msgid "There is an alternative check,"
2460 :     msgstr ""
2461 :    
2462 :     #. type: findex
2463 :     #: R-ints.texi:1619
2464 :     #, no-wrap
2465 :     msgid "R_CheckStack2"
2466 :     msgstr ""
2467 :    
2468 :     #. type: example
2469 :     #: R-ints.texi:1622
2470 :     #, no-wrap
2471 :     msgid " R_CheckStack2(size_t extra);\n"
2472 :     msgstr ""
2473 :    
2474 :     #. type: Plain text
2475 :     #: R-ints.texi:1627
2476 :     msgid "to be called immediately @emph{before} trying an allocation of @code{extra} bytes."
2477 :     msgstr ""
2478 :    
2479 :     #. type: Plain text
2480 :     #: R-ints.texi:1633
2481 :     msgid "An alternative strategy has been used for various functions which require intermediate blocks of storage of varying but usually small size, and this has been consolidated into the routines in the header file @file{src/main/RBufferUtils.h}. This uses a structure which contains a buffer, the current size and the default size. A call to"
2482 :     msgstr ""
2483 :    
2484 :     #. type: findex
2485 :     #: R-ints.texi:1633
2486 :     #, no-wrap
2487 :     msgid "R_AllocStringBuffer"
2488 :     msgstr ""
2489 :    
2490 :     #. type: example
2491 :     #: R-ints.texi:1636
2492 :     #, no-wrap
2493 :     msgid " R_AllocStringBuffer(size_t blen, R_StringBuffer *buf);\n"
2494 :     msgstr ""
2495 :    
2496 :     #. type: Plain text
2497 :     #: R-ints.texi:1642
2498 :     msgid "sets @code{buf->data} to a memory area of at least @code{blen+1} bytes. At least the default size is used, which means that for small allocations the same buffer can be reused. A call to"
2499 :     msgstr ""
2500 :    
2501 :     #. type: findex
2502 :     #: R-ints.texi:1642
2503 :     #, no-wrap
2504 :     msgid "R_FreeStringBufferL"
2505 :     msgstr ""
2506 :    
2507 :     #. type: findex
2508 :     #: R-ints.texi:1643
2509 :     #, no-wrap
2510 :     msgid "R_FreeStringBuffer"
2511 :     msgstr ""
2512 :    
2513 :     #. type: Plain text
2514 :     #: R-ints.texi:1647
2515 :     msgid "@code{R_FreeStringBufferL} releases memory if more than the default has been allocated whereas a call to @code{R_FreeStringBuffer} frees any memory allocated."
2516 :     msgstr ""
2517 :    
2518 :     #. type: Plain text
2519 :     #: R-ints.texi:1649
2520 :     msgid "The @code{R_StringBuffer} structure needs to be initialized, for example by"
2521 :     msgstr ""
2522 :    
2523 :     #. type: example
2524 :     #: R-ints.texi:1652
2525 :     #, no-wrap
2526 :     msgid "static R_StringBuffer ex_buff = @{NULL, 0, MAXELTSIZE@};\n"
2527 :     msgstr ""
2528 :    
2529 :     #. type: Plain text
2530 :     #: R-ints.texi:1660
2531 :     msgid "which uses a default size of @code{MAXELTSIZE = 8192} bytes. Most current uses have a static @code{R_StringBuffer} structure, which allows the (default-sized) buffer to be shared between calls to e.g.@: @code{grep} and even between functions: this will need to be changed if @R{} ever allows concurrent evaluation threads. So the idiom is"
2532 :     msgstr ""
2533 :    
2534 :     #. type: example
2535 :     #: R-ints.texi:1673
2536 :     #, no-wrap
2537 :     msgid ""
2538 :     "static R_StringBuffer ex_buff = @{NULL, 0, MAXELTSIZE@};\n"
2539 :     "...\n"
2540 :     " char *buf;\n"
2541 :     " for(i = 0; i < n; i++) @{\n"
2542 :     " compute len\n"
2543 :     " buf = R_AllocStringBuffer(len, &ex_buff);\n"
2544 :     " use buf\n"
2545 :     " @}\n"
2546 :     " /* free allocation if larger than the default, but leave\n"
2547 :     " default allocated for future use */\n"
2548 :     " R_FreeStringBufferL(&ex_buff);\n"
2549 :     msgstr ""
2550 :    
2551 :     #. type: subsection
2552 :     #: R-ints.texi:1678
2553 :     #: R-ints.texi:1680
2554 :     #: R-ints.texi:1681
2555 :     #, no-wrap
2556 :     msgid "Internals of R_alloc"
2557 :     msgstr ""
2558 :    
2559 :     #. type: Plain text
2560 :     #: R-ints.texi:1689
2561 :     msgid "The memory used by @code{R_alloc} is allocated as @R{} vectors, of type @code{RAWSXP}. Thus the allocation is in units of 8 bytes, and is rounded up. A request for zero bytes currently returns @code{NULL} (but this should not be relied on). For historical reasons, in all other cases 1 byte is added before rounding up so the allocation is always 1--8 bytes more than was asked for: again this should not be relied on."
2562 :     msgstr ""
2563 :    
2564 :     #. type: Plain text
2565 :     #: R-ints.texi:1700
2566 :     msgid "The vectors allocated are protected via the setting of @code{R_VStack}, as the garbage collector marks everything that can be reached from that location. When a vector is @code{R_alloc}ated, its @code{ATTRIB} pointer is set to the current @code{R_VStack}, and @code{R_VStack} is set to the latest allocation. Thus @code{R_VStack} is a single-linked chain of the vectors currently allocated via @code{R_alloc}. Function @code{vmaxset} resets the location @code{R_VStack}, and should be to a value that has previously be obtained @emph{via} @code{vmaxget}: allocations after the value was obtained will no longer be protected and hence available for garbage collection."
2567 :     msgstr ""
2568 :    
2569 :     #. type: Plain text
2570 :     #: R-ints.texi:1706
2571 :     msgid "This section notes known use by the system of these environments: the intention is to minimize or eliminate such uses."
2572 :     msgstr ""
2573 :    
2574 :     #. type: node
2575 :     #: R-ints.texi:1710
2576 :     #: R-ints.texi:1712
2577 :     #: R-ints.texi:1713
2578 :     #: R-ints.texi:1739
2579 :     #, no-wrap
2580 :     msgid "Base environment"
2581 :     msgstr ""
2582 :    
2583 :     #. type: subsection
2584 :     #: R-ints.texi:1710
2585 :     #: R-ints.texi:1712
2586 :     #: R-ints.texi:1739
2587 :     #: R-ints.texi:1740
2588 :     #, no-wrap
2589 :     msgid "Global environment"
2590 :     msgstr ""
2591 :    
2592 :     #. type: findex
2593 :     #: R-ints.texi:1717
2594 :     #, no-wrap
2595 :     msgid ".Device"
2596 :     msgstr ""
2597 :    
2598 :     #. type: findex
2599 :     #: R-ints.texi:1718
2600 :     #, no-wrap
2601 :     msgid ".Devices"
2602 :     msgstr ""
2603 :    
2604 :     #. type: Plain text
2605 :     #: R-ints.texi:1724
2606 :     msgid "The graphics devices system maintains two variables @code{.Device} and @code{.Devices} in the base environment: both are always set. The variable @code{.Devices} gives a list of character vectors of the names of open devices, and @code{.Device} is the element corresponding to the currently active device. The null device will always be open."
2607 :     msgstr ""
2608 :    
2609 :     #. type: findex
2610 :     #: R-ints.texi:1725
2611 :     #, no-wrap
2612 :     msgid ".Options"
2613 :     msgstr ""
2614 :    
2615 :     #. type: Plain text
2616 :     #: R-ints.texi:1729
2617 :     msgid "There appears to be a variable @code{.Options}, a pairlist giving the current options settings. But in fact this is just a symbol with a value assigned, and so shows up as a base variable."
2618 :     msgstr ""
2619 :    
2620 :     #. type: findex
2621 :     #: R-ints.texi:1730
2622 :     #, no-wrap
2623 :     msgid ".Last.value"
2624 :     msgstr ""
2625 :    
2626 :     #. type: Plain text
2627 :     #: R-ints.texi:1733
2628 :     msgid "Similarly, the evaluator creates a symbol @code{.Last.value} which appears as a variable in the base environment."
2629 :     msgstr ""
2630 :    
2631 :     #. type: findex
2632 :     #: R-ints.texi:1734
2633 :     #, no-wrap
2634 :     msgid ".Traceback"
2635 :     msgstr ""
2636 :    
2637 :     #. type: findex
2638 :     #: R-ints.texi:1735
2639 :     #, no-wrap
2640 :     msgid "last.warning"
2641 :     msgstr ""
2642 :    
2643 :     #. type: Plain text
2644 :     #: R-ints.texi:1738
2645 :     msgid "Errors can give rise to objects @code{.Traceback} and @code{last.warning} in the base environment."
2646 :     msgstr ""
2647 :    
2648 :     #. type: cindex
2649 :     #: R-ints.texi:1742
2650 :     #, no-wrap
2651 :     msgid "global environment"
2652 :     msgstr ""
2653 :    
2654 :     #. type: cindex
2655 :     #: R-ints.texi:1743
2656 :     #, no-wrap
2657 :     msgid "environment, global"
2658 :     msgstr ""
2659 :    
2660 :     #. type: findex
2661 :     #: R-ints.texi:1744
2662 :     #, no-wrap
2663 :     msgid ".Random.seed"
2664 :     msgstr ""
2665 :    
2666 :     #. type: Plain text
2667 :     #: R-ints.texi:1747
2668 :     msgid "The seed for the random number generator is stored in object @code{.Random.seed} in the global environment."
2669 :     msgstr ""
2670 :    
2671 :     #. type: findex
2672 :     #: R-ints.texi:1748
2673 :     #, no-wrap
2674 :     msgid "dump.frames"
2675 :     msgstr ""
2676 :    
2677 :     #. type: Plain text
2678 :     #: R-ints.texi:1751
2679 :     msgid "Some error handlers may give rise to objects in the global environment: for example @code{dump.frames} by default produces @code{last.dump}."
2680 :     msgstr ""
2681 :    
2682 :     #. type: findex
2683 :     #: R-ints.texi:1752
2684 :     #, no-wrap
2685 :     msgid ".SavedPlots"
2686 :     msgstr ""
2687 :    
2688 :     #. type: Plain text
2689 :     #: R-ints.texi:1756
2690 :     msgid "The @code{windows()} device makes use of a variable @code{.SavedPlots} to store display lists of saved plots for later display. This is regarded as a variable created by the user."
2691 :     msgstr ""
2692 :    
2693 :     #. type: cindex
2694 :     #: R-ints.texi:1761
2695 :     #, no-wrap
2696 :     msgid "modules"
2697 :     msgstr ""
2698 :    
2699 :     #. type: Plain text
2700 :     #: R-ints.texi:1766
2701 :     msgid "@R{} makes use of a number of shared objects/DLLs stored in the @file{modules} directory. These are parts of the code which have been chosen to be loaded `on demand' rather than linked as dynamic libraries or incorporated into the main executable/dynamic library."
2702 :     msgstr ""
2703 :    
2704 :     #. type: Plain text
2705 :     #: R-ints.texi:1770
2706 :     msgid "For the remaining modules the motivation has been the amount of (often optional) code they will bring in via libraries to which they are linked."
2707 :     msgstr ""
2708 :    
2709 :     #. type: code{#1}
2710 :     #: R-ints.texi:1773
2711 :     #, no-wrap
2712 :     msgid "internet"
2713 :     msgstr ""
2714 :    
2715 :     #. type: table
2716 :     #: R-ints.texi:1776
2717 :     msgid "The internal HTTP and FTP clients and socket support, which link to system-specific support libraries."
2718 :     msgstr ""
2719 :    
2720 :     #. type: code{#1}
2721 :     #: R-ints.texi:1777
2722 :     #, no-wrap
2723 :     msgid "lapack"
2724 :     msgstr ""
2725 :    
2726 :     #. type: table
2727 :     #: R-ints.texi:1780
2728 :     msgid "The code which makes use of the LAPACK library, and is linked to @file{libRlapack} or an external LAPACK library."
2729 :     msgstr ""
2730 :    
2731 :     #. type: code{#1}
2732 :     #: R-ints.texi:1781
2733 :     #, no-wrap
2734 :     msgid "vfonts"
2735 :     msgstr ""
2736 :    
2737 :     #. type: table
2738 :     #: R-ints.texi:1783
2739 :     msgid "The Hershey font databases and the code to draw with them."
2740 :     msgstr ""
2741 :    
2742 :     #. type: code{#1}
2743 :     #: R-ints.texi:1784
2744 :     #, no-wrap
2745 :     msgid "X11"
2746 :     msgstr ""
2747 :    
2748 :     #. type: table
2749 :     #: R-ints.texi:1789
2750 :     msgid "(Unix-alikes only.) The @code{X11()}, @code{jpeg()}, @code{png()} and @code{tiff()} devices. These are optional, and links to some or all of the @code{X11}, @code{pango}, @code{cairo}, @code{jpeg}, @code{libpng} and @code{libtiff} libraries."
2751 :     msgstr ""
2752 :    
2753 :     #. type: file{#1}
2754 :     #: R-ints.texi:1790
2755 :     #, no-wrap
2756 :     msgid "internet2.dll"
2757 :     msgstr ""
2758 :    
2759 :     #. type: table
2760 :     #: R-ints.texi:1794
2761 :     msgid "(Windows only.) An alternative version of the internet access routines, compiled against Internet Explorer internals (and so loads @file{wininet.dll} and @file{wsock32.dll})."
2762 :     msgstr ""
2763 :    
2764 :     #. type: cindex
2765 :     #: R-ints.texi:1798
2766 :     #, no-wrap
2767 :     msgid "visibility"
2768 :     msgstr ""
2769 :    
2770 :     #. type: node
2771 :     #: R-ints.texi:1803
2772 :     #: R-ints.texi:1805
2773 :     #: R-ints.texi:1806
2774 :     #: R-ints.texi:1856
2775 :     #, no-wrap
2776 :     msgid "Hiding C entry points"
2777 :     msgstr ""
2778 :    
2779 :     #. type: subsection
2780 :     #: R-ints.texi:1803
2781 :     #: R-ints.texi:1805
2782 :     #: R-ints.texi:1856
2783 :     #: R-ints.texi:1857
2784 :     #, no-wrap
2785 :     msgid "Variables in Windows DLLs"
2786 :     msgstr ""
2787 :    
2788 :     #. type: Plain text
2789 :     #: R-ints.texi:1809
2790 :     msgid "We make use of the visibility mechanisms discussed in"
2791 :     msgstr ""
2792 :    
2793 :     #. type: ifset
2794 :     #: R-ints.texi:1811
2795 :     msgid "@ref{Controlling visibility, , Controlling visibility, R-exts, Writing R Extensions},"
2796 :     msgstr ""
2797 :    
2798 :     #. type: ifclear
2799 :     #: R-ints.texi:1814
2800 :     msgid "section `Controlling Visibility' in `Writing R Extensions',"
2801 :     msgstr ""
2802 :    
2803 :     #. type: Plain text
2804 :     #: R-ints.texi:1818
2805 :     msgid "C entry points not needed outside the main @R{} executable/dynamic library (and in particular in no package nor module) should be prefixed by @code{attribute_hidden}."
2806 :     msgstr ""
2807 :    
2808 :     #. type: findex
2809 :     #: R-ints.texi:1818
2810 :     #, no-wrap
2811 :     msgid "attribute_hidden"
2812 :     msgstr ""
2813 :    
2814 :     #. type: Plain text
2815 :     #: R-ints.texi:1826
2816 :     msgid "Minimizing the visibility of symbols in the @R{} dynamic library will speed up linking to it (which packages will do) and reduce the possibility of linking to the wrong entry points of the same name. In addition, on some platforms reducing the number of entry points allows more efficient versions of PIC to be used: somewhat over half the entry points are hidden. A convenient way to hide variables (as distinct from functions) is to declare them @code{extern0} in header file @file{Defn.h}."
2817 :     msgstr ""
2818 :    
2819 :     #. type: Plain text
2820 :     #: R-ints.texi:1832
2821 :     msgid "The visibility mechanism used is only available with some compilers and platforms, and in particular not on Windows, where an alternative mechanism is used. Entry points will not be made available in @file{R.dll} if they are listed in the file @file{src/gnuwin32/Rdll.hide}."
2822 :     msgstr ""
2823 :    
2824 :     #. type: findex
2825 :     #: R-ints.texi:1832
2826 :     #, no-wrap
2827 :     msgid "Rdll.hide"
2828 :     msgstr ""
2829 :    
2830 :     #. type: Plain text
2831 :     #: R-ints.texi:1841
2832 :     msgid "Entries in that file start with a space and must be strictly in alphabetic order in the C locale (use @command{sort} on the file to ensure this if you change it). It is possible to hide Fortran as well as C entry points via this file: the former are lower-cased and have an underline as suffix, and the suffixed name should be included in the file. Some entry points exist only on Windows or need to be visible only on Windows, and some notes on these are provided in file @file{src/gnuwin32/Maintainters.notes}."
2833 :     msgstr ""
2834 :    
2835 :     #. type: Plain text
2836 :     #: R-ints.texi:1851
2837 :     msgid "Because of the advantages of reducing the number of visible entry points, they should be declared @code{attribute_hidden} where possible. Note that this only has an effect on a shared-R-library build, and so care is needed not to hide entry points that are legitimately used by packages. So it is best if the decision on visibility is made when a new entry point is created, including the decision if it should be included in header file @file{Rinternals.h}. A list of the visible entry points on shared-R-library build on a reasonably standard Unix-alike can be made by something like"
2838 :     msgstr ""
2839 :    
2840 :     #. type: example
2841 :     #: R-ints.texi:1854
2842 :     #, no-wrap
2843 :     msgid "nm -g libR.so | grep ' [BCDT] ' | cut -b20-\n"
2844 :     msgstr ""
2845 :    
2846 :     #. type: Plain text
2847 :     #: R-ints.texi:1866
2848 :     msgid "Windows is unique in that it conventionally treats importing variables differently from functions: variables that are imported from a DLL need to be specified by a prefix (often @samp{_imp_}) when being linked to (`imported') but not when being linked from (`exported'). The details depend on the compiler system, and have changed for MinGW during the lifetime of that port. They are in the main hidden behind some macros defined in header file @file{R_ext/libextern.h}."
2849 :     msgstr ""
2850 :    
2851 :     #. type: Plain text
2852 :     #: R-ints.texi:1872
2853 :     msgid "A (non-function) variable in the main @R{} sources that needs to be referred to outside @file{R.dll} (in a package, module or another DLL such as @file{Rgraphapp.dll}) should be declared with prefix @code{LibExtern}. The main use is in @file{Rinternals.h}, but it needs to be considered for any public header and also @file{Defn.h}."
2854 :     msgstr ""
2855 :    
2856 :     #. type: Plain text
2857 :     #: R-ints.texi:1879
2858 :     msgid "It would nowadays be possible to make use of the `auto-import' feature of the MinGW port of @command{ld} to fix up imports from DLLs (and if @R{} is built for the Cygwin platform this is what happens). However, this was not possible when the MinGW build of @R{} was first constructed in ca 1998, allows less control of visibility and would not work for other Windows compiler suites."
2859 :     msgstr ""
2860 :    
2861 :     #. type: Plain text
2862 :     #: R-ints.texi:1882
2863 :     msgid "It is only possible to check if this has been handled correctly by compiling the @R{} sources on Windows."
2864 :     msgstr ""
2865 :    
2866 :     #. type: Plain text
2867 :     #: R-ints.texi:1891
2868 :     msgid "Lazy loading is always used for code in packages but is optional (selected by the package maintainer) for datasets in packages. When a package/namespace which uses it is loaded, the package/namespace environment is populated with promises for all the named objects: when these promises are evaluated they load the actual code from a database."
2869 :     msgstr ""
2870 :    
2871 :     #. type: Plain text
2872 :     #: R-ints.texi:1902
2873 :     msgid "There are separate databases for code and data, stored in the @file{R} and @file{data} subdirectories. The database consists of two files, @file{@var{name}.rdb} and @file{@var{name}.rdx}. The @file{.rdb} file is a concatenation of serialized objects, and the @file{.rdx} file contains an index. The objects are stored in (usually) a @command{gzip}-compressed format with a 4-byte header giving the uncompressed serialized length (in XDR, that is big-endian, byte order) and read by a call to the primitive @code{lazyLoadDBfetch}. (Note that this makes lazy-loading unsuitable for really large objects: the unserialized length of an @R{} object can exceed 4GB.)"
2874 :     msgstr ""
2875 :    
2876 :     #. type: Plain text
2877 :     #: R-ints.texi:1917
2878 :     msgid "The index or `map' file @file{@var{name}.rdx} is a compressed serialized @R{} object to be read by @code{readRDS}. It is a list with three elements @code{variables}, @code{references} and @code{compressed}. The first two are named lists of integer vectors of length 2 giving the offset and length of the serialized object in the @file{@var{name}.rdb} file. Element @code{variables} has an entry for each named object: @code{references} serializes a temporary environment used when named environments are added to the database. @code{compressed} is a logical indicating if the serialized objects were compressed: compression is always used nowadays. We later added the values @code{compressed = 2} and @code{3} for @command{bzip2} and @command{xz} compression (with the possibility of future expansion to other methods): these formats add a fifth byte to the header for the type of compression, and store serialized objects uncompressed if compression expands them."
2879 :     msgstr ""
2880 :    
2881 :     #. type: Plain text
2882 :     #: R-ints.texi:1922
2883 :     msgid "The loader for a lazy-load database of code or data is function @code{lazyLoad} in the @pkg{base} package, but note that there is a separate copy to load @pkg{base} itself in file @file{R_HOME/base/R/base}."
2884 :     msgstr ""
2885 :    
2886 :     #. type: Plain text
2887 :     #: R-ints.texi:1928
2888 :     msgid "Lazy-load databases are created by the code in @file{src/library/tools/R/makeLazyLoad.R}: the main tool is the unexported function @code{makeLazyLoadDB} and the insertion of database entries is done by calls to @code{.Call(\"R_lazyLoadDBinsertValue\", ...)}."
2889 :     msgstr ""
2890 :    
2891 :     #. type: Plain text
2892 :     #: R-ints.texi:1932
2893 :     msgid "Lazy-load databases of less than 10MB are cached in memory at first use: this was found necessary when using file systems with high latency (removable devices and network-mounted file systems on Windows)."
2894 :     msgstr ""
2895 :    
2896 :     #. type: Plain text
2897 :     #: R-ints.texi:1942
2898 :     msgid "Lazy-load databases are loaded into the exports for a package, but not into the namespace environment itself. Thus they are visible when the package is @emph{attached}, and also @emph{via} the @code{::} operator. This was a deliberate design decision, as packages mostly make datasets available for use by the end user (or other packages), and they should not be found preferentially from functions in the package, surprising users who expected the normal search path to be used. (There is an alternative mechanism, @file{sysdata.rda}, for `system datasets' that are intended primarily to be used within the package.)"
2899 :     msgstr ""
2900 :    
2901 :     #. type: Plain text
2902 :     #: R-ints.texi:1946
2903 :     msgid "The same database mechanism is used to store parsed @file{Rd} files. One or all of the parsed objects is fetched by a call to @code{tools:::fetchRdDB}."
2904 :     msgstr ""
2905 :    
2906 :     #. type: chapter
2907 :     #: R-ints.texi:1948
2908 :     #, no-wrap
2909 :     msgid "@code{.Internal} vs @code{.Primitive}"
2910 :     msgstr ""
2911 :    
2912 :     #. type: findex
2913 :     #: R-ints.texi:1950
2914 :     #, no-wrap
2915 :     msgid ".Internal"
2916 :     msgstr ""
2917 :    
2918 :     #. type: findex
2919 :     #: R-ints.texi:1951
2920 :     #, no-wrap
2921 :     msgid ".Primitive"
2922 :     msgstr ""
2923 :    
2924 :     #. type: Plain text
2925 :     #: R-ints.texi:1964
2926 :     msgid "C code compiled into @R{} at build time can be called directly in what are termed @emph{primitives} or via the @code{.Internal} interface, which is very similar to the @code{.External} interface except in syntax. More precisely, @R{} maintains a table of @R{} function names and corresponding C functions to call, which by convention all start with @samp{do_} and return a @code{SEXP}. This table (@code{R_FunTab} in file @file{src/main/names.c}) also specifies how many arguments to a function are required or allowed, whether or not the arguments are to be evaluated before calling, and whether the function is `internal' in the sense that it must be accessed via the @code{.Internal} interface, or directly accessible in which case it is printed in @R{} as @code{.Primitive}."
2927 :     msgstr ""
2928 :    
2929 :     #. type: Plain text
2930 :     #: R-ints.texi:1968
2931 :     msgid "Functions using @code{.Internal()} wrapped in a closure are in general preferred as this ensures standard handling of named and default arguments. For example, @code{grep} is defined as"
2932 :     msgstr ""
2933 :    
2934 :     #. type: group
2935 :     #: R-ints.texi:1979
2936 :     #, no-wrap
2937 :     msgid ""
2938 :     "grep <-\n"
2939 :     "function (pattern, x, ignore.case = FALSE, perl = FALSE, value = FALSE,\n"
2940 :     " fixed = FALSE, useBytes = FALSE, invert = FALSE)\n"
2941 :     "@{\n"
2942 :     " if (!is.character(x)) x <- structure(as.character(x), names = names(x))\n"
2943 :     " .Internal(grep(as.character(pattern), x, ignore.case, value,\n"
2944 :     " perl, fixed, useBytes, invert))\n"
2945 :     "@}\n"
2946 :     "\n"
2947 :     msgstr ""
2948 :    
2949 :     #. type: Plain text
2950 :     #: R-ints.texi:1984
2951 :     msgid "and the use of @code{as.character} allows methods to be dispatched (for example, for factors)."
2952 :     msgstr ""
2953 :    
2954 :     #. type: Plain text
2955 :     #: R-ints.texi:1997
2956 :     msgid "However, for reasons of convenience and also efficiency (as there is some overhead in using the @code{.Internal} interface wrapped in a function closure), the primitive functions are exceptions that can be accessed directly. And of course, primitive functions are needed for basic operations---for example @code{.Internal} is itself a primitive. Note that primitive functions make no use of @R{} code, and hence are very different from the usual interpreted functions. In particular, @code{formals} and @code{body} return @code{NULL} for such objects, and argument matching can be handled differently. For some primitives (including @code{call}, @code{switch}, @code{.C} and @code{.subset}) positional matching is important to avoid partial matching of the first argument."
2957 :     msgstr ""
2958 :    
2959 :     #. type: Plain text
2960 :     #: R-ints.texi:2000
2961 :     msgid "The list of primitive functions is subject to change; currently, it includes the following."
2962 :     msgstr ""
2963 :    
2964 :     #. type: enumerate
2965 :     #: R-ints.texi:2006
2966 :     msgid "``Special functions'' which really are @emph{language} elements, but implemented as primitive functions:"
2967 :     msgstr ""
2968 :    
2969 :     #. type: group
2970 :     #: R-ints.texi:2011
2971 :     #, no-wrap
2972 :     msgid ""
2973 :     "@{ ( if for while repeat break next\n"
2974 :     "return function quote switch\n"
2975 :     msgstr ""
2976 :    
2977 :     #. type: enumerate
2978 :     #: R-ints.texi:2018
2979 :     msgid "Language elements and basic @emph{operator}s (i.e., functions usually @emph{not} called as @code{foo(a, b, ...)}) for subsetting, assignment, arithmetic, comparison and logic:"
2980 :     msgstr ""
2981 :    
2982 :     #. type: group
2983 :     #: R-ints.texi:2023
2984 :     #, no-wrap
2985 :     msgid ""
2986 :     " [ [[ $ @@\n"
2987 :     "<- <<- = [<- [[<- $<- @@<-\n"
2988 :     "\n"
2989 :     msgstr ""
2990 :    
2991 :     #. type: group
2992 :     #: R-ints.texi:2027
2993 :     #, no-wrap
2994 :     msgid ""
2995 :     "+ - * / ^ %% %*% %/%\n"
2996 :     "< <= == != >= >\n"
2997 :     "| || & && !\n"
2998 :     msgstr ""
2999 :    
3000 :     #. type: enumerate
3001 :     #: R-ints.texi:2033
3002 :     msgid "When the arithmetic, comparison and logical operators are called as functions, any argument names are discarded so positional matching is used."
3003 :     msgstr ""
3004 :    
3005 :     #. type: enumerate
3006 :     #: R-ints.texi:2037
3007 :     msgid "``Low level'' 0-- and 1--argument functions which belong to one of the following groups of functions:"
3008 :     msgstr ""
3009 :    
3010 :     #. type: enumerate
3011 :     #: R-ints.texi:2041
3012 :     msgid "Basic mathematical functions with a single argument, i.e.,"
3013 :     msgstr ""
3014 :    
3015 :     #. type: group
3016 :     #: R-ints.texi:2046
3017 :     #, no-wrap
3018 :     msgid ""
3019 :     "abs sign sqrt\n"
3020 :     "floor ceiling\n"
3021 :     msgstr ""
3022 :    
3023 :     #. type: group
3024 :     #: R-ints.texi:2056
3025 :     #, no-wrap
3026 :     msgid ""
3027 :     "exp expm1\n"
3028 :     "log2 log10 log1p\n"
3029 :     "cos sin tan\n"
3030 :     "acos asin atan\n"
3031 :     "cosh sinh tanh\n"
3032 :     "acosh asinh atanh\n"
3033 :     "cospi sinpi tanpi\n"
3034 :     msgstr ""
3035 :    
3036 :     #. type: group
3037 :     #: R-ints.texi:2060
3038 :     #, no-wrap
3039 :     msgid "gamma lgamma digamma trigamma\n"
3040 :     msgstr ""
3041 :    
3042 :     #. type: group
3043 :     #: R-ints.texi:2064
3044 :     #, no-wrap
3045 :     msgid "cumsum cumprod cummax cummin\n"
3046 :     msgstr ""
3047 :    
3048 :     #. type: group
3049 :     #: R-ints.texi:2068
3050 :     #, no-wrap
3051 :     msgid "Im Re Arg Conj Mod\n"
3052 :     msgstr ""
3053 :    
3054 :     #. type: enumerate
3055 :     #: R-ints.texi:2073
3056 :     msgid "@code{log} is a primitive function of one or two arguments with named argument matching."
3057 :     msgstr ""
3058 :    
3059 :     #. type: enumerate
3060 :     #: R-ints.texi:2077
3061 :     msgid "@code{trunc} is a difficult case: it is a primitive that can have one or more arguments: the default method handled in the primitive has only one."
3062 :     msgstr ""
3063 :    
3064 :     #. type: enumerate
3065 :     #: R-ints.texi:2081
3066 :     msgid "Functions rarely used outside of ``programming'' (i.e., mostly used inside other functions), such as"
3067 :     msgstr ""
3068 :    
3069 :     #. type: group
3070 :     #: R-ints.texi:2096
3071 :     #, no-wrap
3072 :     msgid ""
3073 :     "nargs missing on.exit interactive\n"
3074 :     "as.call as.character as.complex as.double\n"
3075 :     "as.environment as.integer as.logical as.raw\n"
3076 :     "is.array is.atomic is.call is.character\n"
3077 :     "is.complex is.double is.environment is.expression\n"
3078 :     "is.finite is.function is.infinite is.integer\n"
3079 :     "is.language is.list is.logical is.matrix\n"
3080 :     "is.na is.name is.nan is.null\n"
3081 :     "is.numeric is.object is.pairlist is.raw\n"
3082 :     "is.real is.recursive is.single is.symbol\n"
3083 :     "baseenv emptyenv globalenv pos.to.env\n"
3084 :     "unclass invisible seq_along seq_len\n"
3085 :     msgstr ""
3086 :    
3087 :     #. type: enumerate
3088 :     #: R-ints.texi:2101
3089 :     msgid "The programming and session management utilities"
3090 :     msgstr ""
3091 :    
3092 :     #. type: group
3093 :     #: R-ints.texi:2105
3094 :     #, no-wrap
3095 :     msgid "browser proc.time gc.time tracemem retracemem untracemem\n"
3096 :     msgstr ""
3097 :    
3098 :     #. type: enumerate
3099 :     #: R-ints.texi:2112
3100 :     msgid "The following basic replacement and extractor functions"
3101 :     msgstr ""
3102 :    
3103 :     #. type: group
3104 :     #: R-ints.texi:2126
3105 :     #, no-wrap
3106 :     msgid ""
3107 :     "length length<-\n"
3108 :     "class class<-\n"
3109 :     "oldClass oldCLass<-\n"
3110 :     "attr attr<-\n"
3111 :     "attributes attributes<-\n"
3112 :     "names names<-\n"
3113 :     "dim dim<-\n"
3114 :     "dimnames dimnames<-\n"
3115 :     " environment<-\n"
3116 :     " levels<-\n"
3117 :     " storage.mode<-\n"
3118 :     msgstr ""
3119 :    
3120 :     #. type: enumerate
3121 :     #: R-ints.texi:2136
3122 :     msgid "Note that optimizing @code{NAMED = 1} is only effective within a primitive (as the closure wrapper of a @code{.Internal} will set @code{NAMED = 2} when the promise to the argument is evaluated) and hence replacement functions should where possible be primitive to avoid copying (at least in their default methods)."
3123 :     msgstr ""
3124 :    
3125 :     #. type: enumerate
3126 :     #: R-ints.texi:2139
3127 :     msgid "The following functions are primitive for efficiency reasons:"
3128 :     msgstr ""
3129 :    
3130 :     #. type: group
3131 :     #: R-ints.texi:2147
3132 :     #, no-wrap
3133 :     msgid ""
3134 :     ": ~ c list\n"
3135 :     "call expression substitute\n"
3136 :     "UseMethod standardGeneric\n"
3137 :     ".C .Fortran .Call .External\n"
3138 :     "round signif rep seq.int\n"
3139 :     msgstr ""
3140 :    
3141 :     #. type: enumerate
3142 :     #: R-ints.texi:2152
3143 :     msgid "as well as the following internal-use-only functions"
3144 :     msgstr ""
3145 :    
3146 :     #. type: group
3147 :     #: R-ints.texi:2160
3148 :     #, no-wrap
3149 :     msgid ""
3150 :     ".Primitive .Internal\n"
3151 :     ".Call.graphics .External.graphics\n"
3152 :     ".subset .subset2\n"
3153 :     ".primTrace .primUntrace\n"
3154 :     "lazyLoadDBfetch\n"
3155 :     msgstr ""
3156 :    
3157 :     #. type: Plain text
3158 :     #: R-ints.texi:2167
3159 :     msgid "The multi-argument primitives"
3160 :     msgstr ""
3161 :    
3162 :     #. type: group
3163 :     #: R-ints.texi:2171
3164 :     #, no-wrap
3165 :     msgid ""
3166 :     "call switch\n"
3167 :     ".C .Fortran .Call .External\n"
3168 :     msgstr ""
3169 :    
3170 :     #. type: Plain text
3171 :     #: R-ints.texi:2179
3172 :     msgid "intentionally use positional matching, and need to do so to avoid partial matching to their first argument. They do check that the first argument is unnamed or for the first two, partially matches the formal argument name. On the other hand,"
3173 :     msgstr ""
3174 :    
3175 :     #. type: group
3176 :     #: R-ints.texi:2184
3177 :     #, no-wrap
3178 :     msgid ""
3179 :     "attr attr<- browser rememtrace substitute UseMethod\n"
3180 :     "log round signif rep seq.int\n"
3181 :     msgstr ""
3182 :    
3183 :     #. type: Plain text
3184 :     #: R-ints.texi:2189
3185 :     msgid "manage their own argument matching and do work in the standard way."
3186 :     msgstr ""
3187 :    
3188 :     #. type: Plain text
3189 :     #: R-ints.texi:2194
3190 :     msgid "All the one-argument primitives check that if they are called with a named argument that this (partially) matches the name given in the documentation: this is also done for replacement functions with one argument plus @code{value}."
3191 :     msgstr ""
3192 :    
3193 :     #. type: Plain text
3194 :     #: R-ints.texi:2199
3195 :     msgid "The net effect is that argument matching for primitives intended for end-user use @emph{as functions} is done in the same way as for interpreted functions except for the six exceptions where positional matching is required."
3196 :     msgstr ""
3197 :    
3198 :     #. type: node
3199 :     #: R-ints.texi:2205
3200 :     #: R-ints.texi:2207
3201 :     #: R-ints.texi:2208
3202 :     #: R-ints.texi:2233
3203 :     #, no-wrap
3204 :     msgid "Special primitives"
3205 :     msgstr ""
3206 :    
3207 :     #. type: node
3208 :     #: R-ints.texi:2205
3209 :     #: R-ints.texi:2207
3210 :     #: R-ints.texi:2233
3211 :     #: R-ints.texi:2234
3212 :     #: R-ints.texi:2241
3213 :     #, no-wrap
3214 :     msgid "Special internals"
3215 :     msgstr ""
3216 :    
3217 :     #. type: node
3218 :     #: R-ints.texi:2205
3219 :     #: R-ints.texi:2233
3220 :     #: R-ints.texi:2241
3221 :     #: R-ints.texi:2242
3222 :     #: R-ints.texi:2300
3223 :     #, no-wrap
3224 :     msgid "Prototypes for primitives"
3225 :     msgstr ""
3226 :    
3227 :     #. type: section
3228 :     #: R-ints.texi:2205
3229 :     #: R-ints.texi:2241
3230 :     #: R-ints.texi:2300
3231 :     #: R-ints.texi:2301
3232 :     #, no-wrap
3233 :     msgid "Adding a primitive"
3234 :     msgstr ""
3235 :    
3236 :     #. type: Plain text
3237 :     #: R-ints.texi:2218
3238 :     msgid "A small number of primitives are @emph{specials} rather than @emph{builtins}, that is they are entered with unevaluated arguments. This is clearly necessary for the language constructs and the assignment operators, as well as for @code{&&} and @code{||} which conditionally evaluate their second argument, and @code{~}, @code{.Internal}, @code{call}, @code{expression}, @code{missing}, @code{on.exit}, @code{quote} and @code{substitute} which do not evaluate some of their arguments."
3239 :     msgstr ""
3240 :    
3241 :     #. type: Plain text
3242 :     #: R-ints.texi:2221
3243 :     msgid "@code{rep} and @code{seq.int} are special as they evaluate some of their arguments conditional on which are non-missing."
3244 :     msgstr ""
3245 :    
3246 :     #. type: Plain text
3247 :     #: R-ints.texi:2224
3248 :     msgid "@code{log}, @code{round} and @code{signif} are special to allow default values to be given to missing arguments."
3249 :     msgstr ""
3250 :    
3251 :     #. type: Plain text
3252 :     #: R-ints.texi:2229
3253 :     msgid "The subsetting, subassignment and @code{@@} operators are all special. (For both extraction and replacement forms, @code{$} and @code{@@} take a symbol argument, and @code{[} and @code{[[} allow missing arguments.)"
3254 :     msgstr ""
3255 :    
3256 :     #. type: Plain text
3257 :     #: R-ints.texi:2232
3258 :     msgid "@code{UseMethod} is special to avoid the additional contexts added to calls to builtins."
3259 :     msgstr ""
3260 :    
3261 :     #. type: Plain text
3262 :     #: R-ints.texi:2240
3263 :     msgid "There are also special @code{.Internal} functions: @code{NextMethod}, @code{Recall}, @code{withVisible}, @code{cbind}, @code{rbind} (to allow for the @code{deparse.level} argument), @code{eapply}, @code{lapply} and @code{vapply}."
3264 :     msgstr ""
3265 :    
3266 :     #. type: Plain text
3267 :     #: R-ints.texi:2253
3268 :     msgid "Prototypes are available for the primitive functions and operators, and these are used for printing, @code{args} and package checking (e.g.@: by @code{tools::checkS3methods} and by package @CRANpkg{codetools}). There are two environments in the @pkg{base} package (and namespace), @samp{.GenericArgsEnv} for those primitives which are internal S3 generics, and @samp{.ArgsEnv} for the rest. Those environments contain closures with the same names as the primitives, formal arguments derived (manually) from the help pages, a body which is a suitable call to @code{UseMethod} or @code{NULL} and environment the base namespace."
3269 :     msgstr ""
3270 :    
3271 :     #. type: Plain text
3272 :     #: R-ints.texi:2257
3273 :     msgid "The C code for @code{print.default} and @code{args} uses the closures in these environments in preference to the definitions in base (as primitives)."
3274 :     msgstr ""
3275 :    
3276 :     #. type: Plain text
3277 :     #: R-ints.texi:2262
3278 :     msgid "The QC function @code{undoc} checks that all the functions prototyped in these environments are currently primitive, and that the primitives not included are better thought of as language elements (at the time of writing"
3279 :     msgstr ""
3280 :    
3281 :     #. type: example
3282 :     #: R-ints.texi:2266
3283 :     #, no-wrap
3284 :     msgid ""
3285 :     "$ $<- && ( : @@ @@<- [ [[ [[<- [<- @{ || ~ <- <<- =\n"
3286 :     "break for function if next repeat return while\n"
3287 :     msgstr ""
3288 :    
3289 :     #. type: Plain text
3290 :     #: R-ints.texi:2272
3291 :     msgid "). One could argue about @code{~}, but it is known to the parser and has semantics quite unlike a normal function. And @code{:} is documented with different argument names in its two meanings.)"
3292 :     msgstr ""
3293 :    
3294 :     #. type: Plain text
3295 :     #: R-ints.texi:2291
3296 :     msgid "The QC functions @code{codoc} and @code{checkS3methods} also make use of these environments (effectively placing them in front of base in the search path), and hence the formals of the functions they contain are checked against the help pages by @code{codoc}. However, there are two problems with the generic primitives. The first is that many of the operators are part of the S3 group generic @code{Ops} and that defines their arguments to be @code{e1} and @code{e2}: although it would be very unusual, an operator could be called as e.g.@: @code{\"+\"(e1=a, e2=b)} and if method dispatch occurred to a closure, there would be an argument name mismatch. So the definitions in environment @code{.GenericArgsEnv} have to use argument names @code{e1} and @code{e2} even though the traditional documentation is in terms of @code{x} and @code{y}: @code{codoc} makes the appropriate adjustment via @code{tools:::.make_S3_primitive_generic_env}. The second discrepancy is with the @code{Math} group generics, where the group generic is defined with argument list @code{(x, ...)}, but most of the members only allow one argument when used as the default method (and @code{round} and @code{signif} allow two as default methods): again fix-ups are used."
3297 :     msgstr ""
3298 :    
3299 :     #. type: Plain text
3300 :     #: R-ints.texi:2299
3301 :     msgid "Those primitives which are in @code{.GenericArgsEnv} are checked (via @file{tests/primitives.R}) to be generic @emph{via} defining methods for them, and a check is made that the remaining primitives are probably not generic, by setting a method and checking it is not dispatched to (but this can fail for other reasons). However, there is no certain way to know that if other @code{.Internal} or primitive functions are not internally generic except by reading the source code."
3302 :     msgstr ""
3303 :    
3304 :     #. type: Plain text
3305 :     #: R-ints.texi:2306
3306 :     msgid "[For R-core use: reverse this procedure to remove a primitive. Most commonly this is done by changing a @code{.Internal} to a primitive or @emph{vice versa}.]"
3307 :     msgstr ""
3308 :    
3309 :     #. type: Plain text
3310 :     #: R-ints.texi:2310
3311 :     msgid "Primitives are listed in the table @code{R_FunTab} in @file{src/main/names.c}: primitives have @samp{Y = 0} in the @samp{eval} field."
3312 :     msgstr ""
3313 :    
3314 :     #. type: Plain text
3315 :     #: R-ints.texi:2314
3316 :     msgid "There needs to be an @samp{\\alias} entry in a help file in the @pkg{base} package, and the primitive needs to be added to one of the lists at the start of this section."
3317 :     msgstr ""
3318 :    
3319 :     #. type: Plain text
3320 :     #: R-ints.texi:2320
3321 :     msgid "Some primitives are regarded as language elements (the current ones are listed above). These need to be added to two lists of exceptions, @code{langElts} in @code{undoc()} (in file @file{src/library/tools/R/QC.R}) and @code{lang_elements} in @file{tests/primitives.R}."
3322 :     msgstr ""
3323 :    
3324 :     #. type: Plain text
3325 :     #: R-ints.texi:2329
3326 :     msgid "All other primitives are regarded as functions and should be listed in one of the environments defined in @file{src/library/base/R/zzz.R}, either @code{.ArgsEnv} or @code{.GenericArgsEnv}: internal generics also need to be listed in the character vector @code{.S3PrimitiveGenerics}. Note too the discussion about argument matching above: if you add a primitive function with more than one argument by converting a @code{.Internal} you need to add argument matching to the C code, and for those with a single argument, add argument-name checking."
3327 :     msgstr ""
3328 :    
3329 :     #. type: Plain text
3330 :     #: R-ints.texi:2332
3331 :     msgid "Do ensure that @command{make check-devel} has been run: that tests most of these requirements."
3332 :     msgstr ""
3333 :    
3334 :     #. type: Plain text
3335 :     #: R-ints.texi:2338
3336 :     msgid "The process of marking messages (errors, warnings etc) for translation in an @R{} package is described in"
3337 :     msgstr ""
3338 :    
3339 :     #. type: ifset
3340 :     #: R-ints.texi:2340
3341 :     msgid "@ref{Internationalization, , Internationalization, R-exts, Writing R Extensions},"
3342 :     msgstr ""
3343 :    
3344 :     #. type: ifclear
3345 :     #: R-ints.texi:2343
3346 :     msgid "`Writing R Extensions',"
3347 :     msgstr ""
3348 :    
3349 :     #. type: Plain text
3350 :     #: R-ints.texi:2347
3351 :     msgid "and the standard packages included with @R{} have (with an exception in @pkg{grDevices} for the menus of the @code{windows()} device) been internationalized in the same way as other packages."
3352 :     msgstr ""
3353 :    
3354 :     #. type: node
3355 :     #: R-ints.texi:2354
3356 :     #: R-ints.texi:2356
3357 :     #: R-ints.texi:2357
3358 :     #: R-ints.texi:2373
3359 :     #, no-wrap
3360 :     msgid "R code"
3361 :     msgstr ""
3362 :    
3363 :     #. type: node
3364 :     #: R-ints.texi:2354
3365 :     #: R-ints.texi:2356
3366 :     #: R-ints.texi:2373
3367 :     #: R-ints.texi:2374
3368 :     #: R-ints.texi:2419
3369 :     #, no-wrap
3370 :     msgid "Main C code"
3371 :     msgstr ""
3372 :    
3373 :     #. type: node
3374 :     #: R-ints.texi:2354
3375 :     #: R-ints.texi:2373
3376 :     #: R-ints.texi:2419
3377 :     #: R-ints.texi:2420
3378 :     #: R-ints.texi:2449
3379 :     #, no-wrap
3380 :     msgid "Windows-GUI-specific code"
3381 :     msgstr ""
3382 :    
3383 :     #. type: node
3384 :     #: R-ints.texi:2354
3385 :     #: R-ints.texi:2419
3386 :     #: R-ints.texi:2449
3387 :     #: R-ints.texi:2450
3388 :     #: R-ints.texi:2456
3389 :     #, no-wrap
3390 :     msgid "OS X GUI"
3391 :     msgstr ""
3392 :    
3393 :     #. type: section
3394 :     #: R-ints.texi:2354
3395 :     #: R-ints.texi:2449
3396 :     #: R-ints.texi:2456
3397 :     #: R-ints.texi:2457
3398 :     #, no-wrap
3399 :     msgid "Updating"
3400 :     msgstr ""
3401 :    
3402 :     #. type: Plain text
3403 :     #: R-ints.texi:2366
3404 :     msgid "Internationalization for @R{} code is done in exactly the same way as for extension packages. As all standard packages which have @R{} code also have a namespace, it is never necessary to specify @code{domain}, but for efficiency calls to @code{message}, @code{warning} and @code{stop} should include @code{domain = NA} when the message is constructed @emph{via} @code{gettextf}, @code{gettext} or @code{ngettext}."
3405 :     msgstr ""
3406 :    
3407 :     #. type: Plain text
3408 :     #: R-ints.texi:2372
3409 :     msgid "For each package, the extracted messages and translation sources are stored under package directory @file{po} in the source package, and compiled translations under @file{inst/po} for installation to package directory @file{po} in the installed package. This also applies to C code in packages."
3410 :     msgstr ""
3411 :    
3412 :     #. type: Plain text
3413 :     #: R-ints.texi:2381
3414 :     msgid "The main C code (e.g.@: that in files @file{src/*/*.c} and in the modules) is where @R{} is closest to the sort of application for which @samp{gettext} was written. Messages in the main C code are in domain @code{R} and stored in the top-level directory @file{po} with compiled translations under @file{share/locale}."
3415 :     msgstr ""
3416 :    
3417 :     #. type: Plain text
3418 :     #: R-ints.texi:2384
3419 :     msgid "The list of files covered by the @R{} domain is specified in file @file{po/POTFILES.in}."
3420 :     msgstr ""
3421 :    
3422 :     #. type: Plain text
3423 :     #: R-ints.texi:2390
3424 :     msgid "The normal way to mark messages for translation is via @code{_(\"msg\")} just as for packages. However, sometimes one needs to mark passages for translation without wanting them translated at the time, for example when declaring string constants. This is the purpose of the @code{N_} macro, for example"
3425 :     msgstr ""
3426 :    
3427 :     #. type: example
3428 :     #: R-ints.texi:2393
3429 :     #, no-wrap
3430 :     msgid "@{ ERROR_ARGTYPE, N_(\"invalid argument type\")@},\n"
3431 :     msgstr ""
3432 :    
3433 :     #. type: Plain text
3434 :     #: R-ints.texi:2397
3435 :     msgid "from file @file{src/main/errors.c}."
3436 :     msgstr ""
3437 :    
3438 :     #. type: Plain text
3439 :     #: R-ints.texi:2399
3440 :     msgid "The @code{P_} macro"
3441 :     msgstr ""
3442 :    
3443 :     #. type: example
3444 :     #: R-ints.texi:2406
3445 :     #, no-wrap
3446 :     msgid ""
3447 :     "#ifdef ENABLE_NLS\n"
3448 :     "#define P_(StringS, StringP, N) ngettext (StringS, StringP, N)\n"
3449 :     "#else\n"
3450 :     "#define P_(StringS, StringP, N) (N > 1 ? StringP: StringS)\n"
3451 :     "#endif\n"
3452 :     msgstr ""
3453 :    
3454 :     #. type: Plain text
3455 :     #: R-ints.texi:2413
3456 :     msgid "may be used as a wrapper for @code{ngettext}: however in some cases the preferred approach has been to conditionalize (on @code{ENABLE_NLS}) code using @code{ngettext}."
3457 :     msgstr ""
3458 :    
3459 :     #. type: Plain text
3460 :     #: R-ints.texi:2417
3461 :     msgid "The macro @code{_(\"msg\")} can safely be used in directory @file{src/appl}; the header for standalone @samp{nmath} skips possible translation. (This does not apply to @code{N_} or @code{P_})."
3462 :     msgstr ""
3463 :    
3464 :     #. type: Plain text
3465 :     #: R-ints.texi:2424
3466 :     msgid "Messages for the Windows GUI are in a separate domain @samp{RGui}. This was done for two reasons:"
3467 :     msgstr ""
3468 :    
3469 :     #. type: itemize
3470 :     #: R-ints.texi:2429
3471 :     msgid "The translators for the Windows version of @R{} might be separate from those for the rest of @R{} (familiarity with the GUI helps), and"
3472 :     msgstr ""
3473 :    
3474 :     #. type: itemize
3475 :     #: R-ints.texi:2435
3476 :     msgid "Messages for Windows are most naturally handled in the native charset for the language, and in the case of CJK languages the charset is Windows-specific. (It transpires that as the @code{iconv} we ported works well under Windows, this is less important than anticipated.)"
3477 :     msgstr ""
3478 :    
3479 :     #. type: Plain text
3480 :     #: R-ints.texi:2444
3481 :     msgid "Messages for the @samp{RGui} domain are marked by @code{G_(\"msg\")}, a macro that is defined in header file @file{src/gnuwin32/win-nls.h}. The list of files that are considered is hardcoded in the @code{RGui.pot-update} target of file @file{po/Makefile.in.in}: note that this includes @file{devWindows.c} as the menus on the @code{windows} device are considered to be part of the GUI. (There is also @code{GN_(\"msg\")}, the analogue of @code{N_(\"msg\")}.)"
3482 :     msgstr ""
3483 :    
3484 :     #. type: Plain text
3485 :     #: R-ints.texi:2447
3486 :     msgid "The template and message catalogs for the @samp{RGui} domain are in the top-level @file{po} directory."
3487 :     msgstr ""
3488 :    
3489 :     #. type: Plain text
3490 :     #: R-ints.texi:2454
3491 :     msgid "This is handled separately: see @uref{http://developer.r-project.org/Translations.html}."
3492 :     msgstr ""
3493 :    
3494 :     #. type: Plain text
3495 :     #: R-ints.texi:2460
3496 :     msgid "See file @file{po/README} for how to update the message templates and catalogs."
3497 :     msgstr ""
3498 :    
3499 :     #. type: chapter
3500 :     #: R-ints.texi:2462
3501 :     #, no-wrap
3502 :     msgid "Structure of an Installed Package"
3503 :     msgstr ""
3504 :    
3505 :     #. type: node
3506 :     #: R-ints.texi:2467
3507 :     #: R-ints.texi:2515
3508 :     #: R-ints.texi:2516
3509 :     #: R-ints.texi:2586
3510 :     #, no-wrap
3511 :     msgid "Metadata"
3512 :     msgstr ""
3513 :    
3514 :     #. type: section
3515 :     #: R-ints.texi:2467
3516 :     #: R-ints.texi:2515
3517 :     #: R-ints.texi:2586
3518 :     #: R-ints.texi:2587
3519 :     #, no-wrap
3520 :     msgid "Help"
3521 :     msgstr ""
3522 :    
3523 :     #. type: Plain text
3524 :     #: R-ints.texi:2472
3525 :     msgid "The structure of a @emph{source} packages is described in @ref{Creating R packages, , Creating R packages, R-exts, Writing R Extensions}: this chapter is concerned with the structure of @emph{installed} packages."
3526 :     msgstr ""
3527 :    
3528 :     #. type: Plain text
3529 :     #: R-ints.texi:2484
3530 :     msgid "An installed package has a top-level file @file{DESCRIPTION}, a copy of the file of that name in the package sources with a @samp{Built} field appended, and file @file{INDEX}, usually describing the objects on which help is available, a file @file{NAMESPACE} if the package has a name space, optional files such as @file{CITATION}, @file{LICENCE} and @file{NEWS}, and any other files copied in from @file{inst}. It will have directories @file{Meta}, @file{help} and @file{html} (even if the package has no help pages), almost always has a directory @file{R} and often has a directory @file{libs} to contain compiled code. Other directories with known meaning to @R{} are @file{data}, @file{demo}, @file{doc} and @file{po}."
3531 :     msgstr ""
3532 :    
3533 :     #. type: Plain text
3534 :     #: R-ints.texi:2493
3535 :     msgid "Function @code{library} looks for a namespace and if one is found passes control to @code{loadNamespace}. Then @code{library} or @code{loadNamespace} looks for file @file{R/@var{pkgname}}, warns if it is not found and otherwise sources the code (using @code{sys.source}) into the package's environment, then lazy-loads a database @file{R/sysdata} if present. So how @R{} code gets loaded depends on the contents of @file{R/@var{pkgname}}: a standard template to load lazy-load databases are provided in @file{share/R/nspackloader.R}."
3536 :     msgstr ""
3537 :    
3538 :     #. type: Plain text
3539 :     #: R-ints.texi:2500
3540 :     msgid "Compiled code is usually loaded when the package's namespace is loaded by a @code{useDynlib} directive in a @file{NAMESPACE} file or by the package's @code{.onLoad} function. Conventionally compiled code is loaded by a call to @code{library.dynam} and this looks in directory @file{libs} (and in an appropriate sub-directory if sub-architectures are in use) for a shared object (Unix-alike) or DLL (Windows)."
3541 :     msgstr ""
3542 :    
3543 :     #. type: Plain text
3544 :     #: R-ints.texi:2508
3545 :     msgid "Subdirectory @file{data} serves two purposes. In a package using lazy-loading of data, it contains a lazy-load database @file{Rdata}, plus a file @file{Rdata.rds} which contain a named character vector used by @code{data()} in the (unusual) event that it is used for such a package. Otherwise it is a copy of the @file{data} directory in the sources, with saved images re-compressed if @command{R CMD INSTALL --resave-data} was used."
3546 :     msgstr ""
3547 :    
3548 :     #. type: Plain text
3549 :     #: R-ints.texi:2511
3550 :     msgid "Subdirectory @file{demo} supports the @code{demo} function, and is copied from the sources."
3551 :     msgstr ""
3552 :    
3553 :     #. type: Plain text
3554 :     #: R-ints.texi:2514
3555 :     msgid "Subdirectory @file{po} contains (in subdirectories) compiled message catalogs."
3556 :     msgstr ""
3557 :    
3558 :     #. type: Plain text
3559 :     #: R-ints.texi:2524
3560 :     msgid "Directory @file{Meta} contains several files in @code{.rds} format, that is serialized @R{} objects written by @code{saveRDS}. All packages have files @file{Rd.rds}, @file{hsearch.rds}, @file{links.rds} and @file{package.rds}. Packages with namespaces have a file @file{nsInfo.rds}, and those with data, demos or vignettes have @file{data.rds}, @file{demo.rds} or @file{vignette.rds} files."
3561 :     msgstr ""
3562 :    
3563 :     #. type: Plain text
3564 :     #: R-ints.texi:2529
3565 :     msgid "The structure of these files (and their existence and names) is private to @R{}, so the description here is for those trying to follow the @R{} sources: there should be no reference to these files in non-base packages."
3566 :     msgstr ""
3567 :    
3568 :     #. type: Plain text
3569 :     #: R-ints.texi:2546
3570 :     msgid "File @file{package.rds} is a dump of information extracted from the @file{DESCRIPTION} file. It is a list of several components. The first, @samp{DESCRIPTION}, is a character vector, the @file{DESCRIPTION} file as read by @code{read.dcf}. Further elements @samp{Depends}, @samp{Suggests}, @samp{Imports}, @samp{Rdepends} and @samp{Rdepends2} record the @samp{Depends}, @samp{Suggests} and @samp{Imports} fields. These are all lists, and can be empty. The first three have an entry for each package named, each entry being a list of length 1 or 3, which element @samp{name} (the package name) and optional elements @samp{op} (a character string) and @samp{version} (an object of class @samp{\"package_version\"}). Element @samp{Rdepends} is used for the first version dependency on @R{}, and @samp{Rdepends2} is a list of zero or more @R{} version dependencies---each is a three-element list of the form described for packages. Element @samp{Rdepends} is no longer used, but it is still potentially needed so @R{} < 2.7.0 can detect that the package was not installed for it."
3571 :     msgstr ""
3572 :    
3573 :     #. type: Plain text
3574 :     #: R-ints.texi:2549
3575 :     msgid "File @file{nsInfo.rds} records a list, a parsed version of the @file{NAMESPACE} file."
3576 :     msgstr ""
3577 :    
3578 :     #. type: Plain text
3579 :     #: R-ints.texi:2556
3580 :     msgid "File @file{Rd.rds} records a data frame with one row for each help file. The columns are @samp{File} (the file name with extension), @samp{Name} (the @samp{\\name} section), @samp{Type} (from the optional @samp{\\docType} section), @samp{Title}, @samp{Encoding}, @samp{Aliases}, @samp{Concepts} and @samp{Keywords}. All columns are character vectors apart from @samp{Aliases}, which is a list of character vectors."
3581 :     msgstr ""
3582 :    
3583 :     #. type: Plain text
3584 :     #: R-ints.texi:2567
3585 :     msgid "File @file{hsearch.rds} records the information to be used by @samp{help.search}. This is a list of four unnamed elements which are character matrices for help files, aliases, keywords and concepts. All the matrices have columns @samp{ID} and @samp{Package} which are used to tie the aliases, keywords and concepts (the remaining column of the last three elements) to a particular help file. The first element has further columns @samp{LibPath} (stored as @code{\"\"} and filled in what the file is loaded), @samp{name}, @samp{title}, @samp{topic} (the first alias, used when presenting the results as @samp{@var{pkgname}::@var{topic}}) and @samp{Encoding}."
3586 :     msgstr ""
3587 :    
3588 :     #. type: Plain text
3589 :     #: R-ints.texi:2570
3590 :     msgid "File @file{links.rds} records a named character vector, the names being aliases and the values character strings of the form"
3591 :     msgstr ""
3592 :    
3593 :     #. type: example
3594 :     #: R-ints.texi:2572
3595 :     #, no-wrap
3596 :     msgid "\"../../@var{pkgname}/html/@var{filename}.html\"\n"
3597 :     msgstr ""
3598 :    
3599 :     #. type: Plain text
3600 :     #: R-ints.texi:2577
3601 :     msgid "File @file{data.rds} records a two-column character matrix with columns of dataset names and titles from the corresponding help file. File @file{demo.rds} has the same structure for package demos."
3602 :     msgstr ""
3603 :    
3604 :     #. type: Plain text
3605 :     #: R-ints.texi:2584
3606 :     msgid "File @file{vignette.rds} records a dataframe with one row for each `vignette' (@file{.[RS]nw} file in @file{inst/doc}) and with columns @samp{File} (the full file path in the sources), @samp{Title}, @samp{PDF} (the pathless file name of the installed PDF version, if present), @samp{Depends}, @samp{Keywords} and @samp{R} (the pathless file name of the installed @R{} code, if present)."
3607 :     msgstr ""
3608 :    
3609 :     #. type: Plain text
3610 :     #: R-ints.texi:2593
3611 :     msgid "All installed packages, whether they had any @file{.Rd} files or not, have @file{help} and @file{html} directories. The latter normally only contains the single file @file{00Index.html}, the package index which has hyperlinks to the help topics (if any)."
3612 :     msgstr ""
3613 :    
3614 :     #. type: Plain text
3615 :     #: R-ints.texi:2600
3616 :     msgid "Directory @file{help} contains files @file{AnIndex}, @file{paths.rds} and @file{@var{pkgname}.rd[bx]}. The latter two files are a lazy-load database of parsed @file{.Rd} files, accessed by @code{tools:::fetchRdDB}. File @file{paths.rds} is a saved character vector of the original path names of the @file{.Rd} files, used when updating the database."
3617 :     msgstr ""
3618 :    
3619 :     #. type: Plain text
3620 :     #: R-ints.texi:2607
3621 :     msgid "File @file{AnIndex} is a two-column tab-delimited file: the first column contains the aliases defined in the help files and the second the basename (without the @file{.Rd} or @file{.rd} extension) of the file containing that alias. It is read by @code{utils:::index.search} to search for files matching a topic (alias), and read by @code{scan} in @code{utils:::matchAvailableTopics}, part of the completion system."
3622 :     msgstr ""
3623 :    
3624 :     #. type: Plain text
3625 :     #: R-ints.texi:2611
3626 :     msgid "File @file{aliases.rds} is the same information as @file{AnIndex} as a named character vector (names the topics, values the file basename), for faster access."
3627 :     msgstr ""
3628 :    
3629 :     #. type: Plain text
3630 :     #: R-ints.texi:2619
3631 :     msgid "@R{} provides many functions to work with files and directories: many of these have been added relatively recently to facilitate scripting in @R{} and in particular the replacement of Perl scripts by @R{} scripts in the management of @R{} itself."
3632 :     msgstr ""
3633 :    
3634 :     #. type: Plain text
3635 :     #: R-ints.texi:2626
3636 :     msgid "These functions are implemented by standard C/POSIX library calls, except on Windows. That means that filenames must be encoded in the current locale as the OS provides no other means to access the file system: increasingly filenames are stored in UTF-8 and the OS will translate filenames to UTF-8 in other locales. So using a UTF-8 locale gives transparent access to the whole file system."
3637 :     msgstr ""
3638 :    
3639 :     #. type: Plain text
3640 :     #: R-ints.texi:2639
3641 :     msgid "Windows is another story. There the internal view of filenames is in UTF-16LE (so-called `Unicode'), and standard C library calls can only access files whose names can be expressed in the current codepage. To circumvent that restriction, there is a parallel set of Windows-specific calls which take wide-character arguments for filepaths. Much of the file-handling in @R{} has been moved over to using these functions, so filenames can be manipulated in @R{} as UTF-8 encoded character strings, converted to wide characters (which on Windows are UTF-16LE) and passed to the OS. The utilities @code{RC_fopen} and @code{filenameToWchar} help this process. Currently @code{file.copy} to a directory, @code{list.files}, @code{list.dirs} and @code{path.expand} work only with filepaths encoded in the current codepage."
3642 :     msgstr ""
3643 :    
3644 :     #. type: Plain text
3645 :     #: R-ints.texi:2642
3646 :     msgid "All these functions do tilde expansion, in the same way as @code{path.expand}, with the deliberate exception of @code{Sys.glob}."
3647 :     msgstr ""
3648 :    
3649 :     #. type: Plain text
3650 :     #: R-ints.texi:2649
3651 :     msgid "File names may be case sensitive or not: the latter is the norm on Windows and OS X, the former on other Unix-alikes. Note that this is a property of both the OS and the file system: it is often possible to map names to upper or lower case when mounting the file system. This can affect the matching of patterns in @code{list.files} and @code{Sys.glob}."
3652 :     msgstr ""
3653 :    
3654 :     #. type: Plain text
3655 :     #: R-ints.texi:2654
3656 :     msgid "File names commonly contain spaces on Windows and OS X but not elsewhere. As file names are handled as character strings by @R{}, spaces are not usually a concern unless file names are passed to other process, e.g.@: by a @code{system} call."
3657 :     msgstr ""
3658 :    
3659 :     #. type: Plain text
3660 :     #: R-ints.texi:2668
3661 :     msgid "Windows has another couple of peculiarities. Whereas a POSIX file system has a single root directory (and other physical file systems are mounted onto logical directories under that root), Windows has separate roots for each physical or logical file system (`volume'), organized under @emph{drives} (with file paths starting @code{D:} for an @acronym{ASCII} letter, case-insensitively) and @emph{network shares} (with paths like @code{\\netname\\topdir\\myfiles\\a file}. There is a current drive, and path names without a drive part are relative to the current drive. Further, each drive has a current directory, and relative paths are relative to that current directory, on a particular drive if one is specified. So @file{D:dir\\file} and @file{D:} are valid path specifications (the last being the current directory on drive @file{D:})."
3662 :     msgstr ""
3663 :    
3664 :     #. type: chapter
3665 :     #: R-ints.texi:2699
3666 :     #, no-wrap
3667 :     msgid "Graphics"
3668 :     msgstr ""
3669 :    
3670 :     #. type: Plain text
3671 :     #: R-ints.texi:2708
3672 :     msgid "@R{}'s graphics internals were re-designed to enable multiple graphics systems to be installed on top on the graphics `engine' -- currently there are two such systems, one supporting `base' graphics (based on that in S and whose @R{} code@footnote{The C code is in files @code{base.c}, @code{graphics.c}, @code{par.c}, @code{plot.c} and @code{plot3d.c} in directory @file{src/main}.} is in package @pkg{graphics}) and one implemented in package @pkg{grid}."
3673 :     msgstr ""
3674 :    
3675 :     #. type: Plain text
3676 :     #: R-ints.texi:2712
3677 :     msgid "Some notes on the historical changes can be found at @uref{http://www.stat.auckland.ac.nz/@/~paul/@/R/basegraph.html} and @uref{http://www.stat.auckland.ac.nz/@/~paul/R/@/graphicsChanges.html}."
3678 :     msgstr ""
3679 :    
3680 :     #. type: Plain text
3681 :     #: R-ints.texi:2716
3682 :     msgid "At the lowest level is a graphics device, which manages a plotting surface (a screen window or a representation to be written to a file). This implements a set of graphics primitives, to `draw'"
3683 :     msgstr ""
3684 :    
3685 :     #. type: item
3686 :     #: R-ints.texi:2718
3687 :     #, no-wrap
3688 :     msgid "a circle, optionally filled"
3689 :     msgstr ""
3690 :    
3691 :     #. type: item
3692 :     #: R-ints.texi:2719
3693 :     #, no-wrap
3694 :     msgid "a rectangle, optionally filled"
3695 :     msgstr ""
3696 :    
3697 :     #. type: item
3698 :     #: R-ints.texi:2720
3699 :     #, no-wrap
3700 :     msgid "a line"
3701 :     msgstr ""
3702 :    
3703 :     #. type: item
3704 :     #: R-ints.texi:2721
3705 :     #, no-wrap
3706 :     msgid "a set of connected lines"
3707 :     msgstr ""
3708 :    
3709 :     #. type: item
3710 :     #: R-ints.texi:2722
3711 :     #, no-wrap
3712 :     msgid "a polygon, optionally filled"
3713 :     msgstr ""
3714 :    
3715 :     #. type: item
3716 :     #: R-ints.texi:2723
3717 :     #, no-wrap
3718 :     msgid "a paths, optionally filled using a winding rule"
3719 :     msgstr ""
3720 :    
3721 :     #. type: item
3722 :     #: R-ints.texi:2724
3723 :     #, no-wrap
3724 :     msgid "text"
3725 :     msgstr ""
3726 :    
3727 :     #. type: item
3728 :     #: R-ints.texi:2725
3729 :     #, no-wrap
3730 :     msgid "a raster image (optional)"
3731 :     msgstr ""
3732 :    
3733 :     #. type: item
3734 :     #: R-ints.texi:2726
3735 :     #, no-wrap
3736 :     msgid "and to set a clipping rectangle"
3737 :     msgstr ""
3738 :    
3739 :     #. type: Plain text
3740 :     #: R-ints.texi:2731
3741 :     msgid "as well as requests for information such as"
3742 :     msgstr ""
3743 :    
3744 :     #. type: item
3745 :     #: R-ints.texi:2733
3746 :     #, no-wrap
3747 :     msgid "the width of a string if plotted"
3748 :     msgstr ""
3749 :    
3750 :     #. type: item
3751 :     #: R-ints.texi:2734
3752 :     #, no-wrap
3753 :     msgid "the metrics (width, ascent, descent) of a single character"
3754 :     msgstr ""
3755 :    
3756 :     #. type: item
3757 :     #: R-ints.texi:2735
3758 :     #, no-wrap
3759 :     msgid "the current size of the plotting surface"
3760 :     msgstr ""
3761 :    
3762 :     #. type: Plain text
3763 :     #: R-ints.texi:2740
3764 :     msgid "and requests/opportunities to take action such as"
3765 :     msgstr ""
3766 :    
3767 :     #. type: item
3768 :     #: R-ints.texi:2742
3769 :     #, no-wrap
3770 :     msgid "start a new `page', possibly after responding to a request to ask"
3771 :     msgstr ""
3772 :    
3773 :     #. type: itemize
3774 :     #: R-ints.texi:2744
3775 :     msgid "the user for confirmation."
3776 :     msgstr ""
3777 :    
3778 :     #. type: item
3779 :     #: R-ints.texi:2744
3780 :     #, no-wrap
3781 :     msgid "return the position of the device pointer (if any)."
3782 :     msgstr ""
3783 :    
3784 :     #. type: item
3785 :     #: R-ints.texi:2745
3786 :     #, no-wrap
3787 :     msgid "when a device become the current device or stops being the current"
3788 :     msgstr ""
3789 :    
3790 :     #. type: itemize
3791 :     #: R-ints.texi:2748
3792 :     msgid "device (this is usually used to change the window title on a screen device)."
3793 :     msgstr ""
3794 :    
3795 :     #. type: item
3796 :     #: R-ints.texi:2748
3797 :     #, no-wrap
3798 :     msgid "when drawing starts or finishes (e.g. used to flush graphics to"
3799 :     msgstr ""
3800 :    
3801 :     #. type: itemize
3802 :     #: R-ints.texi:2750
3803 :     msgid "the screen when drawing stops)."
3804 :     msgstr ""
3805 :    
3806 :     #. type: item
3807 :     #: R-ints.texi:2750
3808 :     #, no-wrap
3809 :     msgid "wait for an event, for example a mouse click or keypress."
3810 :     msgstr ""
3811 :    
3812 :     #. type: item
3813 :     #: R-ints.texi:2751
3814 :     #, no-wrap
3815 :     msgid "an `onexit' action, to clean up if plotting is interrupted (by an"
3816 :     msgstr ""
3817 :    
3818 :     #. type: itemize
3819 :     #: R-ints.texi:2753
3820 :     msgid "error or by the user)."
3821 :     msgstr ""
3822 :    
3823 :     #. type: item
3824 :     #: R-ints.texi:2753
3825 :     #, no-wrap
3826 :     msgid "capture the current contents of the device as a raster image."
3827 :     msgstr ""
3828 :    
3829 :     #. type: item
3830 :     #: R-ints.texi:2754
3831 :     #, no-wrap
3832 :     msgid "close the device."
3833 :     msgstr ""
3834 :    
3835 :     #. type: Plain text
3836 :     #: R-ints.texi:2764
3837 :     msgid "The device also sets a number of variables, mainly Boolean flags indicating its capabilities. Devices work entirely in `device units' which are up to its developer: they can be in pixels, big points (1/72 inch), twips, @dots{}, and can differ@footnote{although that needs to be handled carefully, as for example the @code{circle} callback is given a radius (and that should be interpreted as in the x units).} in the @samp{x} and @samp{y} directions."
3838 :     msgstr ""
3839 :    
3840 :     #. type: Plain text
3841 :     #: R-ints.texi:2773
3842 :     msgid "The next layer up is the graphics `engine' that is the main interface to the device (although the graphics subsystems do talk directly to devices). This is responsible for clipping lines, rectangles and polygons, converting the @code{pch} values @code{0...26} to sets of lines/circles, centring (and otherwise adjusting) text, rendering mathematical expressions (`plotmath') and mapping colour descriptions such as names to the internal representation."
3843 :     msgstr ""
3844 :    
3845 :     #. type: Plain text
3846 :     #: R-ints.texi:2791
3847 :     msgid "Another function of the engine is to manage display lists and snapshots. Some but not all instances of graphics devices maintain display lists, a `list' of operations that have been performed on the device to produce the current plot (since the device was opened or the plot was last cleared, e.g.@: by @code{plot.new}). Screen devices generally maintain a display list to handle repaint and resize events whereas file-based formats do not---display lists are also used to implement @code{dev.copy()} and friends. The display list is a pairlist of @code{.Internal} (base graphics) or @code{.Call.graphics} (grid graphics) calls, which means that the C code implementing a graphics operation will be re-called when the display list is replayed: apart from the part which records the operation if successful."
3848 :     msgstr ""
3849 :    
3850 :     #. type: Plain text
3851 :     #: R-ints.texi:2797
3852 :     msgid "Snapshots of the current graphics state are taken by @code{GEcreateSnapshot} and replayed later in the session by @code{GEplaySnapshot}. These are used by @code{recordPlot()}, @code{replayPlot()} and the GUI menus of the @code{windows()} device. The `state' includes the display list."
3853 :     msgstr ""
3854 :    
3855 :     #. type: Plain text
3856 :     #: R-ints.texi:2808
3857 :     msgid "The top layer comprises the graphics subsystems. Although there is provision for 24 subsystems since about 2001, currently still only two exist, `base' and `grid'. The base subsystem is registered with the engine when @R{} is initialized, and unregistered (via @code{KillAllDevices}) when an @R{} session is shut down. The grid subsystem is registered in its @code{.onLoad} function and unregistered in the @code{.onUnload} function. The graphics subsystem may also have `state' information saved in a snapshot (currently base does and grid does not)."
3858 :     msgstr ""
3859 :    
3860 :     #. type: Plain text
3861 :     #: R-ints.texi:2816
3862 :     msgid "Package @pkg{grDevices} was originally created to contain the basic graphics devices (although @code{X11} is in a separate load-on-demand module because of the volume of external libraries it brings in). Since then it has been used for other functionality that was thought desirable for use with @pkg{grid}, and hence has been transferred from package @pkg{graphics} to @pkg{grDevices}. This is principally concerned with the handling of colours and recording and replaying plots."
3863 :     msgstr ""
3864 :    
3865 :     #. type: node
3866 :     #: R-ints.texi:2822
3867 :     #: R-ints.texi:2824
3868 :     #: R-ints.texi:2842
3869 :     #: R-ints.texi:2950
3870 :     #: R-ints.texi:2997
3871 :     #: R-ints.texi:3157
3872 :     #: R-ints.texi:3212
3873 :     #: R-ints.texi:3243
3874 :     #: R-ints.texi:3265
3875 :     #: R-ints.texi:3399
3876 :     #, no-wrap
3877 :     msgid "Graphics devices"
3878 :     msgstr ""
3879 :    
3880 :     #. type: node
3881 :     #: R-ints.texi:2822
3882 :     #: R-ints.texi:2824
3883 :     #: R-ints.texi:3399
3884 :     #: R-ints.texi:3400
3885 :     #: R-ints.texi:3488
3886 :     #, no-wrap
3887 :     msgid "Colours"
3888 :     msgstr ""
3889 :    
3890 :     #. type: node
3891 :     #: R-ints.texi:2822
3892 :     #: R-ints.texi:3399
3893 :     #: R-ints.texi:3488
3894 :     #: R-ints.texi:3489
3895 :     #: R-ints.texi:3540
3896 :     #: R-ints.texi:3580
3897 :     #, no-wrap
3898 :     msgid "Base graphics"
3899 :     msgstr ""
3900 :    
3901 :     #. type: section
3902 :     #: R-ints.texi:2822
3903 :     #: R-ints.texi:3488
3904 :     #: R-ints.texi:3580
3905 :     #: R-ints.texi:3581
3906 :     #, no-wrap
3907 :     msgid "Grid graphics"
3908 :     msgstr ""
3909 :    
3910 :     #. type: Plain text
3911 :     #: R-ints.texi:2831
3912 :     msgid "@R{} ships with several graphics devices, and there is support for third-party packages to provide additional devices---several packages now do. This section describes the device internals from the viewpoint of a would-be writer of a graphics device."
3913 :     msgstr ""
3914 :    
3915 :     #. type: node
3916 :     #: R-ints.texi:2840
3917 :     #: R-ints.texi:2842
3918 :     #: R-ints.texi:2843
3919 :     #: R-ints.texi:2950
3920 :     #, no-wrap
3921 :     msgid "Device structures"
3922 :     msgstr ""
3923 :    
3924 :     #. type: node
3925 :     #: R-ints.texi:2840
3926 :     #: R-ints.texi:2842
3927 :     #: R-ints.texi:2950
3928 :     #: R-ints.texi:2951
3929 :     #: R-ints.texi:2997
3930 :     #, no-wrap
3931 :     msgid "Device capabilities"
3932 :     msgstr ""
3933 :    
3934 :     #. type: node
3935 :     #: R-ints.texi:2840
3936 :     #: R-ints.texi:2950
3937 :     #: R-ints.texi:2997
3938 :     #: R-ints.texi:2998
3939 :     #: R-ints.texi:3157
3940 :     #, no-wrap
3941 :     msgid "Handling text"
3942 :     msgstr ""
3943 :    
3944 :     #. type: node
3945 :     #: R-ints.texi:2840
3946 :     #: R-ints.texi:2997
3947 :     #: R-ints.texi:3157
3948 :     #: R-ints.texi:3158
3949 :     #: R-ints.texi:3212
3950 :     #, no-wrap
3951 :     msgid "Conventions"
3952 :     msgstr ""
3953 :    
3954 :     #. type: node
3955 :     #: R-ints.texi:2840
3956 :     #: R-ints.texi:3157
3957 :     #: R-ints.texi:3212
3958 :     #: R-ints.texi:3243
3959 :     #, no-wrap
3960 :     msgid "'Mode'"
3961 :     msgstr ""
3962 :    
3963 :     #. type: node
3964 :     #: R-ints.texi:2840
3965 :     #: R-ints.texi:3212
3966 :     #: R-ints.texi:3243
3967 :     #: R-ints.texi:3244
3968 :     #: R-ints.texi:3265
3969 :     #, no-wrap
3970 :     msgid "Graphics events"
3971 :     msgstr ""
3972 :    
3973 :     #. type: node
3974 :     #: R-ints.texi:2840
3975 :     #: R-ints.texi:3243
3976 :     #: R-ints.texi:3265
3977 :     #: R-ints.texi:3266
3978 :     #: R-ints.texi:3278
3979 :     #: R-ints.texi:3324
3980 :     #, no-wrap
3981 :     msgid "Specific devices"
3982 :     msgstr ""
3983 :    
3984 :     #. type: Plain text
3985 :     #: R-ints.texi:2847
3986 :     msgid "There are two types used internally which are pointers to structures related to graphics devices."
3987 :     msgstr ""
3988 :    
3989 :     #. type: Plain text
3990 :     #: R-ints.texi:2856
3991 :     msgid "The @code{DevDesc} type is a structure defined in the header file @file{R_ext/GraphicsDevice.h} (which is included by @file{R_ext/GraphicsEngine.h}). This describes the physical characteristics of a device, the capabilities of the device driver and contains a set of callback functions that will be used by the graphics engine to obtain information about the device and initiate actions (e.g.@: a new page, plotting a line or some text). Type @code{pDevDesc} is a pointer to this type."
3992 :     msgstr ""
3993 :    
3994 :     #. type: Plain text
3995 :     #: R-ints.texi:2862
3996 :     msgid "The following callbacks can be omitted (or set to the null pointer, their default value) when appropriate default behaviour will be taken by the graphics engine: @code{activate}, @code{cap}, @code{deactivate}, @code{locator}, @code{holdflush} (API version 9), @code{mode}, @code{newFrameConfirm}, @code{path}, @code{raster} and @code{size}."
3997 :     msgstr ""
3998 :    
3999 :     #. type: Plain text
4000 :     #: R-ints.texi:2866
4001 :     msgid "The relationship of device units to physical dimensions is set by the element @code{ipr} of the @code{DevDesc} structure: a @samp{double} array of length 2."
4002 :     msgstr ""
4003 :    
4004 :     #. type: Plain text
4005 :     #: R-ints.texi:2870
4006 :     msgid "The @code{GEDevDesc} type is a structure defined in @file{R_ext/GraphicsEngine.h} (with comments in the file) as"
4007 :     msgstr ""
4008 :    
4009 :     #. type: example
4010 :     #: R-ints.texi:2884
4011 :     #, no-wrap
4012 :     msgid ""
4013 :     "typedef struct _GEDevDesc GEDevDesc;\n"
4014 :     "struct _GEDevDesc @{\n"
4015 :     " pDevDesc dev;\n"
4016 :     " Rboolean displayListOn;\n"
4017 :     " SEXP displayList;\n"
4018 :     " SEXP DLlastElt;\n"
4019 :     " SEXP savedSnapshot;\n"
4020 :     " Rboolean dirty;\n"
4021 :     " Rboolean recordGraphics;\n"
4022 :     " GESystemDesc *gesd[MAX_GRAPHICS_SYSTEMS];\n"
4023 :     " Rboolean ask;\n"
4024 :     "@}\n"
4025 :     msgstr ""
4026 :    
4027 :     #. type: Plain text
4028 :     #: R-ints.texi:2894
4029 :     msgid "So this is essentially a device structure plus information about the device maintained by the graphics engine and normally@footnote{It is possible for the device to find the @code{GEDevDesc} which points to its @code{DevDesc}, and this is done often enough that there is a convenience function @code{desc2GEDesc} to do so.} visible to the engine and not to the device. Type @code{pGEDevDesc} is a pointer to this type."
4030 :     msgstr ""
4031 :    
4032 :     #. type: Plain text
4033 :     #: R-ints.texi:2905
4034 :     msgid "The graphics engine maintains an array of devices, as pointers to @code{GEDevDesc} structures. The array is of size 64 but the first element is always occupied by the @code{\"null device\"} and the final element is kept as NULL as a sentinel.@footnote{Calling @code{R_CheckDeviceAvailable()} ensures there is a free slot or throws an error.} This array is reflected in the @R{} variable @samp{.Devices}. Once a device is killed its element becomes available for reallocation (and its name will appear as @code{\"\"} in @samp{.Devices}). Exactly one of the devices is `active': this is the the null device if no other device has been opened and not killed."
4035 :     msgstr ""
4036 :    
4037 :     #. type: Plain text
4038 :     #: R-ints.texi:2908
4039 :     msgid "Each instance of a graphics device needs to set up a @code{GEDevDesc} structure by code very similar to"
4040 :     msgstr ""
4041 :    
4042 :     #. type: example
4043 :     #: R-ints.texi:2911
4044 :     #, no-wrap
4045 :     msgid ""
4046 :     " pGEDevDesc gdd;\n"
4047 :     "\n"
4048 :     msgstr ""
4049 :    
4050 :     #. type: example
4051 :     #: R-ints.texi:2923
4052 :     #, no-wrap
4053 :     msgid ""
4054 :     " R_GE_checkVersionOrDie(R_GE_version);\n"
4055 :     " R_CheckDeviceAvailable();\n"
4056 :     " BEGIN_SUSPEND_INTERRUPTS @{\n"
4057 :     " pDevDesc dev;\n"
4058 :     " /* Allocate and initialize the device driver data */\n"
4059 :     " if (!(dev = (pDevDesc) calloc(1, sizeof(DevDesc))))\n"
4060 :     " return 0; /* or error() */\n"
4061 :     " /* set up device driver or free 'dev' and error() */\n"
4062 :     " gdd = GEcreateDevDesc(dev);\n"
4063 :     " GEaddDevice2(gdd, \"dev_name\");\n"
4064 :     " @} END_SUSPEND_INTERRUPTS;\n"
4065 :     msgstr ""
4066 :    
4067 :     #. type: Plain text
4068 :     #: R-ints.texi:2929
4069 :     msgid "The @code{DevDesc} structure contains a @code{void *} pointer @samp{deviceSpecific} which is used to store data specific to the device. Setting up the device driver includes initializing all the non-zero elements of the @code{DevDesc} structure."
4070 :     msgstr ""
4071 :    
4072 :     #. type: Plain text
4073 :     #: R-ints.texi:2935
4074 :     msgid "Note that the device structure is zeroed when allocated: this provides some protection against future expansion of the structure since the graphics engine can add elements that need to be non-NULL/non-zero to be `on' (and the structure ends with 64 reserved bytes which will be zeroed and allow for future expansion)."
4075 :     msgstr ""
4076 :    
4077 :     #. type: Plain text
4078 :     #: R-ints.texi:2939
4079 :     msgid "Rather more protection is provided by the version number of the engine/device API, @code{R_GE_version} defined in @file{R_ext/GraphicsEngine.h} together with access functions"
4080 :     msgstr ""
4081 :    
4082 :     #. type: example
4083 :     #: R-ints.texi:2943
4084 :     #, no-wrap
4085 :     msgid ""
4086 :     "int R_GE_getVersion(void);\n"
4087 :     "void R_GE_checkVersionOrDie(int version);\n"
4088 :     msgstr ""
4089 :    
4090 :     #. type: Plain text
4091 :     #: R-ints.texi:2949
4092 :     msgid "If a graphics device calls @code{R_GE_checkVersionOrDie(R_GE_version)} it can ensure it will only be used in versions of @R{} which provide the API it was designed for and compiled against."
4093 :     msgstr ""
4094 :    
4095 :     #. type: Plain text
4096 :     #: R-ints.texi:2955
4097 :     msgid "The following `capabilities' can be defined for the device's @code{DevDesc} structure."
4098 :     msgstr ""
4099 :    
4100 :     #. type: item
4101 :     #: R-ints.texi:2957
4102 :     #, no-wrap
4103 :     msgid "@code{canChangeGamma} --"
4104 :     msgstr ""
4105 :    
4106 :     #. type: itemize
4107 :     #: R-ints.texi:2960
4108 :     msgid "@code{Rboolean}: can the display gamma be adjusted? This is now ignored, as gamma support has been removed."
4109 :     msgstr ""
4110 :    
4111 :     #. type: item
4112 :     #: R-ints.texi:2960
4113 :     #, no-wrap
4114 :     msgid "@code{canHadj} --"
4115 :     msgstr ""
4116 :    
4117 :     #. type: itemize
4118 :     #: R-ints.texi:2965
4119 :     msgid "@code{integer}: can the device do horizontal adjustment of text @emph{via} the @code{text} callback, and if so, how precisely? 0 = no adjustment, 1 = @{0, 0.5, 1@} (left, centre, right justification) or 2 = continuously variable (in [0,1]) between left and right justification."
4120 :     msgstr ""
4121 :    
4122 :     #. type: item
4123 :     #: R-ints.texi:2965
4124 :     #, no-wrap
4125 :     msgid "@code{canGenMouseDown} --"
4126 :     msgstr ""
4127 :    
4128 :     #. type: itemize
4129 :     #: R-ints.texi:2969
4130 :     msgid "@code{Rboolean}: can the device handle mouse down events? This flag and the next three are not currently used by R, but are maintained for back compatibility."
4131 :     msgstr ""
4132 :    
4133 :     #. type: item
4134 :     #: R-ints.texi:2969
4135 :     #, no-wrap
4136 :     msgid "@code{canGenMouseMove} --"
4137 :     msgstr ""
4138 :    
4139 :     #. type: itemize
4140 :     #: R-ints.texi:2971
4141 :     msgid "@code{Rboolean}: ditto for mouse move events."
4142 :     msgstr ""
4143 :    
4144 :     #. type: item
4145 :     #: R-ints.texi:2971
4146 :     #, no-wrap
4147 :     msgid "@code{canGenMouseUp} --"
4148 :     msgstr ""
4149 :    
4150 :     #. type: itemize
4151 :     #: R-ints.texi:2973
4152 :     msgid "@code{Rboolean}: ditto for mouse up events."
4153 :     msgstr ""
4154 :    
4155 :     #. type: item
4156 :     #: R-ints.texi:2973
4157 :     #, no-wrap
4158 :     msgid "@code{canGenKeybd} --"
4159 :     msgstr ""
4160 :    
4161 :     #. type: itemize
4162 :     #: R-ints.texi:2975
4163 :     msgid "@code{Rboolean}: ditto for keyboard events."
4164 :     msgstr ""
4165 :    
4166 :     #. type: item
4167 :     #: R-ints.texi:2975
4168 :     #, no-wrap
4169 :     msgid "@code{hasTextUTF8} --"
4170 :     msgstr ""
4171 :    
4172 :     #. type: itemize
4173 :     #: R-ints.texi:2979
4174 :     msgid "@code{Rboolean}: should non-symbol text be sent (in UTF-8) to the @code{textUTF8} and @code{strWidthUTF8} callbacks, and sent as Unicode points (negative values) to the @code{metricInfo} callback?"
4175 :     msgstr ""
4176 :    
4177 :     #. type: item
4178 :     #: R-ints.texi:2979
4179 :     #, no-wrap
4180 :     msgid "@code{wantSymbolUTF8} --"
4181 :     msgstr ""
4182 :    
4183 :     #. type: itemize
4184 :     #: R-ints.texi:2982
4185 :     msgid "@code{Rboolean}: should symbol text be handled in UTF-8 in the same way as other text? Requires @code{textUTF8 = TRUE}."
4186 :     msgstr ""
4187 :    
4188 :     #. type: item
4189 :     #: R-ints.texi:2982
4190 :     #, no-wrap
4191 :     msgid "@code{haveTransparency}:"
4192 :     msgstr ""
4193 :    
4194 :     #. type: itemize
4195 :     #: R-ints.texi:2984
4196 :     msgid "does the device support semi-transparent colours?"
4197 :     msgstr ""
4198 :    
4199 :     #. type: item
4200 :     #: R-ints.texi:2984
4201 :     #, no-wrap
4202 :     msgid "@code{haveTransparentBg}:"
4203 :     msgstr ""
4204 :    
4205 :     #. type: itemize
4206 :     #: R-ints.texi:2986
4207 :     msgid "can the background be fully or semi-transparent?"
4208 :     msgstr ""
4209 :    
4210 :     #. type: item
4211 :     #: R-ints.texi:2986
4212 :     #, no-wrap
4213 :     msgid "@code{haveRaster}:"
4214 :     msgstr ""
4215 :    
4216 :     #. type: itemize
4217 :     #: R-ints.texi:2988
4218 :     msgid "is there support for rendering raster images?"
4219 :     msgstr ""
4220 :    
4221 :     #. type: item
4222 :     #: R-ints.texi:2988
4223 :     #, no-wrap
4224 :     msgid "@code{haveCapture}:"
4225 :     msgstr ""
4226 :    
4227 :     #. type: itemize
4228 :     #: R-ints.texi:2990
4229 :     msgid "is there support for @code{grid::grid.cap}?"
4230 :     msgstr ""
4231 :    
4232 :     #. type: item
4233 :     #: R-ints.texi:2990
4234 :     #, no-wrap
4235 :     msgid "@code{haveLocator}:"
4236 :     msgstr ""
4237 :    
4238 :     #. type: itemize
4239 :     #: R-ints.texi:2992
4240 :     msgid "is there an interactive locator?"
4241 :     msgstr ""
4242 :    
4243 :     #. type: Plain text
4244 :     #: R-ints.texi:2996
4245 :     msgid "The last three can often be deduced to be false from the presence of @code{NULL} entries instead of the corresponding functions."
4246 :     msgstr ""
4247 :    
4248 :     #. type: Plain text
4249 :     #: R-ints.texi:3004
4250 :     msgid "Handling text is probably the hardest task for a graphics device, and the design allows for the device to optionally indicate that it has additional capabilities. (If the device does not, these will if possible be handled in the graphics engine.)"
4251 :     msgstr ""
4252 :    
4253 :     #. type: Plain text
4254 :     #: R-ints.texi:3008
4255 :     msgid "The three callbacks for handling text that must be in all graphics devices are @code{text}, @code{strWidth} and @code{metricInfo} with declarations"
4256 :     msgstr ""
4257 :    
4258 :     #. type: example
4259 :     #: R-ints.texi:3012
4260 :     #, no-wrap
4261 :     msgid ""
4262 :     "void text(double x, double y, const char *str, double rot, double hadj,\n"
4263 :     " pGgcontext gc, pDevDesc dd);\n"
4264 :     "\n"
4265 :     msgstr ""
4266 :    
4267 :     #. type: example
4268 :     #: R-ints.texi:3014
4269 :     #, no-wrap
4270 :     msgid ""
4271 :     "double strWidth(const char *str, pGEcontext gc, pDevDesc dd);\n"
4272 :     "\n"
4273 :     msgstr ""
4274 :    
4275 :     #. type: example
4276 :     #: R-ints.texi:3018
4277 :     #, no-wrap
4278 :     msgid ""
4279 :     "void metricInfo(int c, pGEcontext gc,\n"
4280 :     " double* ascent, double* descent, double* width,\n"
4281 :     " pDevDesc dd);\n"
4282 :     msgstr ""
4283 :    
4284 :     #. type: Plain text
4285 :     #: R-ints.texi:3024
4286 :     msgid "The @samp{gc} parameter provides the graphics context, most importantly the current font and fontsize, and @samp{dd} is a pointer to the active device's structure."
4287 :     msgstr ""
4288 :    
4289 :     #. type: Plain text
4290 :     #: R-ints.texi:3031
4291 :     msgid "The @code{text} callback should plot @samp{str} at @samp{(x, y)}@footnote{in device coordinates} with an anti-clockwise rotation of @samp{rot} degrees. (For @samp{hadj} see below.) The interpretation for horizontal text is that the baseline is at @code{y} and the start is a @code{x}, so any left bearing for the first character will start at @code{x}."
4292 :     msgstr ""
4293 :    
4294 :     #. type: Plain text
4295 :     #: R-ints.texi:3036
4296 :     msgid "The @code{strWidth} callback computes the width of the string which it would occupy if plotted horizontally in the current font. (Width here is expected to include both (preferably) or neither of left and right bearings.)"
4297 :     msgstr ""
4298 :    
4299 :     #. type: Plain text
4300 :     #: R-ints.texi:3047
4301 :     msgid "The @code{metricInfo} callback computes the size of a single character: @code{ascent} is the distance it extends above the baseline and @code{descent} how far it extends below the baseline. @code{width} is the amount by which the cursor should be advanced when the character is placed. For @code{ascent} and @code{descent} this is intended to be the bounding box of the `ink' put down by the glyph and not the box which might be used when assembling a line of conventional text (it needs to be for e.g. @code{hat(beta)} to work correctly). However, the @code{width} is used in plotmath to advance to the next character, and so needs to include left and right bearings."
4302 :     msgstr ""
4303 :    
4304 :     #. type: Plain text
4305 :     #: R-ints.texi:3056
4306 :     msgid "The @emph{interpretation} of @samp{c} depends on the locale. In a single-byte locale values @code{32...255} indicate the corresponding character in the locale (if present). For the symbol font (as used by @samp{graphics::par(font=5)}, @samp{grid::gpar(fontface=5}) and by `plotmath'), values @code{32...126, 161...239, 241...254} indicate glyphs in the Adobe Symbol encoding. In a multibyte locale, @code{c} represents a Unicode point (except in the symbol font). So the function needs to include code like"
4307 :     msgstr ""
4308 :    
4309 :     #. type: example
4310 :     #: R-ints.texi:3061
4311 :     #, no-wrap
4312 :     msgid ""
4313 :     " Rboolean Unicode = mbcslocale && (gc->fontface != 5);\n"
4314 :     " if (c < 0) @{ Unicode = TRUE; c = -c; @}\n"
4315 :     " if(Unicode) UniCharMetric(c, ...); else CharMetric(c, ...);\n"
4316 :     msgstr ""
4317 :    
4318 :     #. type: Plain text
4319 :     #: R-ints.texi:3068
4320 :     msgid "In addition, if device capability @code{hasTextUTF8} (see below) is true, Unicode points will be passed as negative values: the code snippet above shows how to handle this. (This applies to the symbol font only if device capability @code{wantSymbolUTF8} is true.)"
4321 :     msgstr ""
4322 :    
4323 :     #. type: Plain text
4324 :     #: R-ints.texi:3075
4325 :     msgid "If possible, the graphics device should handle clipping of text. It indicates this by the structure element @code{canClip} which if true will result in calls to the callback @code{clip} to set the clipping region. If this is not done, the engine will clip very crudely (by omitting any text that does not appear to be wholly inside the clipping region)."
4326 :     msgstr ""
4327 :    
4328 :     #. type: Plain text
4329 :     #: R-ints.texi:3082
4330 :     msgid "The device structure has an integer element @code{canHadj}, which indicates if the device can do horizontal alignment of text. If this is one, argument @samp{hadj} to @code{text} will be called as @code{0 ,0.5, 1} to indicate left-, centre- and right-alignment at the indicated position. If it is two, continuous values in the range @code{[0, 1]} are assumed to be supported."
4331 :     msgstr ""
4332 :    
4333 :     #. type: Plain text
4334 :     #: R-ints.texi:3093
4335 :     msgid "Capability @code{hasTextUTF8} if true, it has two consequences. First, there are callbacks @code{textUTF8} and @code{strWidthUTF8} that should behave identically to @code{text} and @code{strWidth} except that @samp{str} is assumed to be in UTF-8 rather than the current locale's encoding. The graphics engine will call these for all text except in the symbol font. Second, Unicode points will be passed to the @code{metricInfo} callback as negative integers. If your device would prefer to have UTF-8-encoded symbols, define @code{wantSymbolUTF8} as well as @code{hasTextUTF8}. In that case text in the symbol font is sent to @code{textUTF8} and @code{strWidthUTF8}."
4336 :     msgstr ""
4337 :    
4338 :     #. type: Plain text
4339 :     #: R-ints.texi:3097
4340 :     msgid "Some devices can produce high-quality rotated text, but those based on bitmaps often cannot. Those which can should set @code{useRotatedTextInContour} to be true from graphics API version 4."
4341 :     msgstr ""
4342 :    
4343 :     #. type: Plain text
4344 :     #: R-ints.texi:3100
4345 :     msgid "Several other elements relate to the precise placement of text by the graphics engine:"
4346 :     msgstr ""
4347 :    
4348 :     #. type: example
4349 :     #: R-ints.texi:3106
4350 :     #, no-wrap
4351 :     msgid ""
4352 :     "double xCharOffset;\n"
4353 :     "double yCharOffset;\n"
4354 :     "double yLineBias;\n"
4355 :     "double cra[2];\n"
4356 :     msgstr ""
4357 :    
4358 :     #. type: Plain text
4359 :     #: R-ints.texi:3118
4360 :     msgid "These are more than a little mysterious. Element @code{cra} provides an indication of the character size, @code{par(\"cra\")} in base graphics, in device units. The mystery is what is meant by `character size': which character, which font at which size? Some help can be obtained by looking at what this is used for. The first element, `width', is not used by @R{} except to set the graphical parameters. The second, `height', is use to set the line spacing, that is the relationship between @code{par(\"mai\")} and @code{par(\"mai\")} and so on. It is suggested that a good choice is"
4361 :     msgstr ""
4362 :    
4363 :     #. type: example
4364 :     #: R-ints.texi:3122
4365 :     #, no-wrap
4366 :     msgid ""
4367 :     "dd->cra[0] = 0.9 * fnsize;\n"
4368 :     "dd->cra[1] = 1.2 * fnsize;\n"
4369 :     msgstr ""
4370 :    
4371 :     #. type: Plain text
4372 :     #: R-ints.texi:3129
4373 :     msgid "where @samp{fnsize} is the `size' of the standard font (@code{cex=1}) on the device, in device units. So for a 12-point font (the usual default for graphics devices), @samp{fnsize} should be 12 points in device units."
4374 :     msgstr ""
4375 :    
4376 :     #. type: Plain text
4377 :     #: R-ints.texi:3132
4378 :     msgid "The remaining elements are yet more mysterious. The @code{postscript()} device says"
4379 :     msgstr ""
4380 :    
4381 :     #. type: example
4382 :     #: R-ints.texi:3138
4383 :     #, no-wrap
4384 :     msgid ""
4385 :     " /* Character Addressing Offsets */\n"
4386 :     " /* These offsets should center a single */\n"
4387 :     " /* plotting character over the plotting point. */\n"
4388 :     " /* Pure guesswork and eyeballing ... */\n"
4389 :     "\n"
4390 :     msgstr ""
4391 :    
4392 :     #. type: example
4393 :     #: R-ints.texi:3142
4394 :     #, no-wrap
4395 :     msgid ""
4396 :     " dd->xCharOffset = 0.4900;\n"
4397 :     " dd->yCharOffset = 0.3333;\n"
4398 :     " dd->yLineBias = 0.2;\n"
4399 :     msgstr ""
4400 :    
4401 :     #. type: Plain text
4402 :     #: R-ints.texi:3153
4403 :     msgid "It seems that @code{xCharOffset} is not currently used, and @code{yCharOffset} is used by the base graphics system to set vertical alignment in @code{text()} when @code{pos} is specified, and in @code{identify()}. It is occasionally used by the graphic engine when attempting exact centring of text, such as character string values of @code{pch} in @code{points()} or @code{grid.points()}---however, it is only used when precise character metric information is not available or for multi-line strings."
4404 :     msgstr ""
4405 :    
4406 :     #. type: Plain text
4407 :     #: R-ints.texi:3156
4408 :     msgid "@code{yLineBias} is used in the base graphics system in @code{axis()} and @code{mtext()} to provide a default for their @samp{padj} argument."
4409 :     msgstr ""
4410 :    
4411 :     #. type: Plain text
4412 :     #: R-ints.texi:3163
4413 :     msgid "The aim is to make the (default) output from graphics devices as similar as possible. Generally people follow the model of the @code{postscript} and @code{pdf} devices (which share most of their internal code)."
4414 :     msgstr ""
4415 :    
4416 :     #. type: Plain text
4417 :     #: R-ints.texi:3165
4418 :     msgid "The following conventions have become established:"
4419 :     msgstr ""
4420 :    
4421 :     #. type: itemize
4422 :     #: R-ints.texi:3170
4423 :     msgid "The default size of a device should be 7 inches square."
4424 :     msgstr ""
4425 :    
4426 :     #. type: itemize
4427 :     #: R-ints.texi:3177
4428 :     msgid "There should be a @samp{pointsize} argument which defaults to 12, and it should give the pointsize in big points (1/72 inch). How exactly this is interpreted is font-specific, but it should use a font which works with lines packed 1/6 inch apart, and looks good with lines 1/5 inch apart (that is with 2pt leading)."
4429 :     msgstr ""
4430 :    
4431 :     #. type: itemize
4432 :     #: R-ints.texi:3181
4433 :     msgid "The default font family should be a sans serif font, e.g Helvetica or similar (e.g.@: Arial on Windows)."
4434 :     msgstr ""
4435 :    
4436 :     #. type: itemize
4437 :     #: R-ints.texi:3188
4438 :     msgid "@code{lwd = 1} should correspond to a line width of 1/96 inch. This will be a problem with pixel-based devices, and generally there is a minimum line width of 1 pixel (although this may not be appropriate where anti-aliasing of lines is used, and @code{cairo} prefers a minimum of 2 pixels)."
4439 :     msgstr ""
4440 :    
4441 :     #. type: itemize
4442 :     #: R-ints.texi:3193
4443 :     msgid "Even very small circles should be visible, e.g.@: by using a minimum radius of 1 pixel or replacing very small circles by a single filled pixel."
4444 :     msgstr ""
4445 :    
4446 :     #. type: itemize
4447 :     #: R-ints.texi:3197
4448 :     msgid "How RGB colour values will be interpreted should be documented, and preferably be sRGB."
4449 :     msgstr ""
4450 :    
4451 :     #. type: itemize
4452 :     #: R-ints.texi:3200
4453 :     msgid "The help page should describe its policy on these conventions."
4454 :     msgstr ""
4455 :    
4456 :     #. type: Plain text
4457 :     #: R-ints.texi:3205
4458 :     msgid "These conventions are less clear-cut for bitmap devices, especially where the bitmap format does not have a design resolution."
4459 :     msgstr ""
4460 :    
4461 :     #. type: Plain text
4462 :     #: R-ints.texi:3210
4463 :     msgid "The interpretation of the line texture (@code{par(\"lty\"}) is described in the header @file{GraphicsEngine.h} and in the help for @code{par}: note that the `scale' of the pattern should be proportional to the line width (at least for widths above the default)."
4464 :     msgstr ""
4465 :    
4466 :     #. type: subsection
4467 :     #: R-ints.texi:3213
4468 :     #, no-wrap
4469 :     msgid "`Mode'"
4470 :     msgstr ""
4471 :    
4472 :     #. type: Plain text
4473 :     #: R-ints.texi:3217
4474 :     msgid "One of the device callbacks is a function @code{mode}, documented in the header as"
4475 :     msgstr ""
4476 :    
4477 :     #. type: example
4478 :     #: R-ints.texi:3224
4479 :     #, no-wrap
4480 :     msgid ""
4481 :     " * device_Mode is called whenever the graphics engine\n"
4482 :     " * starts drawing (mode=1) or stops drawing (mode=0)\n"
4483 :     " * GMode (in graphics.c) also says that\n"
4484 :     " * mode = 2 (graphical input on) exists.\n"
4485 :     " * The device is not required to do anything\n"
4486 :     msgstr ""
4487 :    
4488 :     #. type: Plain text
4489 :     #: R-ints.texi:3232
4490 :     msgid "Since @code{mode = 2} has only recently been documented at device level. It could be used to change the graphics cursor, but devices currently do that in the @code{locator} callback. (In base graphics the mode is set for the duration of a @code{locator} call, but if @code{type != \"n\"} is switched back for each point whilst annotation is being done.)"
4491 :     msgstr ""
4492 :    
4493 :     #. type: Plain text
4494 :     #: R-ints.texi:3240