From: Kamen TOMOV
Subject: issue with operator precedence in Parenscript
Date:
Message-ID: <ud50jyj8z.fsf@evrocom.net>
Hi,
There is an issue with the operator precedence in Parenscript. The
expression:
(.foo
(if (setf vrbl (bar vrbl))
vrbl
(new (*obj))))
Is compiled to:
vrbl = bar(vrbl) ? vrbl : new Obj().foo();
Instead of:
((vrbl = bar(vrbl)) ? vrbl : new Obj()).foo();
It is great that the turnery operator is used, though.
Can I get some help to fix it?
--
Kamen
From: Pascal Bourguignon
Subject: Re: issue with operator precedence in Parenscript
Date:
Message-ID: <87odk3zoql.fsf@informatimago.com>
Kamen TOMOV <·····@cybuild.com> writes:
> Hi,
>
> There is an issue with the operator precedence in Parenscript. The
> expression:
>
> (.foo
> (if (setf vrbl (bar vrbl))
> vrbl
> (new (*obj))))
>
> Is compiled to:
>
> vrbl = bar(vrbl) ? vrbl : new Obj().foo();
>
> Instead of:
>
> ((vrbl = bar(vrbl)) ? vrbl : new Obj()).foo();
>
> It is great that the turnery operator is used, though.
>
> Can I get some help to fix it?
Try this patch:
diff --exclude CVS --exclude _darcs --exclude '*~' --exclude '*.fasl' --exclude '*.fas' --exclude '*.lib' --exclude '*.[oa]' -Naurtwb --exclude '*.pdf' --exclude '*.fas*' parenscript-20061003-original/src/css.lisp parenscript-20061003/src/css.lisp
--- parenscript-20061003-original/src/css.lisp 2006-10-03 21:54:27.000000000 +0200
+++ parenscript-20061003/src/css.lisp 2007-03-14 12:25:41.000000000 +0100
@@ -41,7 +41,7 @@
";"))
(defmacro css-inline (&rest propvals)
- `(js::css-inline-func ,propvals))
+ `(js::css-inline-func ',propvals))
(defmacro css-file (&rest rules)
`(html
diff --exclude CVS --exclude _darcs --exclude '*~' --exclude '*.fasl' --exclude '*.fas' --exclude '*.lib' --exclude '*.[oa]' -Naurtwb --exclude '*.pdf' --exclude '*.fas*' parenscript-20061003-original/src/js.lisp parenscript-20061003/src/js.lisp
--- parenscript-20061003-original/src/js.lisp 2006-10-03 21:54:27.000000000 +0200
+++ parenscript-20061003/src/js.lisp 2007-03-26 16:09:17.000000000 +0200
@@ -395,8 +395,13 @@
:index (mapcar #'js-compile-to-expression coords)))
(defmethod js-to-strings ((aref js-aref) start-pos)
+
(dwim-join (cons (js-to-strings (aref-array aref) start-pos)
- (mapcar #'(lambda (x) (dwim-join (list (js-to-strings x (+ start-pos 2)))
+ (mapcar #'(lambda (x)
+ (dwim-join
+ (list
+ (list (format nil "(~{~A~^ ~})"
+ (js-to-strings x (+ start-pos 2)))))
(- 80 start-pos 2)
:start "[" :end "]"))
(aref-index aref)))
@@ -639,14 +644,18 @@
(defmethod js-to-strings ((form function-call) start-pos)
(let* ((value-string-lists
- (mapcar #'(lambda (x) (js-to-strings x (+ start-pos 2)))
+ (mapcar #'(lambda (x)
+ (list (format nil "(~{~A~^ ~})"
+ (js-to-strings x (+ start-pos 2)))))
(f-args form)))
(max-length (- 80 start-pos 2))
(args (dwim-join value-string-lists max-length
:start "(" :end ")" :join-after ",")))
(etypecase (f-function form)
(js-lambda
- (dwim-join (list (append (dwim-join (list (js-to-strings (f-function form) (+ start-pos 2)))
+ (dwim-join (list (append
+ (dwim-join
+ (list (js-to-strings (f-function form) (+ start-pos 2)))
max-length
:start "(" :end ")" :separator "")
args))
@@ -660,7 +669,9 @@
(function-call
;; TODO it adds superfluous newlines after each ()
;; and it's nearly the same as the js-lambda case above
- (dwim-join (list (append (dwim-join (list (js-to-strings (f-function form) (+ start-pos 2)))
+ (dwim-join
+ (list (append (dwim-join
+ (list (js-to-strings (f-function form) (+ start-pos 2)))
max-length :separator "")
args))
max-length :separator "")))))
@@ -686,7 +697,11 @@
(butlast (butlast fname))
(last (car (last fname))))
(nconc butlast
- (dwim-join (mapcar #'(lambda (x) (js-to-strings x (+ start-pos 2)))
+ (dwim-join (mapcar
+ #'(lambda (x)
+ (list
+ (format nil "(~{~A~^ ~})"
+ (js-to-strings x (+ start-pos 2)))))
(m-args form))
(- 80 start-pos 2)
:start last
--
__Pascal Bourguignon__ http://www.informatimago.com/
NOTE: The most fundamental particles in this product are held
together by a "gluing" force about which little is currently known
and whose adhesive power can therefore not be permanently
guaranteed.
From: Kamen TOMOV
Subject: Re: issue with operator precedence in Parenscript
Date:
Message-ID: <ups4i1wjl.fsf@cybuild.com>
On �������, ��� 29 2007, Pascal Bourguignon wrote:
>> Can I get some help to fix it?
>
>
> Try this patch:
> ...
Thanks! It didn't work here, though - what issue does it fix?
--
�����