Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
== Outdated egg! This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for [[/eggref/5/F-operator|the CHICKEN 5 version of this egg]], if it exists. If it does not exist, there may be equivalent functionality provided by another egg; have a look at the [[https://wiki.call-cc.org/chicken-projects/egg-index-5.html|egg index]]. Otherwise, please consider porting this egg to the current version of CHICKEN. [[tags: egg]] == F-operator [[toc:]] == Documentation The static delimited continuation operators shift and reset. === Shift/Reset - Dynamically scoped shift/reset <enscript language=scheme> (require-extension shift-reset) </enscript> A "stuck on control" situation, a 'shift' without an enclosing 'reset', is an error. ==== reset <macro>(reset EXPRESSION ...)</macro> Evaluate the body {{EXPRESSION ...}} with a delimited continuation. The body will contain one or more instances of {{(shift ...)}}. ==== shift <macro>(shift PC-TAG EXPRESSION)</macro> Within the scope of {{EXPRESSION}} {{PC-TAG}} is bound to the reified partial continuation delimited by the enclosing {{(reset ...)}}. Provide a value to the partial continuation using the form {{(PC-TAG <something>)}}. ==== reset-values <macro>(reset-values EXPRESSION ...)</macro> Multiple value return version of {{(reset ...)}}. The body will contain one or more instances of {{(shift-values ...)}}. ==== shift-values <macro>(shift-values PC-TAG EXPRESSION)</macro> Multiple value return version of {{(shift ...)}}. Provide a value to the partial continuation using the form {{(PC-TAG <something> ...)}}. === BShift/BReset - Statically scoped shift/reset <enscript language=scheme> (require-extension bshift-breset) </enscript> Invalid delimited continuations, what {{RC-TAG}} below represents, and ''stuck on control'' will generate an error ==== breset <macro>(breset RC-TAG EXPRESSION ...)</macro> Evaluate the body {{EXPRESSION ...}} with a delimited continuation named {{RC-TAG}}. The body will contain one or more instances of {{(bshift RC-TAG ...)}}. ==== bshift <macro>(bshift RC-TAG PC-TAG EXPRESSION)</macro> Within the scope of {{EXPRESSION}} {{PC-TAG}} is bound to the reified partial continuation delimited by the enclosing {{(breset RC-TAG ...)}}. Provide a value to the partial continuation using the form {{(PC-TAG <something>)}}. ==== breset-values <macro>(breset-values RC-TAG EXPRESSION ...)</macro> Multiple value return version of {{(breset ...)}}. The body will contain one or more instances of {{(bshift-values RC-TAG ...)}}. ==== bshift-values <macro>(bshift-values RC-TAG PC-TAG EXPRESSION)</macro> Multiple value return version of {{(bshift ...)}}. Provide a value to the partial continuation using the form {{(PC-TAG <something> ...)}}. === Range <enscript language=scheme> (require-extension range) </enscript> ==== range <macro>(range RC-TAG FROM VALUE STEP TO?)</macro> The value of the delimited continuation {{RC-TAG}} ranges over the set of values specified by the state generation procedure suite. For use with {{(breset ...)}} ; FROM : Zero argument procedure, returning the initial state ; VALUE : Single argument procedure, of the state, returning the value of the state ; STEP : Single argument procedure, of the state, returning the next state ; TO? : Single argument procedure, of the state, returning {{#t) when the range is complete ==== range <macro>(range RC-TAG FROM [STEP] TO)</macro> The value of the delimited continuation {{RC-TAG}} ranges over the number interval [{{FROM}} {{TO}}], by {{STEP}}. The increment is 1 when missing. For use with {{(breset ...)}}. === Reflect/Reify - Monads <enscript language=scheme> (require-extension reflect-reify) </enscript> The Monad example from Filinski, POPL '94 ==== define-unit <macro>(define-unit KIND BODY ...)</macro> Expands to {{(define (KIND-unit obj) BODY ...)}}. ==== define-bind <macro>(define-bind KIND BODY ...)</macro> Expands to {{(define (KIND-bind monad func) BODY ...)}}. ==== reflect <macro>(reflect KIND MONAD)</macro> Extract value from {{MONAD}}. Plays the role of Haskell '<-'. ==== reflect-values <macro>(reflect-values KIND MONAD)</macro> Extract value from {{MONAD}}. Plays the role of Haskell '<-'. ==== reify <macro>(reify KIND EXPRESSION)</macro> Return result of {{EXPRESSION}} as a monad. ==== reify-values <macro>(reify-values KIND EXPRESSION)</macro> Return result of {{EXPRESSION}} as a monad. === GShift/GReset - Generalized shift/reset <enscript language=scheme> (require-extension gshift-greset) </enscript> The generalized shift and reset operator family from [[http://www.cs.indiana.edu/cgi-bin/techreports/TRNNN.cgi?trnum=TR611|How to remove a dynamic prompt: static and dynamic delimited continuation operators are equally expressible]] ==== greset <macro>(greset HR E)</macro> Reset parameterized by the H Reset procedure {{HR}}. ==== gshift <macro>(gshift HS F E)</macro> Shift parameterized by the H Shift procedure {{HS}}. ==== hr-stop <procedure>(hr-stop V)</procedure> H Reset Stop. ==== hs-stop <procedure>(hs-stop V)</procedure> H Shift Stop ==== hr-prop <procedure>(hr-prop V)</procedure> H Reset Propagate. ==== hs-prop <procedure>(hs-prop V)</procedure> H Shift Propagate. ==== h-compose <procedure>(h-compose F X)</procedure> Returns the composition of {{F}} and {{X}} as an {{h-datatype}}. ==== h-value <procedure>(h-value V)</procedure> Returns the value of {{V}} as an {{h-datatype}}. ==== h-datatype? <procedure>(h-datatype? OBJECT)</procedure> Is {{OBJECT}} an {{h-datatype}}? ==== h-cases <macro>(h-cases E ((F X) ON-h-EXPR) (V ON-V-EXPR))</macro> Deconstructs the {{h-datatype}} {{E}}, binding {{F}} & {{X}} for an evaluation of the {{ON-h-EXPR}} and {{V}} for an evaluation of the {{ON-V-EXPR}}. == Usage See individual sections. == Examples <enscript language=scheme> (use shift-reset srfi-41 srfi-45) (define (my-list->stream list) (iteration-procedure->stream (lambda (receiver) (for-each receiver list)))) (define (iteration-procedure->stream iteration-procedure) (reset (iteration-procedure (lambda (element) (shift continue-iteration (stream-cons element (lazy (continue-iteration (void))))))) stream-null)) </enscript> == Notes * The {{reflect-reify}} module (Monads) is an example of the use of {{shift}}/{{reset}}. Not a general purpose implementation for use in Scheme monadic programming. == Requirements [[datatype]] [[miscmacros]] == Bugs and Limitations * Not a direct implementation of partial continuations. Simulated using full continuations. As such prey to the issues elaborated by [[http://okmij.org/ftp/continuations/against-callcc.html#traps|"call/cc implements shift? A good question"]]. * The distinction between the single-valued return & multi-valued return versions of the control operators, ex: {{shift}} & {{shift-values}}. The current single-valued syntax should handle multi-value returns. == Author [[/users/kon-lovett|Kon Lovett]] == Version history ; 3.0.0 : Remove {{%reset}}, {{%shift}}, {{%reset-values}}, {{%shift-values}}, {{%breset}}, {{%bshift}}, {{%breset-values}}, {{%bshift-values}}, {{%range}}, {{%reflect}}, & {{%reify}}. ; 2.0.4 : Has argc-checks. ; 2.0.3 : Use {{er-macro-transformer}}. ; 2.0.2 : Has lambda-info. ; 2.0.1 : Added miscmacros as a dependency [Ivan Raikov]. ; 2.0.0 : Initial Chicken 4 release. == License Copyright (C) 2009 Kon Lovett. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Does not supercede any restrictions found in the source code.
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you subtract 11 from 15?