# New Ticket Created by Andreas Rottmann # Please include the string: [perl #52774] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=52774 >
The attached patch fixes the pair implementation.
Make pairs work From: Andreas Rottmann <[EMAIL PROTECTED]> --- languages/eclectus/compiler.scm | 16 +++++++--------- languages/eclectus/t/pair.t | 6 +++--- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/languages/eclectus/compiler.scm b/languages/eclectus/compiler.scm index fbb7295..6d5843b 100644 --- a/languages/eclectus/compiler.scm +++ b/languages/eclectus/compiler.scm @@ -267,13 +267,10 @@ ; implementation of cons (define-primitive (cons arg1 arg2) - (past::var '(@ (viviself "EclectusPair") - (name "%dummy") - (isdecl 1) - (scope "lexical")) - (past::op '(@ (name "infix:,")) - (emit-expr arg1) - (emit-expr arg2)))) + (past::op '(@ (pasttype "inline") + (inline "new %r, 'EclectusPair'\\nset %r[%0], %1\\n")) + (emit-expr arg1) + (emit-expr arg2))) ; implementation of car (define-primitive (car arg) @@ -283,8 +280,9 @@ ; implementation of cdr (define-primitive (cdr arg) - (past::val '(@ (value 31) - (returns "EclectusFixnum")))) + (past::op '(@ (pasttype "inline") + (inline "%r = %0.'value'()\\n")) + (emit-expr arg))) (define emit-comparison (lambda (builtin arg1 arg2) diff --git a/languages/eclectus/t/pair.t b/languages/eclectus/t/pair.t index e977546..713eadc 100644 --- a/languages/eclectus/t/pair.t +++ b/languages/eclectus/t/pair.t @@ -7,9 +7,9 @@ ((pair? #\A) => "#f\n") ((pair? (fx+ 1 2)) => "#f\n") ((pair? (pair? (fx+ 1 2))) => "#f\n") - ((pair? (cons 30 31)) => "#t\n") - ; ((car (cons 30 31)) => "30\n") - ; ((cdr (cons 30 31)) => "31\n") + ((pair? (cons 41 42)) => "#t\n") + ((car (cons 41 42)) => "41\n") + ((cdr (cons 41 42)) => "42\n") ) (load "compiler.scm")
Regards, Rotty -- Andreas Rottmann | [EMAIL PROTECTED] | [EMAIL PROTECTED] | [EMAIL PROTECTED] http://rotty.uttx.net | GnuPG Key: http://rotty.uttx.net/gpg.asc Fingerprint | C38A 39C5 16D7 B69F 33A3 6993 22C8 27F7 35A9 92E7 v2sw7MYChw5pr5OFma7u7Lw2m5g/l7Di6e6t5BSb7en6g3/5HZa2Xs6MSr1/2p7 hackerkey.com Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald E. Knuth