Skip to content

Commit

Permalink
Merge branch 'srfi-253'
Browse files Browse the repository at this point in the history
  • Loading branch information
egallesio committed Nov 24, 2024
2 parents 6844382 + 2a48f2b commit 555dd29
Show file tree
Hide file tree
Showing 14 changed files with 6,128 additions and 5,428 deletions.
3 changes: 2 additions & 1 deletion SUPPORTED-SRFIS
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ implemented in latest version is available at https://stklos.net/srfi.html):
- SRFI-230: Atomic Operations
- SRFI-232: Flexible Curried Procedures
- SRFI-233: INI files
- SRFI-234: Topological Sorting
- SRFI-234: Topological sorting
- SRFI-235: Combinators
- SRFI-236: Evaluating expressions in an unspecified order
- SRFI-238: Codesets
- SRFI-244: Multiple-value definitions
- SRFI-253: Data (Type-)Checking
66 changes: 56 additions & 10 deletions doc/HTML/stklos-ref.html
Original file line number Diff line number Diff line change
Expand Up @@ -19447,12 +19447,23 @@ <h3 id="doc_misc">4.22. Misc</h3>
</div>
<div class="paragraph">
<p>The special form <code>assume</code> is defined in <strong><a href="http://srfi.schemers.org/srfi-145/srfi-145.html">SRFI-145</a></strong> (<em>Assumptions</em>).
When <strong><em>STklos</em></strong> is in debug mode, this special form is an expression
that evaluates to the value of <code>obj</code> if <code>obj</code> evaluates to a true
value and it is an error if <code>obj</code> evaluates to a false value.</p>
When parameter object <code>compiler:verify-assume</code> is true, this special
form is an expression that evaluates to the value of <code>obj</code> if <code>obj</code>
evaluates to a true value and it is an error if <code>obj</code> evaluates to a
false value. When the parameter object <code>compiler:verify-assume</code> is
false the call to <code>assume</code> is elided (see <a href="#compflags">Section A.2.1</a>).</p>
</div>
<div class="paragraph">
<p>When <strong><em>STklos</em></strong> is not in debug mode, the call to <code>assume</code> is elided.</p>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
When <strong><em>STklos</em></strong> is run in debug mode, assumptions are evaluated.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>
Expand Down Expand Up @@ -26977,7 +26988,7 @@ <h2 id="doc_srfis">13. SRFIs</h2>
<div class="sect2">
<h3 id="doc_supported_srfis">13.1. Supported SRFIs</h3>
<div class="paragraph">
<p><strong><em>STklos</em></strong> supports <strong>126</strong> finalized SRFIS.
<p><strong><em>STklos</em></strong> supports <strong>127</strong> finalized SRFIS.
Some of these SRFIS are <em>embedded</em> and some are <em>external</em>.</p>
</div>
<div class="paragraph">
Expand Down Expand Up @@ -27113,7 +27124,8 @@ <h3 id="doc_supported_srfis">13.1. Supported SRFIs</h3>
- <strong><a href="http://srfi.schemers.org/srfi-235/srfi-235.html">SRFI-235</a></strong>&#8201;&#8212;&#8201;<em>Combinators</em><br>
- <strong><a href="http://srfi.schemers.org/srfi-236/srfi-236.html">SRFI-236</a></strong>&#8201;&#8212;&#8201;<em>Evaluating expressions in an unspecified order</em><br>
- <strong><a href="http://srfi.schemers.org/srfi-238/srfi-238.html">SRFI-238</a></strong>&#8201;&#8212;&#8201;<em>Codesets</em><br>
- <strong><a href="http://srfi.schemers.org/srfi-244/srfi-244.html">SRFI-244</a></strong>&#8201;&#8212;&#8201;<em>Multiple-value definitions</em><br></p>
- <strong><a href="http://srfi.schemers.org/srfi-244/srfi-244.html">SRFI-244</a></strong>&#8201;&#8212;&#8201;<em>Multiple-value definitions</em><br>
- <strong><a href="http://srfi.schemers.org/srfi-253/srfi-253.html">SRFI-253</a></strong>&#8201;&#8212;&#8201;<em>Data (Type-)Checking</em><br></p>
</div>
</div>
<div class="sect2">
Expand Down Expand Up @@ -27179,7 +27191,7 @@ <h4 id="doc_external_srfis">13.2.2. External SRFIs</h4>
</div>
<div class="paragraph">
<p><strong>List of external SRFIs:</strong>
<code>srfi-1</code> <code>srfi-2</code> <code>srfi-4</code> <code>srfi-5</code> <code>srfi-7</code> <code>srfi-9</code> <code>srfi-13</code> <code>srfi-14</code> <code>srfi-17</code> <code>srfi-19</code> <code>srfi-25</code> <code>srfi-26</code> <code>srfi-27</code> <code>srfi-29</code> <code>srfi-35</code> <code>srfi-36</code> <code>srfi-37</code> <code>srfi-41</code> <code>srfi-43</code> <code>srfi-48</code> <code>srfi-51</code> <code>srfi-54</code> <code>srfi-59</code> <code>srfi-60</code> <code>srfi-61</code> <code>srfi-64</code> <code>srfi-66</code> <code>srfi-69</code> <code>srfi-74</code> <code>srfi-89</code> <code>srfi-94</code> <code>srfi-95</code> <code>srfi-96</code> <code>srfi-100</code> <code>srfi-113</code> <code>srfi-115</code> <code>srfi-116</code> <code>srfi-117</code> <code>srfi-125</code> <code>srfi-127</code> <code>srfi-128</code> <code>srfi-129</code> <code>srfi-130</code> <code>srfi-132</code> <code>srfi-133</code> <code>srfi-134</code> <code>srfi-135</code> <code>srfi-137</code> <code>srfi-141</code> <code>srfi-144</code> <code>srfi-151</code> <code>srfi-152</code> <code>srfi-154</code> <code>srfi-156</code> <code>srfi-158</code> <code>srfi-160</code> <code>srfi-161</code> <code>srfi-162</code> <code>srfi-170</code> <code>srfi-171</code> <code>srfi-173</code> <code>srfi-174</code> <code>srfi-175</code> <code>srfi-178</code> <code>srfi-180</code> <code>srfi-185</code> <code>srfi-189</code> <code>srfi-190</code> <code>srfi-196</code> <code>srfi-207</code> <code>srfi-214</code> <code>srfi-215</code> <code>srfi-216</code> <code>srfi-217</code> <code>srfi-221</code> <code>srfi-222</code> <code>srfi-223</code> <code>srfi-224</code> <code>srfi-227</code> <code>srfi-228</code> <code>srfi-229</code> <code>srfi-230</code> <code>srfi-232</code> <code>srfi-233</code> <code>srfi-234</code> <code>srfi-235</code> <code>srfi-236</code> <code>srfi-238</code></p>
<code>srfi-1</code> <code>srfi-2</code> <code>srfi-4</code> <code>srfi-5</code> <code>srfi-7</code> <code>srfi-9</code> <code>srfi-13</code> <code>srfi-14</code> <code>srfi-17</code> <code>srfi-19</code> <code>srfi-25</code> <code>srfi-26</code> <code>srfi-27</code> <code>srfi-29</code> <code>srfi-35</code> <code>srfi-36</code> <code>srfi-37</code> <code>srfi-41</code> <code>srfi-43</code> <code>srfi-48</code> <code>srfi-51</code> <code>srfi-54</code> <code>srfi-59</code> <code>srfi-60</code> <code>srfi-61</code> <code>srfi-64</code> <code>srfi-66</code> <code>srfi-69</code> <code>srfi-74</code> <code>srfi-89</code> <code>srfi-94</code> <code>srfi-95</code> <code>srfi-96</code> <code>srfi-100</code> <code>srfi-113</code> <code>srfi-115</code> <code>srfi-116</code> <code>srfi-117</code> <code>srfi-125</code> <code>srfi-127</code> <code>srfi-128</code> <code>srfi-129</code> <code>srfi-130</code> <code>srfi-132</code> <code>srfi-133</code> <code>srfi-134</code> <code>srfi-135</code> <code>srfi-137</code> <code>srfi-141</code> <code>srfi-144</code> <code>srfi-151</code> <code>srfi-152</code> <code>srfi-154</code> <code>srfi-156</code> <code>srfi-158</code> <code>srfi-160</code> <code>srfi-161</code> <code>srfi-162</code> <code>srfi-170</code> <code>srfi-171</code> <code>srfi-173</code> <code>srfi-174</code> <code>srfi-175</code> <code>srfi-178</code> <code>srfi-180</code> <code>srfi-185</code> <code>srfi-189</code> <code>srfi-190</code> <code>srfi-196</code> <code>srfi-207</code> <code>srfi-214</code> <code>srfi-215</code> <code>srfi-216</code> <code>srfi-217</code> <code>srfi-221</code> <code>srfi-222</code> <code>srfi-223</code> <code>srfi-224</code> <code>srfi-227</code> <code>srfi-228</code> <code>srfi-229</code> <code>srfi-230</code> <code>srfi-232</code> <code>srfi-233</code> <code>srfi-234</code> <code>srfi-235</code> <code>srfi-236</code> <code>srfi-238</code> <code>srfi-253</code></p>
</div>
</div>
<div class="sect3">
Expand Down Expand Up @@ -32718,9 +32730,10 @@ <h3 id="doc_stklos_compiler">A.2. STklos compiler</h3>
<p>This procedure will not set the executable bit on the generated file.</p>
</div>
<div class="sect3">
<h4 id="doc_compiler_flags">A.2.1. Compiler flags</h4>
<h4 id="compflags">A.2.1. Compiler flags</h4>
<div class="paragraph">
<p><strong><em>STklos</em></strong> compiler behaviour can be customized by several parameters. Those parameters are described below.</p>
<p><strong><em>STklos</em></strong> compiler behaviour can be customized by several parameters.
Those parameters are described below.</p>
</div>
<div class="paragraph">
<p><a id='P_compiler:time-display'></a>
Expand Down Expand Up @@ -33033,6 +33046,39 @@ <h4 id="doc_compiler_flags">A.2.1. Compiler flags</h4>
<p>See that the <code>GLOBAL-REF</code> and <code>PUSH</code> were turned by the peephole optimizer
into <code>GLOBAL-REF-PUSH</code>.</p>
</div>
<div class="paragraph">
<p><a id='P_compiler:verify-assume'></a>
</p>
</div>
<div class="paragraph rmargin text-right">
<p><span class="rmargin small silver"><em>STklos</em> procedure</span></p>
</div>
<div class="sidebarblock">
<div class="content">
<div class="paragraph small">
<p><code><strong>(compiler:verify-assume) </strong></code><br>
<code><strong>(compiler:verify-assume bool) </strong></code><br></p>
</div>
</div>
</div>
<div class="paragraph">
<p>This parameter is used by the <code>assume</code> form (<strong><a href="http://srfi.schemers.org/srfi-145/srfi-145.html">SRFI-145</a></strong>).
If its value is <code>#t</code>, assumptions are not verified at all (their code is
not compiled). Otherwise, assumptions are verified.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
When <strong><em>STklos</em></strong> is in debug modethe debug mode, this parameter is
forced to <code>#t</code>.
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
Expand Down
9 changes: 6 additions & 3 deletions doc/refman/idiosync.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,13 @@ Compiling files from Scheme programs can be done with the

