Changeset 39472 in project


Ignore:
Timestamp:
12/30/20 17:25:16 (3 weeks ago)
Author:
Kon Lovett
Message:

remove format-modular ref

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/5/format

    r37635 r39472  
    1 [[tags:egg]]
     1[tags:egg]]
    22== format
    33
     
    3939 Format Specification (Format version 3.1)
    4040 -----------------------------------------
    41  
     41
    4242 Please consult a Common LISP format reference manual for a detailed
    4343 description of the format string syntax.
    44  
     44
    4545 This implementation supports directive parameters and modifiers (`:' and `@'
    4646 characters). Multiple parameters must be separated by a comma (`,').
     
    4949 number of rest arguments parameter (`#'), empty and default parameters.
    5050 Directive characters are case independent.
    51  
     51
    5252 The general form of a directive is:
    53  
     53
    5454 DIRECTIVE ::= ~{DIRECTIVE-PARAMETER,}[:][@]DIRECTIVE-CHARACTER
    55  
     55
    5656 DIRECTIVE-PARAMETER ::= [ [-|+]{0-9}+ | 'CHARACTER | v | # ]
    57  
     57
    5858 Implemented CL Format Control Directives
    5959 ........................................
    60  
     60
    6161 Documentation syntax: Uppercase characters represent the corresponding control
    6262 directive characters. Lowercase characters represent control directive
    6363 parameter descriptions.
    64  
     64
    6565 `~A'
    66  
     66
    6767     Any (print as `display' does).
    68  
     68
    6969    `~@A'
    70  
     70
    7171          left pad.
    72  
     72
    7373    `~MINCOL,COLINC,MINPAD,PADCHARA'
    74  
     74
    7575          full padding.
    76  
     76
    7777 `~S'
    78  
     78
    7979     S-expression (print as `write' does).
    80  
     80
    8181    `~@S'
    82  
     82
    8383          left pad.
    84  
     84
    8585    `~MINCOL,COLINC,MINPAD,PADCHARS'
    86  
     86
    8787          full padding.
    88  
     88
    8989 `~D'
    90  
     90
    9191     Decimal.
    92  
     92
    9393    `~@D'
    94  
     94
    9595          print number sign always.
    96  
     96
    9797    `~:D'
    98  
     98
    9999          print comma separated.
    100  
     100
    101101    `~MINCOL,PADCHAR,COMMACHARD'
    102  
     102
    103103          padding.
    104  
     104
    105105 `~X'
    106  
     106
    107107     Hexadecimal.
    108  
     108
    109109    `~@X'
    110  
     110
    111111          print number sign always.
    112  
     112
    113113    `~:X'
    114  
     114
    115115          print comma separated.
    116  
     116
    117117    `~MINCOL,PADCHAR,COMMACHARX'
    118  
     118
    119119          padding.
    120  
     120
    121121 `~O'
    122  
     122
    123123     Octal.
    124  
     124
    125125    `~@O'
    126  
     126
    127127          print number sign always.
    128  
     128
    129129    `~:O'
    130  
     130
    131131          print comma separated.
    132  
     132
    133133    `~MINCOL,PADCHAR,COMMACHARO'
    134  
     134
    135135          padding.
    136  
     136
    137137 `~B'
    138  
     138
    139139     Binary.
    140  
     140
    141141    `~@B'
    142  
     142
    143143          print number sign always.
    144  
     144
    145145    `~:B'
    146  
     146
    147147          print comma separated.
    148  
     148
    149149    `~MINCOL,PADCHAR,COMMACHARB'
    150  
     150
    151151          padding.
    152  
     152
    153153 `~NR'
    154  
     154
    155155     Radix N.
    156  
     156
    157157    `~N,MINCOL,PADCHAR,COMMACHARR'
    158  
     158
    159159          padding.
    160  
     160
    161161 `~@R'
    162  
     162
    163163     print a number as a Roman numeral.
    164  
     164
    165165 `~:@R'
    166  
     166
    167167     print a number as an "old fashioned" Roman numeral.
    168  
     168
    169169 `~:R'
    170  
     170
    171171     print a number as an ordinal English number.
    172  
     172
    173173 `~R'
    174  
     174
    175175     print a number as a cardinal English number.
    176  
     176
    177177 `~P'
    178  
     178
    179179     Plural.
    180  
     180
    181181    `~@P'
    182  
     182
    183183          prints `y' and `ies'.
    184  
     184
    185185    `~:P'
    186  
     186
    187187          as `~P but jumps 1 argument backward.'
    188  
     188
    189189    `~:@P'
    190  
     190
    191191          as `~@P but jumps 1 argument backward.'
    192  
     192
    193193 `~C'
    194  
     194
    195195     Character.
    196  
     196
    197197    `~@C'
    198  
     198
    199199          prints a character as the reader can understand it (i.e. `#\' prefixing).
    200  
     200
    201201    `~:C'
    202  
     202
    203203          prints a character as emacs does (eg. `^C' for ASCII 03).
    204  
     204
    205205 `~F'
    206  
     206
    207207     Fixed-format floating-point (prints a flonum like MMM.NNN).
    208  
     208
    209209    `~WIDTH,DIGITS,SCALE,OVERFLOWCHAR,PADCHARF'
    210  
     210
    211211    `~@F'
    212212          If the number is positive a plus sign is printed.
    213  
     213
    214214 `~E'
    215  
     215
    216216     Exponential floating-point (prints a flonum like MMM.NNN`E'EE).
    217  
     217
    218218    `~WIDTH,DIGITS,EXPONENTDIGITS,SCALE,OVERFLOWCHAR,PADCHAR,EXPONENTCHARE'
    219  
     219
    220220    `~@E'
    221  
     221
    222222          If the number is positive a plus sign is printed.
    223  
     223
    224224 `~G'
    225  
     225
    226226     General floating-point (prints a flonum either fixed or exponential).
    227  
     227
    228228    `~WIDTH,DIGITS,EXPONENTDIGITS,SCALE,OVERFLOWCHAR,PADCHAR,EXPONENTCHARG'
    229  
     229
    230230    `~@G'
    231  
     231
    232232          If the number is positive a plus sign is printed.
    233  
     233
    234234 `~$'
    235  
     235
    236236     Dollars floating-point (prints a flonum in fixed with signs separated).
    237  
     237
    238238    `~DIGITS,SCALE,WIDTH,PADCHAR$'
    239  
     239
    240240    `~@$'
    241  
     241
    242242          If the number is positive a plus sign is printed.
    243  
     243
    244244    `~:@$'
    245  
     245
    246246          A sign is always printed and appears before the padding.
    247  
     247
    248248    `~:$'
    249  
     249
    250250          The sign appears before the padding.
    251  
     251
    252252 `~%'
    253  
     253
    254254     Newline.
    255  
     255
    256256    `~N%'
    257  
     257
    258258          print N newlines.
    259  
     259
    260260 `~&'
    261  
     261
    262262     print newline if not at the beginning of the output line.
    263  
     263
    264264    `~N&'
    265  
     265
    266266          prints `~&' and then N-1 newlines.
    267  
     267
    268268 `~|'
    269  
     269
    270270     Page Separator.
    271  
     271
    272272    `~N|'
    273  
     273
    274274          print N page separators.
    275  
     275
    276276 `~~'
    277  
     277
    278278     Tilde.
    279  
     279
    280280    `~N~'
    281  
     281
    282282          print N tildes.
    283  
     283
    284284 `~'<newline>
    285  
     285
    286286     Continuation Line.
    287  
     287
    288288    `~:'<newline>
    289  
     289
    290290          newline is ignored, white space left.
    291  
     291
    292292    `~@'<newline>
    293  
     293
    294294          newline is left, white space ignored.
    295  
     295
    296296 `~T'
    297  
     297
    298298     Tabulation.
    299  
     299
    300300    `~@T'
    301  
     301
    302302          relative tabulation.
    303  
     303
    304304    `~COLNUM,COLINCT'
    305  
     305
    306306          full tabulation.
    307  
     307
    308308 `~?'
    309  
     309
    310310     Indirection (expects indirect arguments as a list).
    311  
     311
    312312    `~@?'
    313  
     313
    314314          extracts indirect arguments from format arguments.
    315  
     315
    316316 `~(STR~)'
    317  
     317
    318318     Case conversion (converts by `string-downcase').
    319  
     319
    320320    `~:(STR~)'
    321  
     321
    322322          converts by `string-capitalize'.
    323  
     323
    324324    `~@(STR~)'
    325  
     325
    326326          converts by `string-capitalize-first'.
    327  
     327
    328328    `~:@(STR~)'
    329  
     329
    330330          converts by `string-upcase'.
    331  
     331
    332332 `~*'
    333  
     333
    334334     Argument Jumping (jumps 1 argument forward).
    335  
     335
    336336    `~N*'
    337  
     337
    338338          jumps N arguments forward.
    339  
     339
    340340    `~:*'
    341  
     341
    342342          jumps 1 argument backward.
    343  
     343
    344344    `~N:*'
    345  
     345
    346346          jumps N arguments backward.
    347  
     347
    348348    `~@*'
    349  
     349
    350350          jumps to the 0th argument.
    351  
     351
    352352    `~N@*'
    353  
     353
    354354          jumps to the Nth argument (beginning from 0)
    355  
     355
    356356 `~[STR0~;STR1~;...~;STRN~]'
    357  
     357
    358358     Conditional Expression (numerical clause conditional).
    359  
     359
    360360    `~N['
    361  
     361
    362362          take argument from N.
    363  
     363
    364364    `~@['
    365  
     365
    366366          true test conditional.
    367  
     367
    368368    `~:['
    369  
     369
    370370          if-else-then conditional.
    371  
     371
    372372    `~;'
    373  
     373
    374374          clause separator.
    375  
     375
    376376    `~:;'
    377  
     377
    378378          default clause follows.
    379  
     379
    380380 `~{STR~}'
    381  
     381
    382382     Iteration (args come from the next argument (a list)). Iteration
    383383     bounding is controlled by configuration variables
    384384     format:iteration-bounded and format:max-iterations. With both variables
    385385     default, a maximum of 100 iterations will be performed.
    386  
     386
    387387    `~N{'
    388  
     388
    389389          at most N iterations.
    390  
     390
    391391    `~:{'
    392  
     392
    393393          args from next arg (a list of lists).
    394  
     394
    395395    `~@{'
    396  
     396
    397397          args from the rest of arguments.
    398  
     398
    399399    `~:@{'
    400  
     400
    401401          args from the rest args (lists).
    402  
     402
    403403 `~^'
    404404     Up and out.
    405  
     405
    406406    `~N^'
    407  
     407
    408408          aborts if N = 0
    409  
     409
    410410    `~N,M^'
    411  
     411
    412412          aborts if N = M
    413  
     413
    414414    `~N,M,K^'
    415  
     415
    416416          aborts if N <= M <= K
    417  
     417
    418418 Not Implemented CL Format Control Directives
    419419 ............................................
    420  
     420
    421421 `~:A'
    422  
     422
    423423     print `#f' as an empty list (see below).
    424  
     424
    425425 `~:S'
    426  
     426
    427427     print `#f' as an empty list (see below).
    428  
     428
    429429 `~<~>'
    430  
     430
    431431     Justification.
    432  
     432
    433433 `~:^'
    434  
     434
    435435     (sorry I don't understand its semantics completely)
    436  
     436
    437437 Extended, Replaced and Additional Control Directives
    438438 ....................................................
    439  
     439
    440440 `~MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHD'
    441  
     441
    442442 `~MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHX'
    443  
     443
    444444 `~MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHO'
    445  
     445
    446446 `~MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHB'
    447  
     447
    448448 `~N,MINCOL,PADCHAR,COMMACHAR,COMMAWIDTHR'
    449  
     449
    450450     COMMAWIDTH is the number of characters between two comma
    451451     characters.
    452  
     452
    453453 `~I'
    454454     print a R4RS complex number as `~F~@Fi' with passed parameters for
    455455     `~F'.
    456  
     456
    457457 `~Y'
    458  
     458
    459459     Pretty print formatting of an argument for scheme code lists.
    460  
     460
    461461 `~K'
    462  
     462
    463463     Same as `~?.'
    464  
     464
    465465 `~!'
    466  
     466
    467467     Flushes the output if format DESTINATION is a port.
    468  
     468
    469469 `~_'
    470  
     470
    471471     Print a `#\space' character
    472  
     472
    473473    `~N_'
    474474          print N `#\space' characters.
    475  
     475
    476476 `~/'
    477  
     477
    478478     Print a `#\tab' character
    479  
     479
    480480    `~N/'
    481481          print N `#\tab' characters.
    482  
     482
    483483 `~NC'
    484  
     484
    485485     Takes N as an integer representation for a character. No arguments
    486486     are consumed. N is converted to a character by `integer->char'.  N
    487487     must be a positive decimal number.
    488  
     488
    489489 `~:S'
    490  
     490
    491491     Print out readproof.  Prints out internal objects represented as
    492492     `#<...>' as strings `"#<...>"' so that the format output can always
    493493     be processed by `read'.
    494  
     494
    495495 `~:A'
    496  
     496
    497497     Print out readproof.  Prints out internal objects represented as
    498498     `#<...>' as strings `"#<...>"' so that the format output can always
    499499     be processed by `read'.
    500  
     500
    501501 `~Q'
    502  
     502
    503503     Prints information and a copyright notice on the format
    504504     implementation.
    505  
     505
    506506    `~:Q'
    507507          prints format version.
    508  
     508
    509509 `~F, ~E, ~G, ~$'
    510  
     510
    511511     May also print number strings, i.e. passing a number as a string and
    512512     format it accordingly.
    513  
     513
    514514 Configuration Variables
    515515 -----------------------
    516  
     516
    517517 Format has some configuration variables. There should be no modification
    518518 necessary for the default configuration. If modification is desired the
    519519 variable should be set after the format code is loaded.
    520  
     520
    521521 format:floats
    522  
     522
    523523     System has floating-point numbers. (default #t)
    524  
     524
    525525 format:complex-numbers
    526  
     526
    527527     System has complex numbers. (default #f)
    528  
     528
    529529 format:fn-max
    530  
     530
    531531     Maximum number of number digits. (default 200)
    532  
     532
    533533 format:format:en-max
    534  
     534
    535535     Maximum number of exponent digits. (default 10)
    536  
     536
    537537 format:expch
    538  
     538
    539539     The character prefixing the exponent value in ~E printing.
    540540     (default #\E)
    541  
     541
    542542 format:radix-pref
    543  
     543
    544544     Does number->string add a radix prefix? (default <detects upon load>)
    545  
     545
    546546 format:symbol-case-conv
    547  
     547
    548548     Symbols are converted by symbol->string so the case type of the
    549549     printed symbols is implementation dependent.
     
    551551     conversion), string-upcase, string-downcase or string-capitalize.
    552552     (default #f)
    553  
     553
    554554 format:iobj-case-conv
    555  
     555
    556556     As format:symbol-case-conv but applies for the representation of
    557557     implementation internal objects. (default #f)
    558  
     558
    559559 format:iteration-bounded
    560  
     560
    561561     When #t, a ~{...~} control will iterate no more than the number of
    562562     times specified by format:max-iterations regardless of the number
     
    565565     modifiers and arguments, unless termination is forced by language
    566566     or system limitations. (default #t)
    567  
     567
    568568 format:max-iterations
    569  
     569
    570570     The maximum number of iterations performed by a ~{...~} control.
    571571     Has effect only when format:iteration-bounded is #t. (default 100)
    572  
     572
    573573 format:unprocessed-arguments-error?
    574  
     574
    575575     Are superfluous arguments treated as an error. (default #f)
    576 
    577 
    578 == Notes
    579 
    580 A modular and more robust implementation is available in the [[format-modular.html|format-modular]] extension.
    581576
    582577
Note: See TracChangeset for help on using the changeset viewer.