aboutsummaryrefslogtreecommitdiffstats
path: root/chicken.svnwiki
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2025-10-26 13:26:34 -0400
committerGravatar Peter McGoron 2025-10-26 13:26:34 -0400
commita2b1d33a61bc134b46ecf2e8b4e3e34023cf4d6d (patch)
tree038144c881ca0b6c97f553004cf37ae3b318e5ed /chicken.svnwiki
parent0.1.0 (diff)
tests, chibi support
Diffstat (limited to 'chicken.svnwiki')
-rw-r--r--chicken.svnwiki93
1 files changed, 79 insertions, 14 deletions
diff --git a/chicken.svnwiki b/chicken.svnwiki
index 23dd9b4..d03d749 100644
--- a/chicken.svnwiki
+++ b/chicken.svnwiki
@@ -34,6 +34,12 @@ Since HaScheme is lazy, one can write infinite lists with it:
This code snippet will run in a constant amount of space. (The procedure {{!}} is a strictness annotation to avoid thunk buildup. Since HaScheme is emedded within a call-by-value language, the strictness annotation will always force {{i}} at every iteration of the loop, even if neither part of the pair is accessed.)
+Why use this?
+
+1. To have fun.
+2. To show Haskellers that you don't need some fancy static type system to have pervasive lazyness.
+3. To implement lazy code that can be used with strict code.
+
HaScheme does not support continuations, parameters, exceptions, or multiple value returns.
=== Author
@@ -61,14 +67,16 @@ Exports everything from {{(scheme base)}} as lazy procedures, except
* Anything to do with ports, except for {{eof-object}} and {{eof-object?}}
* {{make-parameter}}, {{parameterize}}
* Anything involving exceptions, except for {{error}}, {{error-object?}}, {{error-object-message}}, {{error-object-irritants}}
-* {{do}}
+* {{for-each}}, {{vector-for-each}}
* {{floor/}}, {{truncate/}}, and {{exact-integer-sqrt}} are exported, but return lists.
The functions act as one would expect they would act. Forcing {{(car x)}} forces {{x}}, but forcing {{(cons x y)}} does not force {{x}} or {{y}}.
Syntax that introduces procedures, like {{lambda}}, {{define}}, and named {{let}} make lazy procedures. Lazy procedures return a promise that when forced, force the body of the procedure.
-Note that control syntax like {{if}} and {{cond}} are still syntax. They can be implemented as functions, but then they will have subtly different behavior when it comes to explicitly forcing values.
+Bodies are regular bodies: they can have internal {{define}}s.
+
+Note that control syntax like {{if}} and {{cond}} are still syntax. They can be implemented as functions, but then they will have subtly different behavior when it comes to explicitly forcing values. Conditinoals force tests.
String, bytevector, and number constructors are always eager. List and vector constructors are lazy.
@@ -78,6 +86,16 @@ This library also exports {{seq}}.
Forces all arguments except its last argument. Returns its last argument unchanged.
+<syntax>(define-record-type name (cstr name ...) predicate? (name accessor) ...)</syntax>
+
+Creates a record type, as if by the regular {{define-record-type}}. This form gives no way to create setters.
+
+The constructor is always non-strict in its arguments, and the accessors always force their arguments.
+
+<syntax>(do ((id init [update]) ...) (condition body ...) inner-body ...)</syntax>
+
+Like the do loop of before, except that the value that {{inner-body ...}} eventually evaluates to is forced for effect. Since {{inner-body ...}} is a body, nothing else is forced for effect. Consider using {{seq}} here.
+
==== {{(hascheme case-lambda)}}
Exports {{case-lambda}}, which creates lazy procedures.
@@ -92,11 +110,11 @@ Exports lazy procedure versions of {{(scheme complex)}}.
==== {{(hascheme cxr)}}
-Exports lazy procedure versions of {{(hascheme cxr)}}.
+Exports lazy procedure versions of {{(scheme cxr)}}.
==== {{(hascheme inexact)}}
-Exports lazy procedure versions of {{(hascheme inexact)}}.
+Exports lazy procedure versions of {{(scheme inexact)}}.
==== {{(hascheme control)}}
@@ -147,6 +165,47 @@ Returns a promise to force each {{expr}}, bind it to {{formal}}, and then execut
This library also exports {{seq}}.
+==== {{(hascheme lists)}}
+
+This library exports all identifiers from [[https://srfi.schemers.org/srfi-1|SRFI-1]], except for
+
+* {{circular-list?}}
+* {{car+cdr}}
+* {{length+}}
+* {{for-each}}, {{pair-for-each}}, {{map-in-order}}
+* {{set-car!}}, {{set-cdr!}}
+* {{unzip[n]}} (see below)
+
+All procedures that normally return multiple values return lists.
+
+In addition, this library exports other procedures.
+
+<procedure>(length>=? list n)</procedure>
+<procedure>(length>? list n)</procedure>
+<procedure>(length<=? list n)</procedure>
+<procedure>(length<? list n)</procedure>
+<procedure>(length=? list n)</procedure>
+
+Determine the size of the list by looking at only {{n}} elements. This
+will decide the size of finite or infinite lists in all cases where {{n}}
+is not infinite. All list lengths are less than or equal to infinity,
+and all lists are not greater than infinity.
+
+<procedure>(unzip lists)</procedure>
+
+Returns a list, whose first element is the first element of each {{lists}},
+the second element is the second element of each {{lists}}, and so on until
+the first empty list.
+
+<procedure>(list-iterate proc base)</procedure>
+
+This procedure is based off of the one in [[https://srfi.schemers.org/srfi-41/srfi-41.html|SRFI-41]].
+
+Create an infinite list where the first element is {{(proc base)}}, and
+the second element is {{(proc (proc base))}}, etc.
+
+This procedure is eager in {{base}}.
+
=== Misc. Information
==== How is it implemented?
@@ -163,7 +222,7 @@ Three critical things are needed to make HaScheme ergonomic:
*# Forcing a value returns the value.
*# Forcing {{(delay-force x)}} is equivalent to a tail call to {{(force x)}}.
-Chicken does all three. There is nothing fancy going on here, just some (relatively) easy-to-understand {{syntax-rules}} macros.
+Chicken does all three. There is nothing fancy going on here, just some (relatively) easy-to-understand {{syntax-rules}} macros. There is a shim for implementations that don't offer the above guarantees.
==== Fun (or pain) with Laziness
@@ -294,16 +353,22 @@ values without forcing the promise.
* Lightly tested.
* I want to implement some purely functional data structures.
+== Version History
+
+; 0.2.0 : Added missing {{do}} form, misc. fixes, alot more tests, lists library, change license to 0BSD
+; 0.1.0 : Initial Release
+
=== License
-Copyright 2025 Peter McGoron
+Copyright (C) Peter McGoron 2025
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at [[http://www.apache.org/licenses/LICENSE-2.0]].
+Permission to use, copy, modify, and/or distribute this software for
+any purpose with or without fee is hereby granted.
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.