relpipe-tr-guile.cpp → relpipe-tr-scheme.cpp v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Fri, 25 Sep 2020 14:38:24 +0200
branchv_0
changeset 316 d7ae02390fac
parent 315 d4c2968a391f
child 317 fce3d6290c40
relpipe-tr-guile.cpp → relpipe-tr-scheme.cpp
relpipe-data/download.xml
relpipe-data/examples-guile-aggregations.xml
relpipe-data/examples-guile-filtering.xml
relpipe-data/examples-guile-multiple-relations.xml
relpipe-data/examples-guile-parametrized-queries.xml
relpipe-data/examples-guile-projections.xml
relpipe-data/examples-in-sql-reading-sql.xml
relpipe-data/examples-parallel-hashes.xml
relpipe-data/examples-runnable-jars.xml
relpipe-data/examples/awk-through-xml.sh
relpipe-data/examples/guile-file-count-size-sum.sh
relpipe-data/implementation.xml
relpipe-data/index.xml
--- a/relpipe-data/download.xml	Sat Sep 12 13:20:21 2020 +0200
+++ b/relpipe-data/download.xml	Fri Sep 25 14:38:24 2020 +0200
@@ -39,9 +39,9 @@
 hg clone https://hg.globalcode.info/relpipe/relpipe-tr-awk.cpp;
 hg clone https://hg.globalcode.info/relpipe/relpipe-tr-cut.cpp;
 hg clone https://hg.globalcode.info/relpipe/relpipe-tr-grep.cpp;
-hg clone https://hg.globalcode.info/relpipe/relpipe-tr-guile.cpp;
 hg clone https://hg.globalcode.info/relpipe/relpipe-tr-python.cpp;
 hg clone https://hg.globalcode.info/relpipe/relpipe-tr-sed.cpp;
+hg clone https://hg.globalcode.info/relpipe/relpipe-tr-scheme.cpp;
 hg clone https://hg.globalcode.info/relpipe/relpipe-tr-sql.cpp;
 hg clone https://hg.globalcode.info/relpipe/relpipe-tr-validator.cpp;
 hg clone https://hg.globalcode.info/relpipe/relpipe-web;]]></pre>
--- a/relpipe-data/examples-guile-aggregations.xml	Sat Sep 12 13:20:21 2020 +0200
+++ b/relpipe-data/examples-guile-aggregations.xml	Fri Sep 25 14:38:24 2020 +0200
@@ -2,15 +2,15 @@
 	xmlns="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/strana"
 	xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro">
 	
-	<nadpis>Aggregating data with Guile</nadpis>
+	<nadpis>Aggregating data with Scheme</nadpis>
 	<perex>counting records and computing sum</perex>
 	<m:pořadí-příkladu>01700</m:pořadí-příkladu>
 
 	<text xmlns="http://www.w3.org/1999/xhtml">
 		
 		<p>
-			In <code>relpipe-tr-guile</code> we can generate new records – not only modify records from the input.
-			There is <code>--has-more-records</code> option which – if evaluated as true – says: „read one more record from the Guile context and call me again“.
+			In <code>relpipe-tr-scheme</code> we can generate new records – not only modify records from the input.
+			There is <code>--has-more-records</code> option which – if evaluated as true – says: „read one more record from the Scheme context and call me again“.
 			We can also suppress all original records by <code>--where '#f'</code>.
 			And we can also change the structure of the relation (see previous examples).
 			Thus we can iterate through a relation but completely replace its structure and content.
@@ -49,7 +49,7 @@
 		</p>
 		
 		<p>
-			One day, there might also be a translator that parses SQL code and generates Guile code,
+			One day, there might also be a translator that parses SQL code and generates Scheme code,
 			so we could have advantages of both worlds
 			a) concise and declarative syntax of SQL and 
 			b) streaming – which means no need for putting all the data in the RAM or on the disk.
