# W

`*Winch`
  Global variable holding a (possibly empty) `prg` body, which will be executed when a SIGWINCH signal is sent to the current process. See also `alarm`, `sigio`, `*Hup`, `*Sig[12]`, `*TStp[12]` and `*Term`.

      : (de *Winch (msg 'SIGWINCH))
      -> *Winch

`(wait 'cnt|NIL . prg) -> any`
`(wait 'cnt|NIL T 'fd) -> fd|NIL`
  Waits for a condition. While the result of the execution of `prg` is `NIL` (first form), or no input is available for the file descriptor in `fd` (second form), a `poll(2)` system call is executed for all file descriptors and timers in the `VAL` of the global variable `*Run`. When `cnt` is non-`NIL`, the waiting time is limited to `cnt` milliseconds. Returns the result of `prg`. See also `key` and `sync`.

      : (wait 2000)                                # Wait 2 seconds
      -> NIL
      : (prog
         (zero *Cnt)
         (setq *Run                                # Install background loop
            '((-2000 0 (println (inc '*Cnt)))) )   # Increment '*Cnt' every 2 sec
         (wait NIL (> *Cnt 6))                     # Wait until > 6
         (off *Run) )
      1                                            # Waiting ..
      2
      3
      4
      5
      6
      7
      -> NIL

`(week 'dat) -> num`
  Returns the number of the week for a given `date` `dat`. See also `day`, `ultimo`, `datStr` and `strDat`.

      : (datStr (date))
      -> "2007-06-01"
      : (week (date))
      -> 22

`(when 'any . prg) -> any`
  Conditional execution: When the condition `any` evaluates to non-`NIL`, `prg` is executed and the result is returned. Otherwise `NIL` is returned. See also `unless`, `if`, `and` and `cond`.

      : (when (> 4 3) (println 'OK) (println 'Good))
      OK
      Good
      -> Good

`(while 'any . prg) -> any`
  Conditional loop: While the condition `any` evaluates to non-`NIL`, `prg` is repeatedly executed. If `prg` is never executed, `NIL` is returned. Otherwise the result of `prg` is returned. See also `until`, `for`, `loop` and `do`.

      : (while (read)
         (println 'got: @) )
      abc
      got: abc
      1234
      got: 1234
      NIL
      -> 1234

`(what 'sym) -> lst`
  (Debug mode only) Returns a list of all internal symbols that match the pattern string `sym`. See also `match`, `who`, `has` and `can`.

      : (what "cd@dr")
      -> (cdaddr cdaadr cddr cddddr cdddr cddadr cdadr)

`(who 'any) -> lst`
  (Debug mode only) Returns a list of all functions or method definitions that contain the atom or pattern `any`. See also `match`, `what`, `has` and `can`.

      : (who 'caddr)                         # Who is using 'caddr'?
      -> ($dat lint1 expDat datStr $tim tim$ mail _gen dat$ datSym)

      : (who "Type error")
      -> ((mis> . +Link) *Uni (mis> . +Joint))

      : (more (who "Type error") pp)         # Pretty print all results
      (dm (mis> . +Link) (Val Obj)
         (and
            Val
            (nor (isa (: type) Val) (canQuery Val))
            "Type error" ) )
      .                                      # Stop
      -> T

`(wipe 'sym|lst) -> sym|lst`
  Clears the `VAL` and the property list of `sym`, or of all symbols in the list `lst`. When a symbol is an external symbol, its state is also set to "not loaded". Does nothing when `sym` is an external symbol that has been modified or deleted ("dirty").

      : (setq A (1 2 3 4))
      -> (1 2 3 4)
      : (put 'A 'a 1)
      -> 1
      : (put 'A 'b 2)
      -> 2
      : (show 'A)
      A (1 2 3 4)
         b 2
         a 1
      -> A
      : (wipe 'A)
      -> A
      : (show 'A)
      A NIL
      -> A

`(with 'var . prg) -> any`
  Saves the current object `This` and sets it to the new value `var`. Then `prg` is executed, and `This` is restored to its previous value. The return value is the result of `prg`. Used typically to access the local data of `var` in the same manner as inside a method body. `prg` is not executed (and `NIL` is returned) when `var` is `NIL`. `(with 'X . prg)` is equivalent to `(let? This 'X . prg)`.

      : (put 'X 'a 1)
      -> 1
      : (put 'X 'b 2)
      -> 2
      : (with 'X (list (: a) (: b)))
      -> (1 2)

`(wr 'cnt ..) -> cnt`
  Writes all `cnt` arguments as raw bytes to the current output channel. See also `rd` and `pr`.

      : (out "x" (wr 1 255 257))  # Write to "x"
      -> 257
      : (hd "x")
      00000000  01 FF 01                                         ...
      -> NIL

`(wrap 'cnt 'lst) -> sym`
  Returns a transient symbol with all characters in `lst` `pack`ed in lines with a maximal length of `cnt`. See also `tab`, `align` and `center`.

      : (wrap 20 (chop "The quick brown fox jumps over the lazy dog"))
      -> "The quick brown fox^Jjumps over the lazy^Jdog"
      : (wrap 8 (chop "The quick brown fox jumps over the lazy dog"))
      -> "The^Jquick^Jbrown^Jfox^Jjumps^Jover the^Jlazy dog"