== SRFI 5: A compatible let form with signatures and rest arguments This egg extends the syntax of {{let}} to allow {{define}}-like named let forms with optional "rest" arguments. [[toc:]] == SRFI description This page is intended to document the forms exported by the egg. For a full description of SRFI 5, see [[https://srfi.schemers.org/srfi-5/srfi-5.html|the SRFI document]]. == Specification === Signature-style syntax Using the {{let}} form provided by this egg, the following (let (fibonacci (n 10) (i 0) (f0 0) (f1 1)) (if (= i n) f0 (fibonacci n (+ i 1) f1 (+ f0 f1)))) is equivalent to (let fibonacci ((n 10) (i 0) (f0 0) (f1 1)) (if (= i n) f0 (fibonacci n (+ i 1) f1 (+ f0 f1)))) === Rest Arguments This egg allows named let forms with rest parameters. For example, (let (blast (port (current-output-port)) . (x (+ 1 2) 4 5)) (if (null? x) 'just-a-silly-contrived-example (begin (write (car x) port) (apply blast port (cdr x))))) is equivalent to (letrec ((blast (lambda (port . x) (if (null? x) 'just-a-silly-contrived-example (begin (write (car x) port) (apply blast port (cdr x))))))) (blast (current-output-port) (+ 1 2) 4 5)) Note: Users of this feature should be aware of the potential for space leaks. In the above snippet, for example, the list denoted by ''x'' will be newly allocated on each recursive call. === Syntax ==== 1. Unnamed (let (( )...) ...) ==== 2. Named, non-signature-style, no rest argument (let (( )...) ...) ==== 3. Named, signature-style, no rest argument (let ( ( )...) ...) ==== 4. Named, non-signature-style, rest argument (let ( ( )... . ( ...)) ...) === Semantics Let {{$lambda}} and {{$letrec}} be hygienic bindings for the {{lambda}} and {{letrec}} forms, respectively. For informal syntax 1: (($lambda (...) ...) ...) For informal syntaxes 2 and 3: ($letrec (( ($lambda (...) ...))) ( ...)) For informal syntaxes 4 and 5: ($letrec (( ($lambda (... . ) ...))) ( ... ...)) == About this egg === Author Andy Gaynor === Maintainer Wolfgang Corcoran-Mathe Contact: {{wcm at sigwinch dot xyzzy without the zy}} === Repository [[https://github.com/Zipheir/srfi-5|GitHub]] === Version history ; 0.1 : (2020-11-11) Ported to Chicken Scheme 5 (Sergey Goldgaber). ; 0.2 : (2020-11-16) Fixed broken egg file name (Sergey Goldgaber). ; 0.3 : (2022-04-25) Change maintainer, fix import. ; 0.3.1 : (2022-04-26) Egg infrastructure fixes. ; 0.3.2 : (2022-04-29) Add tests, rework wiki page. === Copyright Copyright (C) Andy Gaynor (1999). All Rights Reserved. This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself may not be modified in any way, such as by removing the copyright notice or references to the Scheme Request For Implementation process or editors, except as needed for the purpose of developing SRFIs in which case the procedures for copyrights defined in the SRFI process must be followed, or as required to translate it into languages other than English. The limited permissions granted above are perpetual and will not be revoked by the authors or their successors or assigns. This document and the information contained herein is provided on an "AS IS" basis and THE AUTHOR AND THE SRFI EDITORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.