Revision 28173

Date:
2009/09/02 19:56:15
Author:
lwall
Revision Log:
[S02] document Rat and Complex literals
Files:

Legend:

 
Added
 
Removed
 
Modified
  • docs/Perl6/Spec/S02-bits.pod

     
    13 13
    14 14 Created: 10 Aug 2004
    15 15
    16 Last Modified: 31 Aug 2009
    17 Version: 176
    16 Last Modified: 2 Sep 2009
    17 Version: 177
    18 18
    19 19 This document summarizes Apocalypse 2, which covers small-scale
    20 20 lexical items and typological issues. (These Synopses also contain
     
    2553 2553
    2554 2554 =item *
    2555 2555
    2556 Rational literals are indicated by separating two integer literals
    2557 (in any radix) with a slash. Whitespace is not allowed on either
    2558 side of the slash:
    2559
    2560 1/2 # one half literal Rat
    2561 1 / 2 # 1 divided by 2 (also produces a Rat by constant folding)
    2562
    2563 Note that this essentially overrides precedence to produce a term, so:
    2564
    2565 1/2 * 3/4
    2566
    2567 means
    2568
    2569 (1 / 2) * (3 / 4)
    2570
    2571 rather than
    2572
    2573 ((1 / 2) * 3) / 4
    2574
    2575 =item *
    2576
    2577 Complex literals are similarly indicated by writing an addition of
    2578 two real numbers without spaces:
    2579
    2580 5.2+1e42i
    2581
    2582 As with rational literals, constant folding would produce the same
    2583 complex number, but this form parses as a single term, ignoring
    2584 surrounding precedence.
    2585
    2586 =item *
    2587
    2556 2588 Characters indexed by hex numbers can be interpolated into strings
    2557 2589 by introducing with C<"\x">, followed by either a bare hex number
    2558 2590 (C<"\x263a">) or a hex number in square brackets (C<"\x[263a]">).