Changeset 35281 in project


Ignore:
Timestamp:
03/12/18 19:57:25 (5 months ago)
Author:
sjamaan
Message:

man/5: Move documentation of time, require-extension-for-syntax, {let,define}-compiler-syntax and define-for-syntax into their corresponding module pages

Location:
wiki/man/5
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • wiki/man/5/Module (chicken base)

    r35198 r35281  
    12461246(see the [[http://srfi.schemers.org/srfi-55/srfi-55.html|SRFI-55]] document for more information).
    12471247
     1248
     1249==== require-extension-for-syntax
     1250
     1251<macro>(require-extension-for-syntax ID ...)</macro>
     1252
     1253An abbreviation for the idiom:
     1254
     1255<enscript highlight=scheme>
     1256(begin-for-syntax (require-library ID ...))  ; load extension at expansion-time
     1257(import-for-syntax ID ...)                   ; import extension for use in syntax-transformers
     1258</enscript>
     1259
     1260Where {{begin-for-syntax}} is taken from the {{(chicken syntax)}} module.
     1261
     1262
    12481263==== require-library
    12491264
  • wiki/man/5/Module (chicken syntax)

    r35116 r35281  
    7979call from a syntax transformer.
    8080
     81==== define-for-syntax
     82
     83<macro>(define-for-syntax (NAME VAR ...) EXP1 ...)</macro><br>
     84<macro>(define-for-syntax (NAME VAR1 ... VARn . VARn+1) EXP1 ...)</macro><br>
     85<macro>(define-for-syntax NAME [VALUE])</macro>
     86
     87Defines the toplevel variable {{NAME}} at macro-expansion time. This
     88can be helpful when you want to define support procedures for use in
     89macro-transformers, for example.
     90
     91Essentially, this is a shorthand for
     92{{(begin-for-syntax (define ...))}}.
     93
     94Note that {{define-for-syntax}} definitions within a module are
     95implicitly added to that module's import library. Refer to the
     96documentation on [[Modules#import-libraries|import libraries]]
     97for more information.
     98
    8199
    82100==== syntax
     
    123141
    124142
     143=== Compiler macros
     144
     145==== define-compiler-syntax
     146
     147<macro>(define-compiler-syntax NAME)</macro><br>
     148<macro>(define-compiler-syntax NAME TRANSFORMER)</macro><br>
     149
     150Defines what is usually called a ''compiler macro'' in Lisp: {{NAME}}
     151should be the name of a globally or locally bound procedure. Any
     152direct call to this procedure will be transformed before compilation,
     153which allows arbitrary rewritings of function calls.
     154
     155{{TRANSFORMER}} can be a {{syntax-rules}} expression or a transformer
     156procedure (as returned by {{er-macro-transformer}} or
     157{{ir-macro-transformer}}). Returning the original form in an
     158explicit/implicit-renaming macro or simply "falling trough" all
     159patterns in a {{syntax-rules}} form will keep the original expression
     160and compile it normally.
     161
     162In the interpreter this form does nothing and returns an unspecified
     163value.
     164
     165Compiler-syntax is always local to the current compilation unit and
     166can not be exported. Compiler-syntax defined inside a module is not
     167visible outside of that module.
     168
     169{{define-compiler-syntax}} should only be used at top-level. Local
     170compiler-syntax can be defined with {{let-compiler-syntax}}.
     171
     172<enscript highlight=scheme>
     173(define-compiler-syntax +
     174  (syntax-rules ()
     175    ((_) 1)
     176    ((_ x 0) x) ) )
     177</enscript>
     178
     179If no transformer is given, then {{(define-compiler-syntax NAME)}}
     180removes any compiler-syntax definitions for {{NAME}}.
     181
     182
     183==== let-compiler-syntax
     184
     185<macro>(let-compiler-syntax ((NAME [TRANSFORMER]) ...) BODY ...)</macro>
     186
     187Allows definition local compiler macros, which are only applicable
     188inside {{BODY ...}}.  By not providing a {{TRANSFORMER}} expression,
     189compiler-syntax for specific identifiers can be temporarily disabled.
     190
    125191---
    126192Previous: [[Module (chicken string)]]
  • wiki/man/5/Module (chicken time)

    r34079 r35281  
    88[[Module (chicken time posix)]].
    99
    10 === cpu-time
     10=== Retrieving timestamp information
     11
     12==== cpu-time
    1113
    1214<procedure>(cpu-time)</procedure>
     
    1820
    1921
    20 === current-milliseconds
     22==== current-milliseconds
    2123
    2224<procedure>(current-milliseconds)</procedure>
     
    2527
    2628
    27 === current-seconds
     29==== current-seconds
    2830
    2931<procedure>(current-seconds)</procedure>
     
    3234
    3335
     36=== Benchmarking macros
     37
     38==== time
     39
     40<macro>(time EXP1 ...)</macro>
     41
     42Performs a major garbage collection, evaluates {{EXP1 ...}} and prints
     43elapsed CPU time and some values about GC use, like time spent in
     44major GCs, number of minor and major GCs. The output is sent to the
     45port that is the current value of {{(current-error-port)}}. Nested
     46invocations of this form will give incorrect results for all output
     47but the innermost.
     48
    3449
    3550---
  • wiki/man/5/TODO/Non-standard macros and special forms

    r35116 r35281  
    44
    55== Non-standard macros and special forms
    6 
    7 === Making extra libraries and extensions available
    8 
    9 ==== require-extension-for-syntax
    10 
    11 <macro>(require-extension-for-syntax ID ...)</macro>
    12 
    13 An abbreviation for the idiom:
    14 
    15 <enscript highlight=scheme>
    16 (begin-for-syntax (require-library ID ...))  ; load extension at expansion-time
    17 (import-for-syntax ID ...)                   ; import extension for use in syntax-transformers
    18 </enscript>
    19 
    20 
    21 === Substitution forms and macros
    22 
    23 ==== define-for-syntax
    24 
    25 <macro>(define-for-syntax (NAME VAR ...) EXP1 ...)</macro><br>
    26 <macro>(define-for-syntax (NAME VAR1 ... VARn . VARn+1) EXP1 ...)</macro><br>
    27 <macro>(define-for-syntax NAME [VALUE])</macro>
    28 
    29 Defines the toplevel variable {{NAME}} at macro-expansion time. This can
    30 be helpful when you want to define support procedures for use in macro-transformers,
    31 for example.
    32 
    33 Note that {{define-for-syntax}} definitions within a module are implicitly
    34 added to that module's import library. Refer to the documentation on
    35 [[/man/4/Modules#import-libraries|import libraries]] for more information.
    36 
    37 ==== define-compiler-syntax
    38 
    39 <macro>(define-compiler-syntax NAME)</macro><br>
    40 <macro>(define-compiler-syntax NAME TRANSFORMER)</macro><br>
    41 
    42 Defines what is usually called a ''compiler macro'' in Lisp: {{NAME}} should be the
    43 name of a globally or locally bound procedure. Any direct call to this procedure
    44 will be transformed before compilation, which allows arbitrary rewritings
    45 of function calls.
    46 
    47 {{TRANSFORMER}} can be a {{syntax-rules}} expression or a transformer
    48 procedure (as returned by {{er-macro-transformer}} or
    49 {{ir-macro-transformer}}). Returning the original form in an
    50 explicit/implicit-renaming macro or simply "falling trough" all patterns in a
    51 {{syntax-rules}} form will keep the original expression and compile it
    52 normally.
    53 
    54 In the interpreter this form does nothing and returns an unspecified value.
    55 
    56 Compiler-syntax is always local to the current compilation unit and can not be
    57 exported. Compiler-syntax defined inside a module is not visible outside of that
    58 module.
    59 
    60 {{define-compiler-syntax}} should only be used at top-level. Local compiler-syntax
    61 can be defined with {{let-compiler-syntax}}.
    62 
    63 <enscript highlight=scheme>
    64 (define-compiler-syntax +
    65   (syntax-rules ()
    66     ((_) 1)
    67     ((_ x 0) x) ) )
    68 </enscript>
    69 
    70 If no transformer is given, then {{(define-compiler-syntax NAME)}} removes
    71 any compiler-syntax definitions for {{NAME}}.
    72 
    73 
    74 ==== let-compiler-syntax
    75 
    76 <macro>(let-compiler-syntax ((NAME [TRANSFORMER]) ...) BODY ...)</macro>
    77 
    78 Allows definition local compiler macros, which are only applicable inside {{BODY ...}}.
    79 By not providing a {{TRANSFORMER}} expression, compiler-syntax for specific identifiers
    80 can be temporarily disabled.
    81 
    826
    837=== Conditional forms
     
    16892==== time
    16993
    170 <macro>(time EXP1 ...)</macro>
    171 
    172 Performs a major garbage collection, evaluates {{EXP1 ...}} and prints
    173 elapsed CPU time and some values about GC use, like time spent in major
    174 GCs, number of minor and major GCs. The output is sent to the port
    175 that is the current value of {{(current-error-port)}}. Nested invocations
    176 of this form will give incorrect results for all output but the innermost.
    17794
    17895---
Note: See TracChangeset for help on using the changeset viewer.