{{insertdoc 'compile-file}}

==== Compiler flags
[#compflags]

==== Compiler flags

{{stklos}} compiler behaviour can be customized by several parameters. Those parameters are described below.

{{stklos}} compiler behaviour can be customized by several parameters.
Those parameters are described below.

{{insertdoc 'compiler:time-display}}
{{insertdoc 'compiler:gen-line-number}}
Expand All @@ -189,4 +192,4 @@ Compiling files from Scheme programs can be done with the
{{insertdoc 'compiler:keep-source}}
{{insertdoc 'compiler:unroll-iterations}}
{{insertdoc 'compiler:peephole-optimizer}}

{{insertdoc 'compiler:verify-assume}}
4 changes: 4 additions & 0 deletions doc/stklos.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ optimizer during compilation. The peephole optimizer is used to change a
succession of instructions by another set of instructions that has better
performance. This flag uses the parameter \fIcompiler:peehole-optimizer\fR.
By default, the peephole optimizer is activated.
.IP "" 10
-\fIverify-assume\fR can be use to indicate if the compiler must include the
code necessary to verify the SRFI-145 assume forms, or not. This flag is false
by default, but it is forced to true if the debug mode is set.
.IP "-v, --version"
print program version and exit.
.IP "-V"
Expand Down
14 changes: 8 additions & 6 deletions lib/bonus.stk
Original file line number Diff line number Diff line change
Expand Up @@ -2699,15 +2699,17 @@ doc>
* (assume obj ...)
*
* The special form |assume| is defined in {{link-srfi 145}}.
* When {{stklos}} is in debug mode, this special form is an expression
* that evaluates to the value of |obj| if |obj| evaluates to a true
* value and it is an error if |obj| evaluates to a false value.
* When parameter object |compiler:verify-assume| is true, this special
* form is an expression that evaluates to the value of |obj| if |obj|
* evaluates to a true value and it is an error if |obj| evaluates to a
* false value. When the parameter object |compiler:verify-assume| is
* false the call to |assume| is elided (see <<compflags>>).
*
* When {{stklos}} is not in debug mode, the call to |assume| is elided.
* NOTE: When {{stklos}} is run in debug mode, assumptions are evaluated.
doc>
|#
(define-macro (assume expr . args)
(if (positive? (stklos-debug-level))
(if (compiler:verify-assume)
;; Assumptions are evaluated in debug mode ...
(let* ((efile (and (%epair? expr) (%epair-file expr)))
(eline (and (%epair? expr) (%epair-line expr)))
Expand All @@ -2716,7 +2718,7 @@ doc>
"")
"invalid assumption:")))
`(or ,expr
(error ,fmt ',expr ,@args)))
(error 'assume ,fmt ',expr ,@args)))
;; ... and ignored otherwise
#void))

Expand Down
3 changes: 2 additions & 1 deletion lib/boot.stk
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
;;;; Author: Erick Gallesio [[email protected]]
;;;; Creation date: 01-Jan-2000 15:04 (eg)
;;;;

;;
;; Following code is in the STklos module and is needed to ensure STklos
;; bootstrap
Expand Down Expand Up @@ -293,6 +293,7 @@
(compiler:warn-use-undefined #t) ; Signal usage of still undefined symbols
(compiler:gen-line-number #t) ; Generate line numbers
(compiler:keep-source #t) ; Keep function source
(compiler:verify-assume #t) ; Do verify the SRFI-145 assume calls
(when (> debug 1) ; Load-verbose when debug >= 2
(load-verbose debug)))

Expand Down
19 changes: 17 additions & 2 deletions lib/compflags.stk
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
compiler:inline-common-functions
compiler:unroll-iterations
compiler:peephole-optimizer
compiler:source-rewrite)
compiler:source-rewrite
compiler:verify-assume)

#|
<doc EXT compiler:time-display
Expand Down Expand Up @@ -218,7 +219,18 @@ doc>
* @lisp
* (begin (display "Hello") #t)
* @end lisp
* This parameter defaults to `#t`.
* This parameter defaults to `#t`.
doc>
<doc EXT compiler:verify-assume
* (compiler:verify-assume)
* (compiler:verify-assume bool)
*
* This parameter is used by the |assume| form ({{quick-link-srfi 145}}).
* If its value is `#t`, assumptions are not verified at all (their code is
* not compiled). Otherwise, assumptions are verified.
*
* NOTE: When {{stklos}} is in debug modethe debug mode, this parameter is
* forced to `#t`.
doc>
|#
(define-parameter compiler:time-display #t)
Expand All @@ -230,6 +242,8 @@ doc>
(define-parameter compiler:keep-source #f)
(define-parameter compiler:peephole-optimizer #t)
(define-parameter compiler:source-rewrite #t)
(define-parameter compiler:verify-assume #f)

(define-parameter compiler:unroll-iterations 4
(lambda (v)
(unless (and (fixnum? v) (positive? v))
Expand Down Expand Up @@ -280,6 +294,7 @@ doc>
((source-rewrite) (compiler:source-rewrite val))
((show-instructions) (compiler:show-assembly-code val))
((peephole-optimizer)(compiler:peephole-optimizer val))
((verify-assume) (compiler:verify-assume val))
(else (error "bad boolean flag ~s" flag))))
;; valued flag
(let* ((lst (string-split flag "=")))
Expand Down
Loading

0 comments on commit 555dd29

Please sign in to comment.