unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* lua branch
@ 2013-03-26  4:56 Ian Price
  2013-03-26  5:50 ` Ian Price
  2013-04-12 14:27 ` Ian Price
  0 siblings, 2 replies; 9+ messages in thread
From: Ian Price @ 2013-03-26  4:56 UTC (permalink / raw)
  To: guile-devel


Prompted by the recent discussion of lua/zile on guile-user, I decided
to checkout what the actual state of the Lua branch is.

First off, not all of the tests pass.
- lua-standard-library and lua-eval pass with no problems.
- lua-lexer has 1 failure, which is easy fixed (change #:vararg
   to #:varargs)
- lua-eval-3 throws an error, and so the test doesn't finish running.
  The issue seems to be that the lua->tree-il conversion does not
  compile the <ast-variable-arguments> record. (Lua's '...').
- lua-eval-2 has a similar issue, but this only results in a failure,
  rather than an error.

The branch does not have any git issues with rebasing it onto a modern
stable-2.0 branch, however it does result in some new test failures,
indicating some reliance on changed behaviours.

I don't know much about Lua, but I think I could do the following.
1. Fix the lua-lexer failure.
2. Disable or fix[1] the variable-arguments functionality.
3. Rebase or merge with modern stable or master
4. Fix the errors that arise as a result of 3.

[1] I _think_ what needs done is just to compile it into a lexical
ref, but with some hacking to make sure that the code gets the right
gensym for the enclosing function's '...'. Right now, there is no way to
get that information.

-- 
Ian Price -- shift-reset.com

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: lua branch
  2013-03-26  4:56 lua branch Ian Price
@ 2013-03-26  5:50 ` Ian Price
  2013-03-26  6:14   ` Nala Ginrut
  2013-03-26 21:52   ` Ludovic Courtès
  2013-04-12 14:27 ` Ian Price
  1 sibling, 2 replies; 9+ messages in thread
From: Ian Price @ 2013-03-26  5:50 UTC (permalink / raw)
  To: guile-devel

[-- Attachment #1: Type: text/plain, Size: 495 bytes --]

Ian Price <ianprice90@googlemail.com> writes:

> I don't know much about Lua, but I think I could do the following.
> 1. Fix the lua-lexer failure.
> 2. Disable or fix[1] the variable-arguments functionality.
> 3. Rebase or merge with modern stable or master
> 4. Fix the errors that arise as a result of 3.

I have patches for 1 & 2.

-- 
Ian Price -- shift-reset.com

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: typo patch --]
[-- Type: text/x-patch, Size: 797 bytes --]

From de139a394dbf4984b6006646a2bd648a1257a01b Mon Sep 17 00:00:00 2001
From: Ian Price <ianprice90@googlemail.com>
Date: Tue, 26 Mar 2013 03:52:40 +0000
Subject: [PATCH 1/2] Fix typo in lua lexer test.

* test-suite/tests/lua-lexer.test ("lua-lexer"): #:vararg -> #:varargs
---
 test-suite/tests/lua-lexer.test |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/test-suite/tests/lua-lexer.test b/test-suite/tests/lua-lexer.test
index 51e9efa..7b916be 100644
--- a/test-suite/tests/lua-lexer.test
+++ b/test-suite/tests/lua-lexer.test
@@ -62,7 +62,7 @@ comment]]"))
     (test "name" 'name)
     (test "return" #:return)
     (test ".." #:concat)
-    (test "..." #:vararg)
+    (test "..." #:varargs)
     (test ";" #\;)
     (test "-" #\-)
     (test "+" #\+)
-- 
1.7.7.6


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: compile patch --]
[-- Type: text/x-patch, Size: 5596 bytes --]

From beb958de895fccd5f81ce2064050ef624a409104 Mon Sep 17 00:00:00 2001
From: Ian Price <ianprice90@googlemail.com>
Date: Tue, 26 Mar 2013 05:41:32 +0000
Subject: [PATCH 2/2] Compile Lua's ... form.

* module/language/lua/compile-tree-il.scm (compile): Add clause for
  ast-variable-arguments.
* module/language/lua/parser.scm (define-ast, make-parser): Add
  vararg-gensym field to functions, gensym field to variable-arguments.
  Propagate *vararg-gensym* from functions to variable-arguments.
* test-suite/tests/lua-eval-2.test ("lua-eval"): Check for #nil
---
 module/language/lua/compile-tree-il.scm |   11 ++++++++---
 module/language/lua/parser.scm          |   15 +++++++++++----
 test-suite/tests/lua-eval-2.test        |    2 +-
 3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/module/language/lua/compile-tree-il.scm b/module/language/lua/compile-tree-il.scm
index 48c1a58..72c0d1b 100644
--- a/module/language/lua/compile-tree-il.scm
+++ b/module/language/lua/compile-tree-il.scm
@@ -156,7 +156,7 @@ dropped silently"
           src (make-primitive-ref src 'return/values)
           (if (list? exp) (map-compile exp #t) (list (compile exp))))))
 
-    ((ast-function src name arguments argument-gensyms variable-arguments? body)
+    ((ast-function src name arguments argument-gensyms variable-arguments? vararg-gensym body)
      ;; ... is always attached because lua functions must ignore
      ;; variable arguments; the parser will catch it if ... is used in a
      ;; function that doesn't have ... in the parameter list
@@ -165,7 +165,7 @@ dropped silently"
         src meta
         (make-lambda-case src '() arguments '... #f
                           (map (lambda (x) (make-const src #nil)) arguments)
-                          (append argument-gensyms (list (gensym "...")))
+                          (append argument-gensyms (list vararg-gensym))
                           (compile body)
                           #f))))
 
@@ -476,7 +476,12 @@ dropped silently"
                 (make-lexical-ref src 'and-tmp tmp)
                 right
                 (make-lexical-ref src 'and-tmp tmp)))))
-         (else (error #:COMPILE "unknown binary operator" operator)))))))
+         (else (error #:COMPILE "unknown binary operator" operator)))))
+    ((ast-variable-arguments src gensym)
+     (make-application src
+                       (make-primitive-ref src 'apply)
+                       (list (make-primitive-ref src 'values)
+                             (make-lexical-ref src '... gensym))))))
 
 ;; exported compiler function
 (define (compile-tree-il exp env opts)
diff --git a/module/language/lua/parser.scm b/module/language/lua/parser.scm
index dbe73f6..2ee81ce 100644
--- a/module/language/lua/parser.scm
+++ b/module/language/lua/parser.scm
@@ -106,10 +106,10 @@
    (numeric-for-loop named initial limit step body)
    (list-for-loop names gs-names exps body)
    (break)
-   (function name arguments argument-gensyms variable-arguments? body)
+   (function name arguments argument-gensyms variable-arguments? vararg-gensym body)
    (function-call operator operands)
    (binary-operation operator left right)
-   (variable-arguments))
+   (variable-arguments gensym))
 
   ) ; letrec-syntax
 
@@ -219,6 +219,9 @@
   ;; True if inside a function and the function accepts variable arguments
   (define *vararg-function* #f)
 
+  ;; refers to the gensym for '...' in a function that accepts variable arguments
+  (define *vararg-gensym* #f)
+
   ;;;;; ENVIRONMENTS
   (define (enter-environment!)
     "Create a new environment, and set ENVIRONMENT to it"
@@ -482,8 +485,10 @@
     (enforce-next! #\()
     ;; parameter-list
     (receive (parameters variable-arguments?) (parameter-list name)
-      (let* ((old-vararg-function *vararg-function*))
+      (let* ((old-vararg-function *vararg-function*)
+             (old-vararg-gensym *vararg-gensym*))
         (set! *vararg-function* variable-arguments?)
+        (set! *vararg-gensym* (and variable-arguments? (gensym "...")))
         (enforce-next! #\))
         ;; create function
         (enter-environment!)
@@ -504,11 +509,13 @@
                              (list (environment-lookup-gensym 'self)))
                      parameter-gensyms)
                  variable-arguments?
+                 *vararg-gensym*
                  (if (null? body) *void-literal* body))))
           (leave-environment!)
           ;; END
           (enforce-next! #:end)
           (set! *vararg-function* old-vararg-function)
+          (set! *vararg-gensym* old-vararg-gensym)
           result))))
 
   ;; expression-list -> expression { ',' expression }
@@ -535,7 +542,7 @@
         ((#:varargs)
          (unless *vararg-function*
            (syntax-error src "cannot use '...' outside of a variable arguments function"))
-         (advance! (make-ast-variable-arguments src)))
+         (advance! (make-ast-variable-arguments src *vararg-gensym*)))
         ;; FUNCTION function-body
         ((#:function) (advance!) (function-body src))
         ;; primary-expression
diff --git a/test-suite/tests/lua-eval-2.test b/test-suite/tests/lua-eval-2.test
index 0787a3f..e07e827 100644
--- a/test-suite/tests/lua-eval-2.test
+++ b/test-suite/tests/lua-eval-2.test
@@ -99,7 +99,7 @@
     (test "print \"hello world\"; return true")
 
     ;; variable arguments
-    (test "function test(...) print(...) end test(1,2)")
+    (test "function test(...) print(...) end return test(1,2)" #nil)
 
     ;; numeric for loop
     (test "for x = 1,2,1 do print(true) end return true")
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: lua branch
  2013-03-26  5:50 ` Ian Price
@ 2013-03-26  6:14   ` Nala Ginrut
  2013-03-26  6:28     ` Ian Price
  2013-03-26 21:52   ` Ludovic Courtès
  1 sibling, 1 reply; 9+ messages in thread
From: Nala Ginrut @ 2013-03-26  6:14 UTC (permalink / raw)
  To: Ian Price; +Cc: guile-devel

hi ijp!
Here're some rough thoughts about the patch:

On Tue, 2013-03-26 at 05:50 +0000, Ian Price wrote:
> Ian Price <ianprice90@googlemail.com> writes:
> 
> > I don't know much about Lua, but I think I could do the following.
> > 1. Fix the lua-lexer failure.
> > 2. Disable or fix[1] the variable-arguments functionality.
> > 3. Rebase or merge with modern stable or master
> > 4. Fix the errors that arise as a result of 3.
> 
> I have patches for 1 & 2.
> 


+      (let* ((old-vararg-function *vararg-function*)
+             (old-vararg-gensym *vararg-gensym*))

Is 'let' better here?

------------------------

+  ;; refers to the gensym for '...' in a function that accepts variable
arguments
+  (define *vararg-gensym* #f)
+

I know it's consistent with the old code, but maybe parameterize is
suggested? 

------------------------


Besides, as we talked in IRC, LALR/PEG is better than this manual
parser. But I think this lua implementation could work after some
patches, so I'm not sure if it's necessary to rewrite it with LALR/PEG.
What do you think? 





^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: lua branch
  2013-03-26  6:14   ` Nala Ginrut
@ 2013-03-26  6:28     ` Ian Price
  0 siblings, 0 replies; 9+ messages in thread
From: Ian Price @ 2013-03-26  6:28 UTC (permalink / raw)
  To: Nala Ginrut; +Cc: guile-devel

Nala Ginrut <nalaginrut@gmail.com> writes:
> +      (let* ((old-vararg-function *vararg-function*)
> +             (old-vararg-gensym *vararg-gensym*))
>
> Is 'let' better here?

Actually, I didn't notice that it was a let*. It's arguably a little
more confusing, but not really harmful.

> +  ;; refers to the gensym for '...' in a function that accepts variable
> arguments
> +  (define *vararg-gensym* #f)
> +
>
> I know it's consistent with the old code, but maybe parameterize is
> suggested? 

Yeah, fluid-let or parameterize is a lot better to my mind, but this way
was less invasive.

> Besides, as we talked in IRC, LALR/PEG is better than this manual
> parser. But I think this lua implementation could work after some
> patches, so I'm not sure if it's necessary to rewrite it with LALR/PEG.
> What do you think? 

It's not necessary, and I don't have any intention of ripping out the
parser and writing a new one.  If someone else wrote one though, I think
we should consider it.

-- 
Ian Price -- shift-reset.com

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: lua branch
  2013-03-26  5:50 ` Ian Price
  2013-03-26  6:14   ` Nala Ginrut
@ 2013-03-26 21:52   ` Ludovic Courtès
  1 sibling, 0 replies; 9+ messages in thread
From: Ludovic Courtès @ 2013-03-26 21:52 UTC (permalink / raw)
  To: guile-devel

Ian Price <ianprice90@googlemail.com> skribis:

> Ian Price <ianprice90@googlemail.com> writes:
>
>> I don't know much about Lua, but I think I could do the following.
>> 1. Fix the lua-lexer failure.
>> 2. Disable or fix[1] the variable-arguments functionality.
>> 3. Rebase or merge with modern stable or master
>> 4. Fix the errors that arise as a result of 3.
>
> I have patches for 1 & 2.

Nice.  These are simple enough, and an improvement, so feel free to push.

Ludo’.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: lua branch
  2013-03-26  4:56 lua branch Ian Price
  2013-03-26  5:50 ` Ian Price
@ 2013-04-12 14:27 ` Ian Price
  2013-04-17 23:09   ` Ian Price
  1 sibling, 1 reply; 9+ messages in thread
From: Ian Price @ 2013-04-12 14:27 UTC (permalink / raw)
  To: guile-devel

Ian Price <ianprice90@googlemail.com> writes:

> I don't know much about Lua, but I think I could do the following.
> 1. Fix the lua-lexer failure.
> 2. Disable or fix[1] the variable-arguments functionality.
> 3. Rebase or merge with modern stable or master
> 4. Fix the errors that arise as a result of 3.
The current issues with lua vs master are as follows
1) <application> has been renamed to <call> on master
2) <sequence> has been replaced with <seq> which is not quite a drop-in
3) while was being compiled into something with improper scoping.

I have fixes for these locally. There is just the question of rebase vs
merge for bringing the branch up to date. Any preference there?

-- 
Ian Price -- shift-reset.com

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: lua branch
  2013-04-12 14:27 ` Ian Price
@ 2013-04-17 23:09   ` Ian Price
  2013-05-21 20:42     ` Phil
  0 siblings, 1 reply; 9+ messages in thread
From: Ian Price @ 2013-04-17 23:09 UTC (permalink / raw)
  To: guile-devel

[-- Attachment #1: Type: text/plain, Size: 693 bytes --]

Ian Price <ianprice90@googlemail.com> writes:

> The current issues with lua vs master are as follows
> 1) <application> has been renamed to <call> on master
> 2) <sequence> has been replaced with <seq> which is not quite a drop-in
> 3) while was being compiled into something with improper scoping.
>
> I have fixes for these locally. There is just the question of rebase vs
> merge for bringing the branch up to date. Any preference there?

Sorry, got distracted.
Is it okay to merge master into lua, and push these three patches?

-- 
Ian Price -- shift-reset.com

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Fix <application> --]
[-- Type: text/x-patch, Size: 12164 bytes --]

From 80887b0913479c980e31534d16d0a872d437e18e Mon Sep 17 00:00:00 2001
From: Ian Price <ianprice90@googlemail.com>
Date: Wed, 17 Apr 2013 23:53:31 +0100
Subject: [PATCH 1/3] Use `make-application' instead of removed `make-call'.

* module/language/lua/compile-tree-il.scm: Rename.
---
 module/language/lua/compile-tree-il.scm |  102 +++++++++++++++---------------
 1 files changed, 51 insertions(+), 51 deletions(-)

diff --git a/module/language/lua/compile-tree-il.scm b/module/language/lua/compile-tree-il.scm
index 72c0d1b..e81e929 100644
--- a/module/language/lua/compile-tree-il.scm
+++ b/module/language/lua/compile-tree-il.scm
@@ -41,7 +41,7 @@
 
 (define (make-runtime-application src name arguments)
   "Shorthand for creating an application of a function in the (language lua runtime) module"
-  (make-application src (ref-runtime src name) arguments))
+  (make-call src (ref-runtime src name) arguments))
 
 (define (make-table-ref src table index)
   "Shorthand for calling the index function in (language lua runtime)"
@@ -79,7 +79,7 @@
 (define (apply-named-lua-function src name get-body)
   (let* ((name (gensym (string-append " " name)))
          (parameters (list name)))
-    (make-application
+    (make-call
      src
      (make-module-ref src '(guile) 'catch #t)
      (list
@@ -89,7 +89,7 @@
          src
          parameters parameters
          (list (make-lambda src '() (get-body name)))
-         (make-application src (make-lexical-ref src name name) '())))
+         (make-call src (make-lexical-ref src name name) '())))
       (make-arg-ignoring-lambda src
        (make-void src))))))
 
@@ -104,7 +104,7 @@
       (make-sequence
        src
        (list body
-             (make-application src (make-lexical-ref src loop loop) '())))
+             (make-call src (make-lexical-ref src loop loop) '())))
       (make-void src)))))
 
 (define (could-result-in-multiple-values? x)
@@ -149,10 +149,10 @@ dropped silently"
     ((ast-return src exp)
      (if tail?
          (if (and (list? exp) (not (= (length exp) 1)))
-             (make-application src (make-primitive-ref src 'values)
+             (make-call src (make-primitive-ref src 'values)
                                (map-compile exp))
              (compile (if (list? exp) (car exp) exp) #t))
-         (make-application
+         (make-call
           src (make-primitive-ref src 'return/values)
           (if (list? exp) (map-compile exp #t) (list (compile exp))))))
 
@@ -183,23 +183,23 @@ dropped silently"
              ;; and a function that takes variable arguments. Then
              ;; append those variable arguments to the rest of the
              ;; expression, and apply the first function to it)
-             (make-application src
+             (make-call src
                (make-primitive-ref src 'call-with-values)
                (list
                  (make-argless-lambda src (make-sequence src (last-pair args)))
                  (let ((rest-gensym (gensym "rest")))
                    (make-catch-all-lambda src
-                     (make-application src (make-primitive-ref src 'apply)
+                     (make-call src (make-primitive-ref src 'apply)
                        (list
                          proc
-                         (make-application src
+                         (make-call src
                            (make-module-ref src '(srfi srfi-1) 'append! #t)
                            (list
-                             (make-application src (make-primitive-ref src 'list) (drop-right args 1))
+                             (make-call src (make-primitive-ref src 'list) (drop-right args 1))
                              (make-lexical-ref src 'rest rest-gensym)))))
                        rest-gensym))))
 
-             (make-application src proc args)))
+             (make-call src proc args)))
 
        ;; If this is function is a global variable, prepend a call to
        ;; check-global-function to make sure it's defined before
@@ -208,7 +208,7 @@ dropped silently"
            (make-sequence
             src (list
                  ;; FIXME: use module binders instead
-                 (make-application
+                 (make-call
                   src (make-module-ref src '(language lua runtime)
                                        'check-global-function #t)
                   (list (make-const src (ast-global-ref-name operator))
@@ -252,7 +252,7 @@ dropped silently"
      (unless (memq (context) '(while-loop list-for-loop numeric-for-loop))
        (syntax-error src "no loop to break"))
      ;; FIXME: use abort instead of throw
-     (make-application src (make-module-ref src '(guile) 'throw #t)
+     (make-call src (make-module-ref src '(guile) 'throw #t)
                        (list (make-const src 'lua-break))))
 
     ;; FIXME: use prompt and abort instead of throw and catch
@@ -278,32 +278,32 @@ dropped silently"
                    (begin
                      ;; even more complicated, assigning the values to
                      ;; the loop variables
-                     (apply (primitive call-with-values)
-                            (lambda ()
-                              (lambda-case
-                               (,no-arguments
-                                (apply (lexical iterator ,gs-iterator)
-                                       (lexical state ,gs-state)
-                                       (lexical variable ,gs-variable)))))
-                            (lambda ()
-                              (lambda-case
-                               ((,names #f #f #f () ,gs-names)
-                                ;; almost to the actual loop body, hang
-                                ;; in there
-                                (begin
-                                  (set! (lexical variable ,gs-variable)
-                                        (lexical ,(car names) ,(car gs-names)))
-                                  (if (apply (primitive eq?)
-                                             (lexical variable ,gs-variable)
-                                             (const #nil))
-                                      (apply (@ (guile) throw) (const lua-break))
-                                      (void))
-                                  ,(parameterize ((context 'list-for-loop))
-                                     (unparse-tree-il (compile body)))
-                                  (apply (lexical loop ,gs-loop))))))))))))
+                     (call (primitive call-with-values)
+                           (lambda ()
+                             (lambda-case
+                              (,no-arguments
+                               (call (lexical iterator ,gs-iterator)
+                                     (lexical state ,gs-state)
+                                     (lexical variable ,gs-variable)))))
+                           (lambda ()
+                             (lambda-case
+                              ((,names #f #f #f () ,gs-names)
+                               ;; almost to the actual loop body, hang
+                               ;; in there
+                               (begin
+                                 (set! (lexical variable ,gs-variable)
+                                       (lexical ,(car names) ,(car gs-names)))
+                                 (if (call (primitive eq?)
+                                           (lexical variable ,gs-variable)
+                                           (const #nil))
+                                     (call (@ (guile) throw) (const lua-break))
+                                     (void))
+                                 ,(parameterize ((context 'list-for-loop))
+                                    (unparse-tree-il (compile body)))
+                                 (call (lexical loop ,gs-loop))))))))))))
            ;; initialize variables and start loop
            (begin
-             (apply (primitive call-with-values)
+             (call (primitive call-with-values)
                     (lambda ()
                       (lambda-case
                        (,no-arguments
@@ -320,12 +320,12 @@ dropped silently"
                                 (lexical state ,gs-state2))
                           (set! (lexical variable ,gs-variable)
                                 (lexical variable ,gs-variable2)))))))
-             (apply (@ (guile) catch)
+             (call (@ (guile) catch)
                     (const lua-break)
                     (lambda ()
                       (lambda-case
                        (,no-arguments
-                        (apply (lexical loop ,gs-loop)))))
+                        (call (lexical loop ,gs-loop)))))
                     (lambda ()
                       (lambda-case
                        (((key) #f #f #f () (,(gensym "key")))
@@ -348,11 +348,11 @@ dropped silently"
             (gs-step (gensym "step"))
             (gs-loop (gensym "loop"))
             (while-condition
-             `(if (apply (primitive >) (lexical step ,gs-step) (const 0))
-                 (if (apply (primitive <=)
+             `(if (call (primitive >) (lexical step ,gs-step) (const 0))
+                 (if (call (primitive <=)
                             (lexical variable ,gs-variable)
                             (lexical limit ,gs-limit))
-                     (apply (lexical loop ,gs-loop))
+                     (call (lexical loop ,gs-loop))
                      (void))
                  (void))))
        (parse-tree-il
@@ -366,8 +366,8 @@ dropped silently"
               '(const #f)
               (append
                (map (lambda (x)
-                      `(apply (@ (language lua runtime) tonumber)
-                              ,(unparse-tree-il (compile x))))
+                      `(call (@ (language lua runtime) tonumber)
+                             ,(unparse-tree-il (compile x))))
                     (list initial limit step))
                ;; loop body
                (list
@@ -382,14 +382,14 @@ dropped silently"
                        ,(parameterize ((context 'numeric-for-loop))
                           (unparse-tree-il (compile body)))
                        (set! (lexical variable ,gs-variable)
-                             (apply (primitive +)
-                                    (lexical variable ,gs-variable)
-                                    (lexical step ,gs-step)))
+                             (call (primitive +)
+                                   (lexical variable ,gs-variable)
+                                   (lexical step ,gs-step)))
                        ,while-condition)))))))
            ;; body
            (begin
              ;; if not (var and limit and step) then error() end
-             (if (apply (primitive not)
+             (if (call (primitive not)
                         (if (lexical variable ,gs-variable)
                             (if (lexical limit ,gs-limit)
                                 (if (lexical step ,gs-step)
@@ -397,7 +397,7 @@ dropped silently"
                                     (const #f))
                                 (const #f))
                             (const #f)))
-                 (apply (@ (guile) error))
+                 (call (@ (guile) error))
                  (void))
              ,while-condition
              )))))
@@ -437,7 +437,7 @@ dropped silently"
      (if (and (eq? operator #\-) (ast-literal? right)
               (number? (ast-literal-exp right)))
          (make-const src (- (ast-literal-exp right)))
-         (make-application
+         (make-call
           src
           (case operator
             ((#\-) (ref-runtime src 'unm))
@@ -478,7 +478,7 @@ dropped silently"
                 (make-lexical-ref src 'and-tmp tmp)))))
          (else (error #:COMPILE "unknown binary operator" operator)))))
     ((ast-variable-arguments src gensym)
-     (make-application src
+     (make-call src
                        (make-primitive-ref src 'apply)
                        (list (make-primitive-ref src 'values)
                              (make-lexical-ref src '... gensym))))))
-- 
1.7.7.6


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: Fix <sequence> --]
[-- Type: text/x-patch, Size: 1109 bytes --]

From a8a3a1cdc67fa7bf3be6435500cd4a1fe77be8a8 Mon Sep 17 00:00:00 2001
From: Ian Price <ianprice90@googlemail.com>
Date: Wed, 17 Apr 2013 23:58:09 +0100
Subject: [PATCH 2/3] Add missing `make-sequence' procedure.

* module/language/lua/compile-tree-il.scm (make-sequence): New procedure.
---
 module/language/lua/compile-tree-il.scm |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/module/language/lua/compile-tree-il.scm b/module/language/lua/compile-tree-il.scm
index e81e929..e0ecfa3 100644
--- a/module/language/lua/compile-tree-il.scm
+++ b/module/language/lua/compile-tree-il.scm
@@ -53,6 +53,11 @@
   (make-runtime-application src 'new-index!
     (list table (if (symbol? index) (make-const src (symbol->string index)) index) exp)))
 
+(define (make-sequence src body)
+  (if (null? (cdr body))
+      (car body)
+      (make-seq src (car body) (make-sequence #f (cdr body)))))
+
 ;; Calling conventions
 (define* (make-plain-lambda-case src args gensyms body #:optional alternate)
   (make-lambda-case src args #f #f #f '() (or gensyms args) body alternate))
-- 
1.7.7.6


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: Fix while --]
[-- Type: text/x-patch, Size: 1120 bytes --]

From e964c5acf2f54871d6ce06a627f48e0b8331b5c0 Mon Sep 17 00:00:00 2001
From: Ian Price <ianprice90@googlemail.com>
Date: Thu, 18 Apr 2013 00:03:34 +0100
Subject: [PATCH 3/3] Fix code generated for `while'.

* module/language/lua/compile-tree-il.scm (while-loop->tree-il):
  Generate `letrec' instead of `let'.
  Generate valid `lambda' expression.
---
 module/language/lua/compile-tree-il.scm |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/module/language/lua/compile-tree-il.scm b/module/language/lua/compile-tree-il.scm
index e0ecfa3..4472b05 100644
--- a/module/language/lua/compile-tree-il.scm
+++ b/module/language/lua/compile-tree-il.scm
@@ -90,10 +90,10 @@
      (list
       (make-const src 'lua-break)
       (make-argless-lambda src
-        (make-let
+        (make-letrec #f
          src
          parameters parameters
-         (list (make-lambda src '() (get-body name)))
+         (list (make-argless-lambda src (get-body name)))
          (make-call src (make-lexical-ref src name name) '())))
       (make-arg-ignoring-lambda src
        (make-void src))))))
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: lua branch
  2013-04-17 23:09   ` Ian Price
@ 2013-05-21 20:42     ` Phil
  2013-05-21 21:25       ` Phil
  0 siblings, 1 reply; 9+ messages in thread
From: Phil @ 2013-05-21 20:42 UTC (permalink / raw)
  To: Ian Price; +Cc: guile-devel

Hey guys,

I was just thinking about Guile Lua (and feeling guilty that I never
did finish it). Anyway, I never did make any progress after my 2012
posts. I got a little discouraged while implementing Lua's multiple
values everywhere, to be honest.

By all means, feel free to take over the lua branch. As long as it's
okay with Ludo, Andy, whoever is in charge these days, I think you
should push to it with reckless abandon instead of submitting patches
since it isn't used in guile (yet).

On Wed, Apr 17, 2013 at 6:09 PM, Ian Price <ianprice90@googlemail.com> wrote:
> Ian Price <ianprice90@googlemail.com> writes:
>
>> The current issues with lua vs master are as follows
>> 1) <application> has been renamed to <call> on master
>> 2) <sequence> has been replaced with <seq> which is not quite a drop-in
>> 3) while was being compiled into something with improper scoping.
>>
>> I have fixes for these locally. There is just the question of rebase vs
>> merge for bringing the branch up to date. Any preference there?
>
> Sorry, got distracted.
> Is it okay to merge master into lua, and push these three patches?
>
> --
> Ian Price -- shift-reset.com
>
> "Programming is like pinball. The reward for doing it well is
> the opportunity to do it again" - from "The Wizardy Compiled"
>



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: lua branch
  2013-05-21 20:42     ` Phil
@ 2013-05-21 21:25       ` Phil
  0 siblings, 0 replies; 9+ messages in thread
From: Phil @ 2013-05-21 21:25 UTC (permalink / raw)
  To: Ian Price; +Cc: guile-devel

[-- Attachment #1: Type: text/plain, Size: 2942 bytes --]

It's been so long since I worked on it, I hardly remember what was left. I
think module/language/lua/notes.org covers most of it.

The main tasks would be:
- Standard library compliance (the existing modules are missing some
functions, and there is no debug/coroutine module)
- module function
- Multiple values and variable arguments. Lua expressions can return
multiple values. Lua assignments can involve multiple values in confusing
ways. (This is very easy for the Lua runtime to handle, but as I recall
bolting it onto tree-il was frustrating me quite a bit).
- Fix the REPL. Scheme is all about expressions, Lua is all about
statements. Somehow, despite writing a Lua implementation, I never realized
that you evaluate Lua expressions in the REPL by typing "return true" or "=
true" for short. Typing a normal expression, such as "true", is an error.
And I don't know whether you can convince the Guile REPL to play nice with
that worldview.
- I was personally planning to pretty much rewrite parser.scm and
compile-tree-il.scm as I wasn't happy with the length or complexity of
them. I would think the parser could be rewritten using a parser generator,
and the code generator could be simplified quite a bit (look at ecmascript).
- Performance improvements. Never did get around to benchmarking it.
- Import the Lua language test suite and ensure compliance
http://www.lua.org/tests

- Consider implementing Lua 5.2. They added a bitwise manipulation library
and simplified the module system quite a bit.

On Tue, May 21, 2013 at 3:42 PM, Phil <theseaisinhere@gmail.com> wrote:

> Hey guys,
>
> I was just thinking about Guile Lua (and feeling guilty that I never
> did finish it). Anyway, I never did make any progress after my 2012
> posts. I got a little discouraged while implementing Lua's multiple
> values everywhere, to be honest.
>
> By all means, feel free to take over the lua branch. As long as it's
> okay with Ludo, Andy, whoever is in charge these days, I think you
> should push to it with reckless abandon instead of submitting patches
> since it isn't used in guile (yet).
>
> On Wed, Apr 17, 2013 at 6:09 PM, Ian Price <ianprice90@googlemail.com>
> wrote:
> > Ian Price <ianprice90@googlemail.com> writes:
> >
> >> The current issues with lua vs master are as follows
> >> 1) <application> has been renamed to <call> on master
> >> 2) <sequence> has been replaced with <seq> which is not quite a drop-in
> >> 3) while was being compiled into something with improper scoping.
> >>
> >> I have fixes for these locally. There is just the question of rebase vs
> >> merge for bringing the branch up to date. Any preference there?
> >
> > Sorry, got distracted.
> > Is it okay to merge master into lua, and push these three patches?
> >
> > --
> > Ian Price -- shift-reset.com
> >
> > "Programming is like pinball. The reward for doing it well is
> > the opportunity to do it again" - from "The Wizardy Compiled"
> >
>

[-- Attachment #2: Type: text/html, Size: 4000 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-05-21 21:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-26  4:56 lua branch Ian Price
2013-03-26  5:50 ` Ian Price
2013-03-26  6:14   ` Nala Ginrut
2013-03-26  6:28     ` Ian Price
2013-03-26 21:52   ` Ludovic Courtès
2013-04-12 14:27 ` Ian Price
2013-04-17 23:09   ` Ian Price
2013-05-21 20:42     ` Phil
2013-05-21 21:25       ` Phil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).