Changeset 3877

Show
Ignore:
Timestamp:
05/25/05 15:02:29 (4 years ago)
Author:
scook0
svk:copy_cache_prev:
5385
Message:

* Minor English tweaks to PA02
* Fixed a comment that was confusing Haddock

Files:
2 modified

Legend:

Unmodified
Added
Removed
  • docs/02Internals.pod

    r3804 r3877  
    5959 
    6060This section does not discuss the files in detail. Pugs is documented with 
    61 haddock, and for reference that is the place to look. 
     61Haddock, and for reference that is the place to look. 
    6262 
    6363What this section B<does> provide is an overview of the responsibilities each 
     
    9999table at the bottom. 
    100100 
    101 The table basicallly says whether the builtin is infix or not, how many 
     101The table basically says whether the builtin is infix or not, how many 
    102102parameters it accepts, and so forth. 
    103103 
     
    106106This is the file that ties it all together, it takes a Perl 6 file, slurps 
    107107the string out of it, hands it to the parser, then takes the AST out and 
    108 sends it's envBody into the evaluator. 
     108sends its envBody into the evaluator. 
    109109 
    110110=head1 A PROGRAM'S LIFE CYCLE IN DETAIL 
     
    115115As we've seen before, the runtime calls the parser on the Perl code, and it, 
    116116in turn, generates an AST. Most parsed things result in trivial structures -- 
    117 just a representation of the program in something a bit more manipulatable 
     117just a representation of the program in something a bit more manipulable 
    118118than a string of source code. 
    119119 
    120 This basic structure, a node of the AST is called an C<Exp> - an expression. 
     120This basic structure, a node of the AST, is called an C<Exp> - an expression. 
    121121It represents the combination of values and operation, and the evaluator 
    122122knows to boil it down into a C<Val>. 
     
    130130 
    131131The parser is pure in that it does not affect the outside world when it does 
    132 it's thing. It constructs the AST, but not much more. 
     132its thing. It constructs the AST, but not much more. 
    133133 
    134134In order to execute things like C<BEGIN> blocks there are exceptions to 
     
    139139This operation has side effects - it causes the world outside the pugs 
    140140interpreter to change. However, it must happen within the "pure" parser, and 
    141 haskell does not normally allow these things. 
     141Haskell does not normally allow these things. 
    142142 
    143143The C<unsafe> in the name denotes that an effort was made to not care about 
     
    206206 
    207207For example C<reduce (Syn "env" [])> is the reduce that takes care of variable 
    208 declaration using C<VControl>, while C<reduce (Cxt cxt exp)> forces the sub 
    209 expression C<exp> to be evaluated in the context C<cxt>. 
     208declaration using C<VControl>, while C<reduce (Cxt cxt exp)> forces the  
     209subexpression C<exp> to be evaluated in the context C<cxt>. 
    210210 
    211211Let's look at some of the more interesting C<reduce>s. My personal favourite is 
     
    223223the body. C<for (@list) { print "i'm the body" }>. 
    224224 
    225 The body is actually a subroutine, we'll look at that in a bit. After those 
    226 lines are some details which we don't care about right now. Lets pretend they 
     225The body is actually a subroutine; we'll look at that in a bit. After those 
     226lines are some details which we don't care about right now. Let's pretend they 
    227227don't exist and jump down to 
    228228 
     
    256256 
    257257The line starting with C<apply> applies the subroutine currently in C<sub'>, 
    258 and gives it C<these> as it's paramters on the line starting with C<map>. 
     258and gives it C<these> as its parameters on the line starting with C<map>. 
    259259 
    260260Lastly, after the subroutine is applied, C<runBody> is run again on C<rest>. 
     
    269269C<&runBody>. 
    270270 
    271 When all the auxillery functions have been define, we can run the body with 
     271When all the auxiliary functions have been defined, we can run the body with 
    272272the list passed into the for (munging into C<elms> omitted): 
    273273 
     
    281281 
    282282 
    283 Subroutine application be very simple, in the case of a C<Prim>. At other 
     283Subroutine application can be very simple, in the case of a C<Prim>. At other 
    284284times it involves entering a lexical scope, due to block open. Sometimes 
    285285parameter binding is involved too. 
  • src/Pugs/Prim/List.hs

    r3827 r3877  
    232232    mapMn' []     _  = return [] 
    233233 
    234 -- | Takes an int and a list and returns a LoL. 
    235 --   Ex.: 
    236 --   > list2LoL 3 [1,2,3,4,5] = [[1,2,3],[4,5,undef]] 
     234{-| 
     235Takes an int and a list and returns a LoL. 
     236Ex.: 
     237 
     238> list2LoL 3 [1,2,3,4,5] = [[1,2,3],[4,5,undef]] 
     239-} 
    237240list2LoL :: Int -> [Val] -> [[Val]] 
    238241list2LoL n list