--- a/relpipe-data/examples-guile-filtering.xml	Sat Sep 12 13:20:21 2020 +0200
+++ b/relpipe-data/examples-guile-filtering.xml	Fri Sep 25 14:38:24 2020 +0200
@@ -2,7 +2,7 @@
 	xmlns="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/strana"
 	xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro">
 	
-	<nadpis>Complex filtering with Guile</nadpis>
+	<nadpis>Complex filtering with Scheme</nadpis>
 	<perex>filtering records with AND, OR and functions</perex>
 	<m:pořadí-příkladu>01400</m:pořadí-příkladu>
 
@@ -12,12 +12,12 @@
 			For simple filtering, we can use <code>relpipe-tr-grep</code>.
 			But what if we need to write some complex query that contains AND and OR operators?
 			What if we need e.g. compare numbers – not only match texts against regular expressions?
-			There is a tool capable to do this and much more: <code>relpipe-tr-guile</code>!
+			There is a tool capable to do this and much more: <code>relpipe-tr-scheme</code>!
 		</p>
 		
 		<p>
 			<a href="https://www.gnu.org/software/guile/">Guile</a> is the GNU implementation of Scheme language (something like Lisp and also full of parenthesis).
-			The <code>relpipe-tr-guile</code> uses GNU Guile as a library, puts data in the Guile context and evaluates Guile expressions and then reads data from the Guile context back and generates relational output from them.
+			The <code>relpipe-tr-scheme</code> reference implementation uses GNU Guile as a library, puts data in the Scheme context and evaluates Scheme expressions and then reads data from the Scheme context back and generates relational output from them.
 			Good news are that it is not necessary to know Lisp/Scheme to use this tool. For the first steps, it can be used just as a query language – like SQL, just a bit Polish.
 		</p>
 		
@@ -29,7 +29,7 @@
 		
 		<m:pre jazyk="bash"><![CDATA[find /usr/share/icons/ -type f -print0 \
 	| relpipe-in-filesystem \
-	| relpipe-tr-guile --relation 'files.*' --where '(= $size 666)' \
+	| relpipe-tr-scheme --relation 'files.*' --where '(= $size 666)' \
 	| relpipe-out-tabular]]></m:pre>
 	
 		<p>Well, well… here we are:</p>
@@ -54,7 +54,7 @@
  ╰───────────────────────────────────────────────────────────────────────┴───────────────┴────────────────┴────────────────┴────────────────╯
 Record count: 13]]></m:pre>
 
-		<p>The <code>--relation 'files.*'</code> is a regular expression that says which relations should be processed in Guile – others are passed through unchanged.</p>
+		<p>The <code>--relation 'files.*'</code> is a regular expression that says which relations should be processed in Scheme – others are passed through unchanged.</p>
 		
 		<p>
 			The <code>--where '(= $size 666)'</code> is our condition. 
@@ -65,11 +65,11 @@
 		</p>
 		
 		<p>
-			Relational attributes are mapped to Guile variables with same name, just prefixed with <code>$</code>.
+			Relational attributes are mapped to Scheme variables with same name, just prefixed with <code>$</code>.
 			(we considered <code>
 				<abbr title="Bitcoin">₿</abbr>
 			</code> symbol, but <code>$</code> seems to be still more common on keyboards in 2019)
-			While relational attribute name is an arbitrary string, Guile variable names have some limitations, thus not all attributes can be mapped – those with spaces and some special characters are currently unsupported (this will be fixed in later versions by some kind of encoding/escaping).
+			While relational attribute name is an arbitrary string, Scheme variable names have some limitations, thus not all attributes can be mapped – those with spaces and some special characters are currently unsupported (this will be fixed in later versions by some kind of encoding/escaping).
 		</p>
 		
 		<p>
@@ -88,7 +88,7 @@
 		</p>
 		
 		<m:pre jazyk="bash"><![CDATA[relpipe-in-fstab \
-	| relpipe-tr-guile --relation 'fstab' --where '(string= $type "btrfs")' \
+	| relpipe-tr-scheme --relation 'fstab' --where '(string= $type "btrfs")' \
 	| relpipe-out-tabular]]></m:pre>
 	
 		<p>The Btrfs filesystems in our <code>fstab</code>:</p>
