From f62e6a8e33451dbfe8097131a261ff10d9c3dc28 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Fri, 28 Nov 2014 02:27:03 -0500 Subject: [PATCH 1/8] Arity test case using f:make-ref In place of manual specification. --- test/apply/arity-test.xsl | 32 ++++++++++++++++++++++++++++++++ test/apply/arity.xspec | 14 ++++++++------ 2 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 test/apply/arity-test.xsl diff --git a/test/apply/arity-test.xsl b/test/apply/arity-test.xsl new file mode 100644 index 0000000..0993c3f --- /dev/null +++ b/test/apply/arity-test.xsl @@ -0,0 +1,32 @@ + + + + + + + + diff --git a/test/apply/arity.xspec b/test/apply/arity.xspec index bb94b01..1fe892f 100644 --- a/test/apply/arity.xspec +++ b/test/apply/arity.xspec @@ -25,7 +25,11 @@ xmlns:x="http://www.jenitennison.com/xslt/xspec" xmlns:f="http://www.lovullo.com/hoxsl/apply" xmlns:foo="http://www.lovullo.com/_junk" - stylesheet="../../src/apply/arity.xsl"> + stylesheet="arity-test.xsl"> + + @@ -35,11 +39,9 @@ - - - - - + Date: Sat, 29 Nov 2014 01:16:59 -0500 Subject: [PATCH 2/8] `f:arity' now considers partial applications --- src/apply/arity.xsl | 29 +++++++++++++++++----------- src/apply/partial.xsl | 15 +++++++++------ test/apply/arity.xspec | 43 +++++++++++++++++++++++++++--------------- 3 files changed, 55 insertions(+), 32 deletions(-) diff --git a/src/apply/arity.xsl b/src/apply/arity.xsl index 5e9de23..ad24032 100644 --- a/src/apply/arity.xsl +++ b/src/apply/arity.xsl @@ -28,21 +28,28 @@ - - + + - + + + + + 0" /> + + diff --git a/src/apply/partial.xsl b/src/apply/partial.xsl index 2208a95..3953377 100644 --- a/src/apply/partial.xsl +++ b/src/apply/partial.xsl @@ -71,12 +71,15 @@ - - - + + + @@ -87,7 +90,7 @@ select="$ref"> - + @@ -96,7 +99,7 @@ + select="count( $argout )" /> diff --git a/test/apply/arity.xspec b/test/apply/arity.xspec index 1fe892f..a09198f 100644 --- a/test/apply/arity.xspec +++ b/test/apply/arity.xspec @@ -31,6 +31,13 @@ select="namespace-uri-for-prefix( 'foo', root(.)/element() )" /> + + + + @@ -39,32 +46,38 @@ - - - + + select="$test-arity" /> - - - - - + + select="f:apply( $test-fn, 1, 2 )" /> - + + + + + + + + + + From 5857eed3d6409eefebd026dc6734d8a71ec7b1e5 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Sat, 29 Nov 2014 02:01:40 -0500 Subject: [PATCH 3/8] `arity.xsl' stylesheet combined with ref functions into `ref.xsl' These are strongly related---they operate on the same abstraction. --- src/apply.xsl | 74 ------ src/apply/arity.xsl | 55 ----- src/apply/partial.xsl | 2 +- src/apply/ref.xsl | 150 ++++++++++++ test/apply.xspec | 158 ------------- test/apply/arity.xspec | 83 ------- test/apply/{arity-test.xsl => ref-test.xsl} | 5 +- test/apply/ref.xspec | 244 ++++++++++++++++++++ 8 files changed, 399 insertions(+), 372 deletions(-) delete mode 100644 src/apply/arity.xsl create mode 100644 src/apply/ref.xsl delete mode 100644 test/apply/arity.xspec rename test/apply/{arity-test.xsl => ref-test.xsl} (90%) create mode 100644 test/apply/ref.xspec diff --git a/src/apply.xsl b/src/apply.xsl index fc184c6..b7c4940 100644 --- a/src/apply.xsl +++ b/src/apply.xsl @@ -162,78 +162,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/apply/arity.xsl b/src/apply/arity.xsl deleted file mode 100644 index ad24032..0000000 --- a/src/apply/arity.xsl +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/src/apply/partial.xsl b/src/apply/partial.xsl index 3953377..8a8fcba 100644 --- a/src/apply/partial.xsl +++ b/src/apply/partial.xsl @@ -29,7 +29,7 @@ xmlns:f="http://www.lovullo.com/hoxsl/apply" xmlns:_f="http://www.lovullo.com/hoxsl/apply/_priv"> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/apply.xspec b/test/apply.xspec index 7f6ad61..cbaff69 100644 --- a/test/apply.xspec +++ b/test/apply.xspec @@ -418,162 +418,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/apply/arity.xspec b/test/apply/arity.xspec deleted file mode 100644 index a09198f..0000000 --- a/test/apply/arity.xspec +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/apply/arity-test.xsl b/test/apply/ref-test.xsl similarity index 90% rename from test/apply/arity-test.xsl rename to test/apply/ref-test.xsl index 0993c3f..268b805 100644 --- a/test/apply/arity-test.xsl +++ b/test/apply/ref-test.xsl @@ -1,6 +1,6 @@ + + + diff --git a/test/apply/ref.xspec b/test/apply/ref.xspec new file mode 100644 index 0000000..da2a9df --- /dev/null +++ b/test/apply/ref.xspec @@ -0,0 +1,244 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From bc871435fa67507a207bed5106dcb22e0dd09145 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Sun, 30 Nov 2014 03:28:00 -0500 Subject: [PATCH 4/8] apply-gen now uses `f:make-ref' We're essentailly macro-expanding the `f:make-ref' call. :) --- src/transform/apply-gen.xsl | 20 +++++++----------- test/transform/apply-gen.xspec | 38 ++++++++++++++++++++++++++++------ 2 files changed, 40 insertions(+), 18 deletions(-) diff --git a/src/transform/apply-gen.xsl b/src/transform/apply-gen.xsl index 1591d50..adf5401 100644 --- a/src/transform/apply-gen.xsl +++ b/src/transform/apply-gen.xsl @@ -36,6 +36,8 @@ xmlns:out="http://www.lovullo.com/hoxsl/apply/gen/_out" exclude-result-prefixes="#default fgen"> + + @@ -119,11 +121,10 @@ dependencies and simply specify the full namespace URI --> - + select="namespace-uri-from-QName( $name-resolv )" /> + @@ -164,15 +165,10 @@ - - + - - - - + diff --git a/test/transform/apply-gen.xspec b/test/transform/apply-gen.xspec index 51de570..151731c 100644 --- a/test/transform/apply-gen.xspec +++ b/test/transform/apply-gen.xspec @@ -184,13 +184,39 @@ - - - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + From cd278c31d441acda3c4f91adec0b77d47ab97366 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Sun, 30 Nov 2014 03:29:46 -0500 Subject: [PATCH 5/8] Partial applications now manipulate fnref arity Previously, a separate `@partial' attribute was added to the ref and the `@arity' maintained. Unfortunately, this coupled `f:arity' with `f:partial', which is unnecessary, considering that partial application is supposed to conceptually yield a new function, which should be transparent to `f:arity'. --- src/apply/partial.xsl | 8 ++++---- src/apply/ref.xsl | 10 +++------- test/apply/partial.xspec | 33 ++++++++++++++++++--------------- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/apply/partial.xsl b/src/apply/partial.xsl index 8a8fcba..98700be 100644 --- a/src/apply/partial.xsl +++ b/src/apply/partial.xsl @@ -98,8 +98,9 @@ - + + @@ -128,8 +129,7 @@ + and exists( $fnref[ 2 ] )" /> diff --git a/src/apply/ref.xsl b/src/apply/ref.xsl index 8c6df09..3ea34de 100644 --- a/src/apply/ref.xsl +++ b/src/apply/ref.xsl @@ -135,16 +135,12 @@ + - - - + diff --git a/test/apply/partial.xspec b/test/apply/partial.xspec index eda5a53..33e3743 100644 --- a/test/apply/partial.xspec +++ b/test/apply/partial.xspec @@ -51,11 +51,9 @@ - - - + @@ -68,12 +66,13 @@ - - - + + @@ -108,8 +107,10 @@ - + @@ -406,7 +407,9 @@ + assert on that; we are going to explicitly choose to *not* + support that behavior, since an fnref acquires meaning as an + opaque unit --> @@ -414,8 +417,8 @@ select="f:partial( foo:ternary(), (1, 2) )[ 1 ]" /> - + From 18c1614777e54338eeeff788cb3e1662481393c7 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Sun, 30 Nov 2014 04:34:44 -0500 Subject: [PATCH 6/8] `f:set-args' setter and `f:args' accessor implemented As operations on dynamic function references become more complex, and since evolution of the reference structure is planned to evolve, maintaining an abstraction is vital for both grokking and maintenance. --- src/apply/ref.xsl | 65 ++++++++++++++++- test/apply/ref.xspec | 161 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 220 insertions(+), 6 deletions(-) diff --git a/src/apply/ref.xsl b/src/apply/ref.xsl index 3ea34de..bb94d73 100644 --- a/src/apply/ref.xsl +++ b/src/apply/ref.xsl @@ -104,19 +104,24 @@ - + + + + select="$desc/element()[ 1 ]" /> @@ -143,4 +148,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/apply/ref.xspec b/test/apply/ref.xspec index da2a9df..c3e67b1 100644 --- a/test/apply/ref.xspec +++ b/test/apply/ref.xspec @@ -38,6 +38,14 @@ select="f:make-ref( QName( $foo-uri, 'foo:bar' ), $test-arity )" /> + + + + + + + + @@ -169,10 +177,11 @@ - - + + @@ -186,6 +195,22 @@ + + + + + + + + + + + @@ -241,4 +266,134 @@ select="$test-arity - 3" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From c526fa2925a7f6ce8dd825e1f3b6f254f07f3979 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Mon, 1 Dec 2014 00:34:52 -0500 Subject: [PATCH 7/8] `f:{unshift,push}-args' added --- src/apply/ref.xsl | 32 +++++++++ test/apply/ref.xspec | 151 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 183 insertions(+) diff --git a/src/apply/ref.xsl b/src/apply/ref.xsl index bb94d73..c1a7be4 100644 --- a/src/apply/ref.xsl +++ b/src/apply/ref.xsl @@ -174,6 +174,10 @@ increasing the argument count of @var{fnref} will @emph{decrease} the arity of the resulting reference and vice versa. + @emph{No validations are performed on arity}—if there exist more + arguments than the number of target function parameters, no error + will be raised. + @var{fnref} must be a valid dynamic function reference. --> @@ -202,4 +206,32 @@ + + + + + + + + + + + + + + + + + + diff --git a/test/apply/ref.xspec b/test/apply/ref.xspec index c3e67b1..86d0b2a 100644 --- a/test/apply/ref.xspec +++ b/test/apply/ref.xspec @@ -43,6 +43,7 @@ + @@ -396,4 +397,154 @@ test="count( $x:result ) = 2" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 189eb0cdd6429f46453b1282cc540d2b3654fb8f Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Mon, 1 Dec 2014 01:20:29 -0500 Subject: [PATCH 8/8] Partial applications now defined in terms of ref mutators --- src/apply/partial.xsl | 69 +++++++++++-------------------------- test/apply/partial-test.xsl | 6 ++-- test/apply/partial.xspec | 49 +++++++++++++------------- 3 files changed, 47 insertions(+), 77 deletions(-) diff --git a/src/apply/partial.xsl b/src/apply/partial.xsl index 98700be..e078163 100644 --- a/src/apply/partial.xsl +++ b/src/apply/partial.xsl @@ -55,57 +55,32 @@ - - - - - - - - - - - + select="f:arity( $fnref )" /> - - - - - - - + select="$fnref"> + + - - + - - - - - - - + @@ -149,24 +124,18 @@ match="f:ref" priority="1"> - - + - - @@ -183,14 +152,16 @@ are supported}. This should be enough. --> - - + - + + - + diff --git a/test/apply/partial-test.xsl b/test/apply/partial-test.xsl index 99dfadd..bdb0422 100644 --- a/test/apply/partial-test.xsl +++ b/test/apply/partial-test.xsl @@ -41,8 +41,10 @@