@@ -106,7 +106,7 @@
 		</p>
 
 		<m:pre jazyk="bash"><![CDATA[relpipe-in-fstab \
-	| relpipe-tr-guile --relation 'fstab' --where '(string-prefix? "/mnt" $mount_point)' \
+	| relpipe-tr-scheme --relation 'fstab' --where '(string-prefix? "/mnt" $mount_point)' \
 	| relpipe-out-tabular]]></m:pre>
 		
 		<p>So we can find filesystems mounted somewhere under <code>/mnt</code>:</p>
@@ -130,7 +130,7 @@
 		
 		<p>
 			Like in SQL, we can join multiple conditions together with logical operators AND and OR.
-			In Guile/Scheme these operators are also functions – they are written in the same <code>(</code>fashion<code>)</code>.
+			In Scheme these operators are also functions – they are written in the same <code>(</code>fashion<code>)</code>.
 		</p>
 		
 		<p>
@@ -139,7 +139,7 @@
 		
 		<m:pre jazyk="bash"><![CDATA[find /usr/share/icons/ -type f -print0 \
 	| relpipe-in-filesystem --file path --file size \
-	| relpipe-tr-guile --relation 'files.*' --where '(or (= $size 666) (= $size 1984) )' \
+	| relpipe-tr-scheme --relation 'files.*' --where '(or (= $size 666) (= $size 1984) )' \
 	| relpipe-out-tabular]]></m:pre>
 	
 		<p>Files with sizes 666 bytes or 1984 bytes:</p>
@@ -172,7 +172,7 @@
 		
 		<m:pre jazyk="bash"><![CDATA[find /usr/share/icons/ -type f -print0 \
 	| relpipe-in-filesystem --file path --file size \
-	| relpipe-tr-guile \
+	| relpipe-tr-scheme \
 		--relation 'files.*' \
 		--where '(and (string-suffix? ".svg" $path) (= $size 1984) )' \
 	| relpipe-out-tabular]]></m:pre>
--- a/relpipe-data/examples-guile-multiple-relations.xml	Sat Sep 12 13:20:21 2020 +0200
+++ b/relpipe-data/examples-guile-multiple-relations.xml	Fri Sep 25 14:38:24 2020 +0200
@@ -2,14 +2,14 @@
 	xmlns="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/strana"
 	xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro">
 	
-	<nadpis>Processing multiple relations with Guile</nadpis>
+	<nadpis>Processing multiple relations with Scheme</nadpis>
 	<perex>filter some relations and others keep unaffected</perex>
 	<m:pořadí-příkladu>01800</m:pořadí-příkladu>
 
 	<text xmlns="http://www.w3.org/1999/xhtml">
 		
 		<p>
-			The <code>relpipe-tr-guile</code> is capable to process multiple relations in a single pass.
+			The <code>relpipe-tr-scheme</code> is capable to process multiple relations in a single pass.
 			So we can filter some relations and let others flow unaffected through this pipeline step.
 		</p>
 
@@ -21,9 +21,9 @@
 # put them together in a single stream function:
 sample-data() { r1; r2; r3; }
 
-# let them flow through our Guile transformation:
+# let them flow through our Scheme transformation:
 sample-data \
-	| relpipe-tr-guile \
+	| relpipe-tr-scheme \
 		--relation fstab \
 			--where '(or (string= $type "btrfs") (string-prefix? "/mnt/" $mount_point) )' \
 		--relation filesystem \
@@ -74,7 +74,7 @@
 
 
 		<p>
-			In Guile, we have filtered the <code>fstab</code> and <code>filesystem</code> relations
+			In Scheme, we have filtered the <code>fstab</code> and <code>filesystem</code> relations
 			while the <code>seq</code> relation was kept intact.
 		</p>
 		
@@ -85,7 +85,7 @@
 		</p>
 		
 		<p>
-			If we define some variables in the Guile context, they will stay there – so we can pass data across relations.
+			If we define some variables in the Scheme context, they will stay there – so we can pass data across relations.
 			Thus we can do even JOIN, if we really want.
 		</p>
 
--- a/relpipe-data/examples-guile-parametrized-queries.xml	Sat Sep 12 13:20:21 2020 +0200
+++ b/relpipe-data/examples-guile-parametrized-queries.xml	Fri Sep 25 14:38:24 2020 +0200
@@ -2,7 +2,7 @@
 	xmlns="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/strana"
 	xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro">
 	
-	<nadpis>Parametrized queries with Guile</nadpis>
+	<nadpis>Parametrized queries with Scheme</nadpis>
 	<perex>passing input parameters and avoiding code-injections</perex>
 	<m:pořadí-příkladu>01600</m:pořadí-příkladu>
 
@@ -20,7 +20,7 @@
 		
 		<m:pre jazyk="bash"><![CDATA[fstab-where-type() {
 	relpipe-in-fstab \
-		| relpipe-tr-guile \
+		| relpipe-tr-scheme \
 			--relation fstab \
 			--where '(string= $type "'$1'")' \
 		| relpipe-out-tabular;
@@ -37,20 +37,20 @@
 Record count: 1]]></m:pre>
 		
 		<p>
-			But it is fundamentally wrong. The input parameter is blindly pasted in middle of the Guile code.
+			But it is fundamentally wrong. The input parameter is blindly pasted in middle of the Scheme code.
 			So if we call e.g. <code>fstab-where-type 'ext4"'</code>, it crashes terribly.
 			Do you remember SQL injections in your first PHP scripts when you were 14?
 			Do not do it again!
 		</p>
 		
 		<p>
-			The <code>relpipe-tr-guile</code> tool has a safe way for passing parameters from the outside. And such parameters are even strongly typed.
+			The <code>relpipe-tr-scheme</code> tool has a safe way for passing parameters from the outside. And such parameters are even strongly typed.
 			So this is, how our program should be written:
 		</p>
 
 		<m:pre jazyk="bash"><![CDATA[fstab-where-type() {
 	relpipe-in-fstab \
-		| relpipe-tr-guile \
+		| relpipe-tr-scheme \
 			--relation fstab \
 			--define 'myRequestedType' string "$1" \
 			--where '(string= $type myRequestedType)' \
--- a/relpipe-data/examples-guile-projections.xml	Sat Sep 12 13:20:21 2020 +0200
+++ b/relpipe-data/examples-guile-projections.xml	Fri Sep 25 14:38:24 2020 +0200
@@ -2,14 +2,14 @@
 	xmlns="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/strana"
 	xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro">
 	
-	<nadpis>Doing projections with Guile</nadpis>
+	<nadpis>Doing projections with Scheme</nadpis>
 	<perex>modifying attribute values and adding new attributes or removing them</perex>
 	<m:pořadí-příkladu>01500</m:pořadí-příkladu>
 
 	<text xmlns="http://www.w3.org/1999/xhtml">
 		
 		<p>
-			The <code>relpipe-tr-guile</code> can not only filter records,
+			The <code>relpipe-tr-scheme</code> can not only filter records,
 			but can also modify them and even modify the structure of the relation – add or remove attributes.
 			
 		</p>
@@ -55,11 +55,11 @@
 		<h2>Modifying attribute values</h2>
 
 		<p>
-			Then, we can modify such relation using Guile – e.g. we can make the <code>name</code> uppercase and increase <code>id</code> by 1000:
+			Then, we can modify such relation using Scheme – e.g. we can make the <code>name</code> uppercase and increase <code>id</code> by 1000:
 		</p>
 		
 		<m:pre jazyk="bash"><![CDATA[sample-data \
-	| relpipe-tr-guile \
+	| relpipe-tr-scheme \
 		--relation n \
 		--for-each '(set! $name (string-upcase $name) ) (set! $id (+ $id 1000) )' \
 	| relpipe-out-tabular]]></m:pre>
@@ -85,7 +85,7 @@
 		</p>
 	
 		<m:pre jazyk="bash"><![CDATA[sample-data \
-	| relpipe-tr-guile \
+	| relpipe-tr-scheme \
 		--relation n \
 		--for-each '(set! $name (string-upcase $name) ) (set! $id (+ $id 1000) )' \
 		--output-attribute 'id' integer \
@@ -112,7 +112,7 @@
 		</p>
 		
 		<m:pre jazyk="bash"><![CDATA[sample-data \
-	| relpipe-tr-guile \
+	| relpipe-tr-scheme \
 		--relation n \
 		--for-each '(define $sum (+ $a $b $c) )' \
 		--output-attribute 'sum' integer \
@@ -144,7 +144,7 @@
 		</p>
 		
 		<m:pre jazyk="bash"><![CDATA[sample-data \
-	| relpipe-tr-guile \
+	| relpipe-tr-scheme \
 		--relation n \
 		--for-each '(define $id (string-upcase $name) )' \
 		--output-attribute 'id' string \
@@ -176,7 +176,7 @@
 		</p>
 		
 		<m:pre jazyk="bash"><![CDATA[sample-data \
-	| relpipe-tr-guile \
+	| relpipe-tr-scheme \
 		--relation n \
 		--for-each '(set! $name (string-upcase $name) ) (set! $id (+ $id 1000) )' \
 		--output-attribute 'id' integer \
--- a/relpipe-data/examples-in-sql-reading-sql.xml	Sat Sep 12 13:20:21 2020 +0200
+++ b/relpipe-data/examples-in-sql-reading-sql.xml	Fri Sep 25 14:38:24 2020 +0200
@@ -44,10 +44,10 @@
 		--relation '.*' --drop \
 	| relpipe-out-tabular
 
-# Guile transformation:
+# Scheme transformation:
 cat relpipe-in-sql-1.sql \
 	| relpipe-in-sql \
-	| relpipe-tr-guile \
+	| relpipe-tr-scheme \
 		--relation 'a' --where '(string= $message "Hello,")' \
 		--relation '.*' --drop \
 	| relpipe-out-tabular]]></m:pre>
@@ -68,7 +68,7 @@
 	<p>
 		Actually, the <code>relpipe-in-sql</code> is just a symbolic link to the <code>relpipe-tr-sql</code> 
 		and have the same capabilities (with just bit different default behavior to match general logic of the input filters).
-		So if we do not need special feautres of Guile, AWK or other transformation tool, it is better to stay with SQL (when we already use the SQL module).
+		So if we do not need special feautres of Scheme, AWK or other transformation tool, it is better to stay with SQL (when we already use the SQL module).
 	</p>
 	
 	<p>
--- a/relpipe-data/examples-parallel-hashes.xml	Sat Sep 12 13:20:21 2020 +0200
+++ b/relpipe-data/examples-parallel-hashes.xml	Fri Sep 25 14:38:24 2020 +0200
@@ -56,7 +56,7 @@
 			<li>
 				<code>aggregate</code>
 				– uses SQL to order the records and SQL window function to show, how many files have the same content;
-				in this step we could use also <code>relpipe-tr-awk</code> or <code>relpipe-tr-guile</code> if we prefer AWK or Guile/Scheme to SQL
+				in this step we could use also <code>relpipe-tr-awk</code> or <code>relpipe-tr-scheme</code> if we prefer AWK or Scheme to SQL
 			</li>
 			<li>
 				<code>relpipe-out-tabular</code>
--- a/relpipe-data/examples-runnable-jars.xml	Sat Sep 12 13:20:21 2020 +0200
+++ b/relpipe-data/examples-runnable-jars.xml	Fri Sep 25 14:38:24 2020 +0200
@@ -43,7 +43,7 @@
 			<li>
 				<code>filterRunable</code>
 				– uses AWK to skip the records (files) that does not have a main class;
-				in this step we could use also <code>relpipe-tr-sql</code> or <code>relpipe-tr-guile</code> if we prefer SQL or Guile/Scheme to AWK
+				in this step we could use also <code>relpipe-tr-sql</code> or <code>relpipe-tr-scheme</code> if we prefer SQL or Scheme to AWK
 			</li>
 			<li>
 				<code>shortenPath</code>
--- a/relpipe-data/examples/awk-through-xml.sh	Sat Sep 12 13:20:21 2020 +0200
+++ b/relpipe-data/examples/awk-through-xml.sh	Fri Sep 25 14:38:24 2020 +0200
@@ -41,8 +41,8 @@
 	#		"SELECT * FROM policy WHERE policy = 'allow' AND user <> 'root'"
 	#	--copy 'limit'
 
-	# Or using Guile (Scheme):
-	# relpipe-tr-guile \
+	# Or using Scheme:
+	# relpipe-tr-scheme \
 	#	--relation policy \
 	#	--where '(and (string= $policy "allow") (not (string= $user "root")) )'
 }
--- a/relpipe-data/examples/guile-file-count-size-sum.sh	Sat Sep 12 13:20:21 2020 +0200
+++ b/relpipe-data/examples/guile-file-count-size-sum.sh	Fri Sep 25 14:38:24 2020 +0200
@@ -7,7 +7,7 @@
 	| relpipe-in-filesystem \
 		--file path \
 		--file size \
-	| relpipe-tr-guile \
+	| relpipe-tr-scheme \
 		--relation 'f.*' \
 		--output-attribute 'count' integer \
 		--output-attribute 'sum'   integer \
--- a/relpipe-data/implementation.xml	Sat Sep 12 13:20:21 2020 +0200
+++ b/relpipe-data/implementation.xml	Fri Sep 25 14:38:24 2020 +0200
@@ -38,7 +38,7 @@
 			relpipe-tr-awk.cpp	executable	transformation	c++	GNU GPLv3
 			relpipe-tr-cut.cpp	executable	transformation	c++	GNU GPLv3
 			relpipe-tr-grep.cpp	executable	transformation	c++	GNU GPLv3
-			relpipe-tr-guile.cpp	executable	transformation	c++	GNU GPLv3
+			relpipe-tr-scheme.cpp	executable	transformation	c++	GNU GPLv3
 			relpipe-tr-python.cpp	executable	transformation	c++	GNU GPLv3
 			relpipe-tr-sed.cpp	executable	transformation	c++	GNU GPLv3
 			relpipe-tr-sql.cpp	executable	transformation	c++	GNU GPLv3
--- a/relpipe-data/index.xml	Sat Sep 12 13:20:21 2020 +0200
+++ b/relpipe-data/index.xml	Fri Sep 25 14:38:24 2020 +0200
@@ -148,7 +148,7 @@
 			<li>Terminal emulator – same as with shells, we use existing terminals and we can use <m:name/> also outside any terminal; if we interact with the terminal, we use standard means like Unicode, ANSI escape sequences etc.</li>
 			<li>IDE – we can use standard <m:unix/> tools as an IDE (GNU Screen, Emacs, Make etc.) or any other IDE.</li>
 			<li>Programming language – <m:name/> are language-independent data format and can be produced or consumed in any programming language.</li>
-			<li>Query language – although some of our tools are doing queries, filtering or transformations, we are not inventing a new query language – instead, we use existing languages like SQL, XPath, Guile/Scheme, AWK or regular expressions.</li>
+			<li>Query language – although some of our tools are doing queries, filtering or transformations, we are not inventing a new query language – instead, we use existing languages like SQL, XPath, Scheme, AWK or regular expressions.</li>
 			<!--<li>Text editor – </li>-->
 			<li>Database system, DBMS – we focus on the stream processing rather than data storage. Although sometimes it makes sense to redirect data to a file and continue with the processing later.</li>
 		</ul>