public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
* bug in kawa syntax transformer?
@ 2024-06-29  8:13 Damien Mattei
  2024-06-29  9:03 ` Damien Mattei
  0 siblings, 1 reply; 7+ messages in thread
From: Damien Mattei @ 2024-06-29  8:13 UTC (permalink / raw)
  To: kawa mailing list

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

hello,

still the bu i was talking about, the behavior is this:

it is some code made of modules , it is working well in REPL:

i compute 3 * 5 + 2:

#|kawa:1|# (import (nfx))
#|kawa:2|# ($nfx$ 3 * 5 + 2)
!0-generic : terms=(3 * 5 + 2)
!0-generic : operator-precedence=((#<syntax#387 expt in #815>
                                   #<syntax#388 ** in #816>)
                                  (#<syntax#389 * in #817>
                                   #<syntax#390 / in #818>
                                   #<syntax#391 % in #819>)
                                  (#<syntax#392 + in #820>
                                   #<syntax#393 - in #821>)
                                  (#<syntax#394 << in #822>
                                   #<syntax#395 >> in #823>)
                                  (#<syntax#396 & in #824>
                                   #<syntax#397 ∣ in #825>)
                                  (#<syntax#398 < in #826>
                                   #<syntax#399 > in #827>
                                   #<syntax#400 = in #828>
                                   #<syntax#401 ≠ in #829>
                                   #<syntax#402 <= in #830>
                                   #<syntax#403 >= in #831>
                                   #<syntax#404 <> in #832>)
                                  (#<syntax#405 and in #833>)
                                  (#<syntax#406 or in #834>)
                                  (#<syntax#378 <- in #806>
                                   #<syntax#379 -> in #807>
                                   #<syntax#380 ← in #808>
                                   #<syntax#381 → in #809>
                                   #<syntax#382 := in #810>
                                   #<syntax#383 <v in #811>
                                   #<syntax#384 v> in #812>
                                   #<syntax#385 ⇜ in #813>
                                   #<syntax#386 ⇝ in #814>)
                                  (#<syntax#373 <+ in #801>
                                   #<syntax#374 +> in #802>
                                   #<syntax#375 ⥆ in #803>
                                   #<syntax#376 ⥅ in #804>
                                   #<syntax#377 :+ in #805>))
!*-generic : terms = (2 + 5 * 3)
!*-generic : operator-groups = ((#<syntax#387 expt in #815>
                                 #<syntax#388 ** in #816>)
                                (#<syntax#389 * in #817>
                                 #<syntax#390 / in #818>
                                 #<syntax#391 % in #819>)
                                (#<syntax#392 + in #820>
                                 #<syntax#393 - in #821>)
                                (#<syntax#394 << in #822>
                                 #<syntax#395 >> in #823>)
                                (#<syntax#396 & in #824>
                                 #<syntax#397 ∣ in #825>)
                                (#<syntax#398 < in #826>
                                 #<syntax#399 > in #827>
                                 #<syntax#400 = in #828>
                                 #<syntax#401 ≠ in #829>
                                 #<syntax#402 <= in #830>
                                 #<syntax#403 >= in #831>
                                 #<syntax#404 <> in #832>)
                                (#<syntax#405 and in #833>)
                                (#<syntax#406 or in #834>)
                                (#<syntax#378 <- in #806>
                                 #<syntax#379 -> in #807>
                                 #<syntax#380 ← in #808>
                                 #<syntax#381 → in #809>
                                 #<syntax#382 := in #810>
                                 #<syntax#383 <v in #811>
                                 #<syntax#384 v> in #812>
                                 #<syntax#385 ⇜ in #813>
                                 #<syntax#386 ⇝ in #814>)
                                (#<syntax#373 <+ in #801>
                                 #<syntax#374 +> in #802>
                                 #<syntax#375 ⥆ in #803>
                                 #<syntax#376 ⥅ in #804>
                                 #<syntax#377 :+ in #805>))

!** : terms = (2 + 5 * 3)
!** : operators = (#<syntax#387 expt in #815> #<syntax#388 ** in #816>)
!** : stack = ()
!** : terms = (+ 5 * 3)
!** : operators = (#<syntax#387 expt in #815> #<syntax#388 ** in #816>)
!** : stack = (2)
!** : terms = (5 * 3)
!** : operators = (#<syntax#387 expt in #815> #<syntax#388 ** in #816>)
!** : stack = (+ 2)
!** : terms = (* 3)
!** : operators = (#<syntax#387 expt in #815> #<syntax#388 ** in #816>)
!** : stack = (5 + 2)
!** : terms = (3)
!** : operators = (#<syntax#387 expt in #815> #<syntax#388 ** in #816>)
!** : stack = (* 5 + 2)
!** : terms = ()
!** : operators = (#<syntax#387 expt in #815> #<syntax#388 ** in #816>)
!** : stack = (3 * 5 + 2)
!**-generic cond case 2 : stack =(3 * 5 + 2)
!**-generic : terms =()
!*-generic : rv-tms =(3 * 5 + 2)
!*-generic : terms = (3 * 5 + 2)
!*-generic : operator-groups = ((#<syntax#389 * in #817>
                                 #<syntax#390 / in #818>
                                 #<syntax#391 % in #819>)
                                (#<syntax#392 + in #820>
                                 #<syntax#393 - in #821>)
                                (#<syntax#394 << in #822>
                                 #<syntax#395 >> in #823>)
                                (#<syntax#396 & in #824>
                                 #<syntax#397 ∣ in #825>)
                                (#<syntax#398 < in #826>
                                 #<syntax#399 > in #827>
                                 #<syntax#400 = in #828>
                                 #<syntax#401 ≠ in #829>
                                 #<syntax#402 <= in #830>
                                 #<syntax#403 >= in #831>
                                 #<syntax#404 <> in #832>)
                                (#<syntax#405 and in #833>)
                                (#<syntax#406 or in #834>)
                                (#<syntax#378 <- in #806>
                                 #<syntax#379 -> in #807>
                                 #<syntax#380 ← in #808>
                                 #<syntax#381 → in #809>
                                 #<syntax#382 := in #810>
                                 #<syntax#383 <v in #811>
                                 #<syntax#384 v> in #812>
                                 #<syntax#385 ⇜ in #813>
                                 #<syntax#386 ⇝ in #814>)
                                (#<syntax#373 <+ in #801>
                                 #<syntax#374 +> in #802>
                                 #<syntax#375 ⥆ in #803>
                                 #<syntax#376 ⥅ in #804>
                                 #<syntax#377 :+ in #805>))

!** : terms = (3 * 5 + 2)
!** : operators = (#<syntax#389 * in #817> #<syntax#390 / in #818>
                   #<syntax#391 % in #819>)
!** : stack = ()
!** : terms = (* 5 + 2)
!** : operators = (#<syntax#389 * in #817> #<syntax#390 / in #818>
                   #<syntax#391 % in #819>)
!** : stack = (3)
!** : terms = (5 + 2)
!** : operators = (#<syntax#389 * in #817> #<syntax#390 / in #818>
                   #<syntax#391 % in #819>)
!** : stack = (* 3)
!** : terms = (+ 2)
!** : operators = (#<syntax#389 * in #817> #<syntax#390 / in #818>
                   #<syntax#391 % in #819>)
!** : stack = ((* 3 5))
!** : terms = (2)
!** : operators = (#<syntax#389 * in #817> #<syntax#390 / in #818>
                   #<syntax#391 % in #819>)
!** : stack = (+ (* 3 5))
!** : terms = ()
!** : operators = (#<syntax#389 * in #817> #<syntax#390 / in #818>
                   #<syntax#391 % in #819>)
!** : stack = (2 + (* 3 5))
!**-generic cond case 1 : stack =(2 + (* 3 5))
!**-generic : terms =()
!**-generic : rs =((* 3 5) + 2)
!*-generic : rv-tms =((* 3 5) + 2)
!*-generic : terms = ((* 3 5) + 2)
!*-generic : operator-groups = ((#<syntax#392 + in #820>
                                 #<syntax#393 - in #821>)
                                (#<syntax#394 << in #822>
                                 #<syntax#395 >> in #823>)
                                (#<syntax#396 & in #824>
                                 #<syntax#397 ∣ in #825>)
                                (#<syntax#398 < in #826>
                                 #<syntax#399 > in #827>
                                 #<syntax#400 = in #828>
                                 #<syntax#401 ≠ in #829>
                                 #<syntax#402 <= in #830>
                                 #<syntax#403 >= in #831>
                                 #<syntax#404 <> in #832>)
                                (#<syntax#405 and in #833>)
                                (#<syntax#406 or in #834>)
                                (#<syntax#378 <- in #806>
                                 #<syntax#379 -> in #807>
                                 #<syntax#380 ← in #808>
                                 #<syntax#381 → in #809>
                                 #<syntax#382 := in #810>
                                 #<syntax#383 <v in #811>
                                 #<syntax#384 v> in #812>
                                 #<syntax#385 ⇜ in #813>
                                 #<syntax#386 ⇝ in #814>)
                                (#<syntax#373 <+ in #801>
                                 #<syntax#374 +> in #802>
                                 #<syntax#375 ⥆ in #803>
                                 #<syntax#376 ⥅ in #804>
                                 #<syntax#377 :+ in #805>))

!** : terms = ((* 3 5) + 2)
!** : operators = (#<syntax#392 + in #820> #<syntax#393 - in #821>)
!** : stack = ()
!** : terms = (+ 2)
!** : operators = (#<syntax#392 + in #820> #<syntax#393 - in #821>)
!** : stack = ((* 3 5))
!** : terms = (2)
!** : operators = (#<syntax#392 + in #820> #<syntax#393 - in #821>)
!** : stack = (+ (* 3 5))
!** : terms = ()
!** : operators = (#<syntax#392 + in #820> #<syntax#393 - in #821>)
!** : stack = ((+ (* 3 5) 2))
!**-generic cond case 1 : stack =((+ (* 3 5) 2))
!**-generic : terms =()
!**-generic : rs =((+ (* 3 5) 2))
!*-generic : rv-tms =((+ (* 3 5) 2))
!*-generic : terms = ((+ (* 3 5) 2))
!*-generic : operator-groups = ((#<syntax#394 << in #822>
                                 #<syntax#395 >> in #823>)
                                (#<syntax#396 & in #824>
                                 #<syntax#397 ∣ in #825>)
                                (#<syntax#398 < in #826>
                                 #<syntax#399 > in #827>
                                 #<syntax#400 = in #828>
                                 #<syntax#401 ≠ in #829>
                                 #<syntax#402 <= in #830>
                                 #<syntax#403 >= in #831>
                                 #<syntax#404 <> in #832>)
                                (#<syntax#405 and in #833>)
                                (#<syntax#406 or in #834>)
                                (#<syntax#378 <- in #806>
                                 #<syntax#379 -> in #807>
                                 #<syntax#380 ← in #808>
                                 #<syntax#381 → in #809>
                                 #<syntax#382 := in #810>
                                 #<syntax#383 <v in #811>
                                 #<syntax#384 v> in #812>
                                 #<syntax#385 ⇜ in #813>
                                 #<syntax#386 ⇝ in #814>)
                                (#<syntax#373 <+ in #801>
                                 #<syntax#374 +> in #802>
                                 #<syntax#375 ⥆ in #803>
                                 #<syntax#376 ⥅ in #804>
                                 #<syntax#377 :+ in #805>))


17

it is a long debug display to compute 3 * 5 + 2 = 17

now when i try the computation in a module:

(define-library (test-nfx) ; R7RS

  (import
 (kawa base)

 (operators-list)
 (n-arity)
 (infix-with-precedence-to-prefix)
 (nfx))


  (define x ($nfx$ 3 * 5 + 2))
  (display x) (newline)

)


here is the output:

#|kawa:1|# (import (test-nfx))
!0-generic : terms=(3 * 5 + 2)
!0-generic : operator-precedence=((#<syntax#355 expt in #783>
                                   #<syntax#356 ** in #784>)
                                  (#<syntax#357 * in #785>
                                   #<syntax#358 / in #786>
                                   #<syntax#359 % in #787>)
                                  (#<syntax#360 + in #788>
                                   #<syntax#361 - in #789>)
                                  (#<syntax#362 << in #790>
                                   #<syntax#363 >> in #791>)
                                  (#<syntax#364 & in #792>
                                   #<syntax#365 ∣ in #793>)
                                  (#<syntax#366 < in #794>
                                   #<syntax#367 > in #795>
                                   #<syntax#368 = in #796>
                                   #<syntax#369 ≠ in #797>
                                   #<syntax#370 <= in #798>
                                   #<syntax#371 >= in #799>
                                   #<syntax#372 <> in #800>)
                                  (#<syntax#373 and in #801>)
                                  (#<syntax#374 or in #802>)
                                  (#<syntax#346 <- in #774>
                                   #<syntax#347 -> in #775>
                                   #<syntax#348 ← in #776>
                                   #<syntax#349 → in #777>
                                   #<syntax#350 := in #778>
                                   #<syntax#351 <v in #779>
                                   #<syntax#352 v> in #780>
                                   #<syntax#353 ⇜ in #781>
                                   #<syntax#354 ⇝ in #782>)
                                  (#<syntax#341 <+ in #769>
                                   #<syntax#342 +> in #770>
                                   #<syntax#343 ⥆ in #771>
                                   #<syntax#344 ⥅ in #772>
                                   #<syntax#345 :+ in #773>))
!*-generic : terms = (2 + 5 * 3)
!*-generic : operator-groups = ((#<syntax#355 expt in #783>
                                 #<syntax#356 ** in #784>)
                                (#<syntax#357 * in #785>
                                 #<syntax#358 / in #786>
                                 #<syntax#359 % in #787>)
                                (#<syntax#360 + in #788>
                                 #<syntax#361 - in #789>)
                                (#<syntax#362 << in #790>
                                 #<syntax#363 >> in #791>)
                                (#<syntax#364 & in #792>
                                 #<syntax#365 ∣ in #793>)
                                (#<syntax#366 < in #794>
                                 #<syntax#367 > in #795>
                                 #<syntax#368 = in #796>
                                 #<syntax#369 ≠ in #797>
                                 #<syntax#370 <= in #798>
                                 #<syntax#371 >= in #799>
                                 #<syntax#372 <> in #800>)
                                (#<syntax#373 and in #801>)
                                (#<syntax#374 or in #802>)
                                (#<syntax#346 <- in #774>
                                 #<syntax#347 -> in #775>
                                 #<syntax#348 ← in #776>
                                 #<syntax#349 → in #777>
                                 #<syntax#350 := in #778>
                                 #<syntax#351 <v in #779>
                                 #<syntax#352 v> in #780>
                                 #<syntax#353 ⇜ in #781>
                                 #<syntax#354 ⇝ in #782>)
                                (#<syntax#341 <+ in #769>
                                 #<syntax#342 +> in #770>
                                 #<syntax#343 ⥆ in #771>
                                 #<syntax#344 ⥅ in #772>
                                 #<syntax#345 :+ in #773>))

!** : terms = (2 + 5 * 3)
!** : operators = (#<syntax#355 expt in #783> #<syntax#356 ** in #784>)
!** : stack = ()
!** : terms = (+ 5 * 3)
!** : operators = (#<syntax#355 expt in #783> #<syntax#356 ** in #784>)
!** : stack = (2)
!** : terms = (5 * 3)
!** : operators = (#<syntax#355 expt in #783> #<syntax#356 ** in #784>)
!** : stack = (+ 2)
!** : terms = (* 3)
!** : operators = (#<syntax#355 expt in #783> #<syntax#356 ** in #784>)
!** : stack = (5 + 2)
!** : terms = (3)
!** : operators = (#<syntax#355 expt in #783> #<syntax#356 ** in #784>)
!** : stack = (* 5 + 2)
!** : terms = ()
!** : operators = (#<syntax#355 expt in #783> #<syntax#356 ** in #784>)
!** : stack = (3 * 5 + 2)
!**-generic cond case 2 : stack =(3 * 5 + 2)
!**-generic : terms =()
!*-generic : rv-tms =(3 * 5 + 2)
!*-generic : terms = (3 * 5 + 2)
!*-generic : operator-groups = ((#<syntax#357 * in #785>
                                 #<syntax#358 / in #786>
                                 #<syntax#359 % in #787>)
                                (#<syntax#360 + in #788>
                                 #<syntax#361 - in #789>)
                                (#<syntax#362 << in #790>
                                 #<syntax#363 >> in #791>)
                                (#<syntax#364 & in #792>
                                 #<syntax#365 ∣ in #793>)
                                (#<syntax#366 < in #794>
                                 #<syntax#367 > in #795>
                                 #<syntax#368 = in #796>
                                 #<syntax#369 ≠ in #797>
                                 #<syntax#370 <= in #798>
                                 #<syntax#371 >= in #799>
                                 #<syntax#372 <> in #800>)
                                (#<syntax#373 and in #801>)
                                (#<syntax#374 or in #802>)
                                (#<syntax#346 <- in #774>
                                 #<syntax#347 -> in #775>
                                 #<syntax#348 ← in #776>
                                 #<syntax#349 → in #777>
                                 #<syntax#350 := in #778>
                                 #<syntax#351 <v in #779>
                                 #<syntax#352 v> in #780>
                                 #<syntax#353 ⇜ in #781>
                                 #<syntax#354 ⇝ in #782>)
                                (#<syntax#341 <+ in #769>
                                 #<syntax#342 +> in #770>
                                 #<syntax#343 ⥆ in #771>
                                 #<syntax#344 ⥅ in #772>
                                 #<syntax#345 :+ in #773>))

!** : terms = (3 * 5 + 2)
!** : operators = (#<syntax#357 * in #785> #<syntax#358 / in #786>
                   #<syntax#359 % in #787>)
!** : stack = ()
!** : terms = (* 5 + 2)
!** : operators = (#<syntax#357 * in #785> #<syntax#358 / in #786>
                   #<syntax#359 % in #787>)
!** : stack = (3)
!** : terms = (5 + 2)
!** : operators = (#<syntax#357 * in #785> #<syntax#358 / in #786>
                   #<syntax#359 % in #787>)
!** : stack = (* 3)
!** : terms = (+ 2)
!** : operators = (#<syntax#357 * in #785> #<syntax#358 / in #786>
                   #<syntax#359 % in #787>)
!** : stack = ((* 3 5))
!** : terms = (2)
!** : operators = (#<syntax#357 * in #785> #<syntax#358 / in #786>
                   #<syntax#359 % in #787>)
!** : stack = (+ (* 3 5))
!** : terms = ()
!** : operators = (#<syntax#357 * in #785> #<syntax#358 / in #786>
                   #<syntax#359 % in #787>)
!** : stack = (2 + (* 3 5))
!**-generic cond case 1 : stack =(2 + (* 3 5))
!**-generic : terms =()
!**-generic : rs =((* 3 5) + 2)
!*-generic : rv-tms =151 3 168 13 151 14 25 7473stack7459 151 3 168 13 152
6 17 7479terms7458 151 3 168 13 153 6 18 7485stack7459 151 3 168 13 156 12
157 42 156 16 38 7498operators7460 7501x7475 7502x7475 156 12 157 42
7504member-syntax7445 157 24 30ClassType
kawa.lang.TemplateScope7507null7477 7508operators7460 158 10 31
7509calc-generic7462 7511op7471 7512b7472 7513a7473 159 10 31
7514calc-generic7462 7516op7471 7517a7473 7518b7472 163 5 168 12
7520!**-generic7449 163 18 29 7524terms7458ClassType gnu.lists.Pair164 4
165 23 7527calculus7474 165 10 22 7530stack7459 7531operators7460
7532creator7461(Let#662 line::-: ((op#7471/fl:40042 = (Apply line::- (Quote
ClassType java.lang.Object kawa.lib.lists.car(gnu.lists.Pair)
::gnu.expr.PrimProcedure) (Ref//#)))) (Let#665 line::-: ((b#7472/fl:40042 =
(Apply line::- (Quote ClassType java.lang.Object
kawa.lib.lists.car(gnu.lists.Pair) ::gnu.expr.PrimProcedure) (Ref//#))))
(Let#668 line::-: ((a#7473/fl:40042 = (Apply line::- (Quote ClassType
java.lang.Object kawa.lib.lists.cadr(java.lang.Object)
::gnu.expr.PrimProcedure) (Ref//#)))) (Let#671 line::-:
((calculus#7474/fl:40042 = (Let#675 line::-: ((x#7475/fl:40042 = (Apply
line::- (Quote ClassType java.lang.Object
kawa.lib.lists.memq(java.lang.Object,java.lang.Object)
::gnu.expr.PrimProcedure) (Quote expt ::gnu.mapping.SimpleSymbol)
(Ref//#)))) (If (If (Ref//#) (Ref//#) (Apply line::-: (Ref//#) (Let#681
line::- ((null#7477/fl:42::kawa.lang.TemplateScope = (Apply =>  (Quote
ClassType kawa.lang.TemplateScope kawa.lang.TemplateScope.make()
::gnu.expr.PrimProcedure)))) (Apply (Quote ClassType java.lang.Object
kawa.lang.SyntaxTemplate.execute(java.lang.Object[],kawa.lang.TemplateScope)
::gnu.expr.PrimProcedure) (Quote kawa.lang.SyntaxTemplate@55120f99
::kawa.lang.SyntaxTemplate) (Quote #!null ::(type of null)) (Ref//#)))
(Ref//#))) (Apply line::- (Ref//#) (Ref//#) (Ref//#) (Ref//#)) (Apply
line::- (Ref//#) (Ref//#) (Ref//#) (Ref//#)))))) (Apply [tailcall] line::-:
(Ref//#) (Apply line::- (Quote ClassType java.lang.Object
kawa.lib.lists.cdr(gnu.lists.Pair) ::gnu.expr.PrimProcedure) (Ref//#))
(Apply =>  line::-: (Quote ClassType gnu.lists.Pair
kawa.lib.lists.cons(java.lang.Object,java.lang.Object)
::gnu.expr.PrimProcedure) (Ref//#) (Apply line::- (Quote ClassType
java.lang.Object kawa.lib.lists.cddr(java.lang.Object)
::gnu.expr.PrimProcedure) (Ref//#))) (Ref//#) (Ref//#))))))
!*-generic : terms = 151 3 168 13 151 14 25 7473stack7459 151 3 168 13 152
6 17 7479terms7458 151 3 168 13 153 6 18 7485stack7459 151 3 168 13 156 12
157 42 156 16 38 7498operators7460 7501x7475 7502x7475 156 12 157 42
7504member-syntax7445 157 24 30ClassType
kawa.lang.TemplateScope7507null7477 7508operators7460 158 10 31
7509calc-generic7462 7511op7471 7512b7472 7513a7473 159 10 31
7514calc-generic7462 7516op7471 7517a7473 7518b7472 163 5 168 12
7520!**-generic7449 163 18 29 7524terms7458ClassType gnu.lists.Pair164 4
165 23 7527calculus7474 165 10 22 7530stack7459 7531operators7460
7532creator7461(Let#662 line::-: ((op#7471/fl:40042 = (Apply line::- (Quote
ClassType java.lang.Object kawa.lib.lists.car(gnu.lists.Pair)
::gnu.expr.PrimProcedure) (Ref//#)))) (Let#665 line::-: ((b#7472/fl:40042 =
(Apply line::- (Quote ClassType java.lang.Object
kawa.lib.lists.car(gnu.lists.Pair) ::gnu.expr.PrimProcedure) (Ref//#))))
(Let#668 line::-: ((a#7473/fl:40042 = (Apply line::- (Quote ClassType
java.lang.Object kawa.lib.lists.cadr(java.lang.Object)
::gnu.expr.PrimProcedure) (Ref//#)))) (Let#671 line::-:
((calculus#7474/fl:40042 = (Let#675 line::-: ((x#7475/fl:40042 = (Apply
line::- (Quote ClassType java.lang.Object
kawa.lib.lists.memq(java.lang.Object,java.lang.Object)
::gnu.expr.PrimProcedure) (Quote expt ::gnu.mapping.SimpleSymbol)
(Ref//#)))) (If (If (Ref//#) (Ref//#) (Apply line::-: (Ref//#) (Let#681
line::- ((null#7477/fl:42::kawa.lang.TemplateScope = (Apply =>  (Quote
ClassType kawa.lang.TemplateScope kawa.lang.TemplateScope.make()
::gnu.expr.PrimProcedure)))) (Apply (Quote ClassType java.lang.Object
kawa.lang.SyntaxTemplate.execute(java.lang.Object[],kawa.lang.TemplateScope)
::gnu.expr.PrimProcedure) (Quote kawa.lang.SyntaxTemplate@55120f99
::kawa.lang.SyntaxTemplate) (Quote #!null ::(type of null)) (Ref//#)))
(Ref//#))) (Apply line::- (Ref//#) (Ref//#) (Ref//#) (Ref//#)) (Apply
line::- (Ref//#) (Ref//#) (Ref//#) (Ref//#)))))) (Apply [tailcall] line::-:
(Ref//#) (Apply line::- (Quote ClassType java.lang.Object
kawa.lib.lists.cdr(gnu.lists.Pair) ::gnu.expr.PrimProcedure) (Ref//#))
(Apply =>  line::-: (Quote ClassType gnu.lists.Pair
kawa.lib.lists.cons(java.lang.Object,java.lang.Object)
::gnu.expr.PrimProcedure) (Ref//#) (Apply line::- (Quote ClassType
java.lang.Object kawa.lib.lists.cddr(java.lang.Object)
::gnu.expr.PrimProcedure) (Ref//#))) (Ref//#) (Ref//#))))))
!*-generic : operator-groups = ((#<syntax#360 + in #788>
                                 #<syntax#361 - in #789>)
                                (#<syntax#362 << in #790>
                                 #<syntax#363 >> in #791>)
                                (#<syntax#364 & in #792>
                                 #<syntax#365 ∣ in #793>)
                                (#<syntax#366 < in #794>
                                 #<syntax#367 > in #795>
                                 #<syntax#368 = in #796>
                                 #<syntax#369 ≠ in #797>
                                 #<syntax#370 <= in #798>
                                 #<syntax#371 >= in #799>
                                 #<syntax#372 <> in #800>)
                                (#<syntax#373 and in #801>)
                                (#<syntax#374 or in #802>)
                                (#<syntax#346 <- in #774>
                                 #<syntax#347 -> in #775>
                                 #<syntax#348 ← in #776>
                                 #<syntax#349 → in #777>
                                 #<syntax#350 := in #778>
                                 #<syntax#351 <v in #779>
                                 #<syntax#352 v> in #780>
                                 #<syntax#353 ⇜ in #781>
                                 #<syntax#354 ⇝ in #782>)
                                (#<syntax#341 <+ in #769>
                                 #<syntax#342 +> in #770>
                                 #<syntax#343 ⥆ in #771>
                                 #<syntax#344 ⥅ in #772>
                                 #<syntax#345 :+ in #773>))

(import (test-nfx))
/Users/mattei/Scheme-PLUS-for-Kawa/test-nfx.scm:15:13: evaluating syntax
transformer '$nfx$' threw Argument #1 (null) to 'cdr' has wrong type
(expected: gnu.lists.Pair)
    gnu.mapping.CallContext.matchError(CallContext.java:185)
    gnu.expr.PrimProcedure.applyToConsumerX(PrimProcedure.java:250)
    gnu.expr.PrimProcedure.applyToConsumer(PrimProcedure.java:189)
    gnu.mapping.CallContext.runUntilDone(CallContext.java:586)
    gnu.mapping.CallContext.getFromContext(CallContext.java:616)
    gnu.expr.Expression.eval(Expression.java:52)
    gnu.expr.ApplyExp.apply(ApplyExp.java:161)
    gnu.expr.IfExp.apply(IfExp.java:43)
    gnu.expr.Expression.applyMethodExpression(Expression.java:41)
    gnu.mapping.CallContext.runUntilDone(CallContext.java:586)
    gnu.mapping.CallContext.getFromContext(CallContext.java:616)
    gnu.expr.Expression.eval(Expression.java:52)
    gnu.expr.IfExp.apply(IfExp.java:40)
    gnu.expr.LetExp.apply(LetExp.java:72)
    gnu.expr.BeginExp.apply(BeginExp.java:123)
    gnu.expr.LambdaExp$Closure.applyToConsumer(LambdaExp.java:2144)
    gnu.mapping.CallContext.runUntilDone(CallContext.java:586)
    gnu.mapping.CallContext.getFromContext(CallContext.java:616)
    gnu.expr.Expression.eval(Expression.java:52)
    gnu.expr.ApplyExp.apply(ApplyExp.java:161)
    gnu.expr.IfExp.apply(IfExp.java:43)
    gnu.expr.Expression.applyMethodExpression(Expression.java:41)
    gnu.mapping.CallContext.runUntilDone(CallContext.java:586)
    gnu.mapping.CallContext.getFromContext(CallContext.java:616)
    gnu.expr.Expression.eval(Expression.java:52)
    gnu.expr.Expression.eval(Expression.java:67)
    gnu.expr.SetExp.apply(SetExp.java:108)
    gnu.expr.Expression.applyMethodExpression(Expression.java:41)
    gnu.mapping.CallContext.runUntilDone(CallContext.java:586)
    gnu.mapping.CallContext.getFromContext(CallContext.java:616)
    gnu.expr.Expression.eval(Expression.java:52)
    gnu.expr.BeginExp.apply(BeginExp.java:117)
    gnu.expr.LetExp.apply(LetExp.java:72)
    gnu.expr.LambdaExp$Closure.applyToConsumer(LambdaExp.java:2144)
    gnu.mapping.CallContext.runUntilDone(CallContext.java:586)
    gnu.mapping.CallContext.getFromContext(CallContext.java:616)
    gnu.expr.Expression.eval(Expression.java:52)
    gnu.expr.ApplyExp.apply(ApplyExp.java:161)
    gnu.expr.BeginExp.apply(BeginExp.java:123)
    gnu.expr.LetExp.apply(LetExp.java:72)
    gnu.expr.Expression.applyMethodExpression(Expression.java:41)
    gnu.mapping.CallContext.runUntilDone(CallContext.java:586)
    gnu.mapping.CallContext.getFromContext(CallContext.java:616)
    gnu.expr.Expression.eval(Expression.java:52)
    gnu.expr.LetExp.evalVariable(LetExp.java:26)
    gnu.expr.LetExp.apply(LetExp.java:60)
    gnu.expr.LetExp.apply(LetExp.java:72)
    gnu.expr.IfExp.apply(IfExp.java:41)
    gnu.expr.Expression.applyMethodExpression(Expression.java:41)
    gnu.mapping.CallContext.runUntilDone(CallContext.java:586)
    gnu.mapping.CallContext.getFromContext(CallContext.java:616)
    gnu.expr.Expression.eval(Expression.java:52)
    gnu.expr.BlockExp.apply(BlockExp.java:58)
    gnu.expr.LetExp.apply(LetExp.java:72)
    gnu.expr.LetExp.apply(LetExp.java:72)
    gnu.expr.LambdaExp$Closure.applyToConsumer(LambdaExp.java:2144)
    gnu.mapping.CallContext.runUntilDone(CallContext.java:586)
    gnu.mapping.CallContext.runUntilValue(CallContext.java:669)
    gnu.mapping.Procedure.apply1(Procedure.java:154)
    kawa.lang.Macro.expand(Macro.java:205)
    kawa.lang.Macro.rewriteForm(Macro.java:107)
    kawa.lang.Translator.apply_rewrite(Translator.java:181)
    kawa.lang.Translator.rewrite_pair(Translator.java:408)
    kawa.lang.Translator.rewrite(Translator.java:798)
    kawa.lang.Translator.rewrite(Translator.java:778)
    kawa.lang.Translator.rewrite_with_position(Translator.java:1475)
    kawa.lang.Translator.rewrite_car(Translator.java:136)
    kawa.standard.define.rewriteForm(define.java:265)
    kawa.lang.Translator.apply_rewrite(Translator.java:181)
    kawa.lang.Translator.rewrite_pair(Translator.java:361)
    kawa.lang.Translator.rewrite(Translator.java:798)
    kawa.lang.Translator.rewrite(Translator.java:778)
    kawa.lang.Translator.rewriteInBody(Translator.java:708)
    kawa.lang.Translator.rewriteBody(Translator.java:1778)
    kawa.lang.Translator.resolveModule(Translator.java:1959)
    gnu.kawa.lispexpr.LispLanguage.resolve(LispLanguage.java:154)
    gnu.expr.Compilation.process(Compilation.java:1754)
    gnu.expr.ModuleInfo.loadEager(ModuleInfo.java:337)
    kawa.standard.require.importDefinitions(require.java:289)
    kawa.standard.ImportFromLibrary.handleImport(ImportFromLibrary.java:486)

kawa.standard.ImportFromLibrary.scanImportSet1(ImportFromLibrary.java:295)

kawa.standard.ImportFromLibrary.scanImportSet(ImportFromLibrary.java:263)
    kawa.standard.ImportFromLibrary.scanForm(ImportFromLibrary.java:96)
    kawa.lang.Translator.scanForm(Translator.java:1623)
    kawa.lang.Translator.scanBody(Translator.java:1680)
    kawa.standard.begin.scanForm(begin.java:23)
    kawa.lang.Translator.scanForm(Translator.java:1623)
    gnu.kawa.lispexpr.LispLanguage.parse(LispLanguage.java:117)
    gnu.expr.Language.parse(Language.java:765)
    gnu.expr.Language.parse(Language.java:759)
    gnu.kawa.io.JLineInPort.parse(JLineInPort.java:97)

org.jline.reader.impl.LineReaderImpl.acceptLine(LineReaderImpl.java:2982)
    org.jline.reader.impl.LineReaderImpl$1.apply(LineReaderImpl.java:3796)
    org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:665)
    org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:454)
    gnu.kawa.io.JLineInPort$KawaParsedLine.parse(JLineInPort.java:292)

java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
    java.base/java.lang.reflect.Method.invoke(Method.java:580)
    kawa.Shell.run(Shell.java:261)
    kawa.Shell.run(Shell.java:196)
    kawa.Shell.run(Shell.java:183)
    kawa.repl.processArgs(repl.java:724)
    kawa.repl.main(repl.java:830)

the display dump show that , the called procedure !**-generic compute well
the result but when the result is send to the calling procedure !*-generic
it changed:
the called procedure !**-generic return rs =((* 3 5) + 2)
and the calling procedure !*-generic get : rv-tms =151 3 168 13 151 14 25
7473stack7459 151 3 ........


!**-generic : rs =((* 3 5) + 2)
!*-generic : rv-tms =151 3 168 13 151 14 25 7473stack7459 151 3 168 13 152
6 17 7479terms7458 151 3 168 13 153 6 18 7485stack7459 151 3 168 13 156 12
157 42 156 16 38 7498operators7460 7501x7475 7502x7475 156 12 157 42
7504member-syntax7445 157 24 30ClassType
kawa.lang.TemplateScope7507null7477 7508operators7460 158 10 31
7509calc-generic7462 7511op7471 7512b7472 7513a7473 159 10 31
7514calc-generic7462 7516op7471 7517a7473 7518b7472 163 5 168 12
7520!**-generic7449 163 18 29 7524terms7458ClassType gnu.lists.Pair164 4
165 23 7527calculus7474 165 10 22 7530stack7459 7531operators7460
7532creator7461(Let#662 line::-: ((op#7471/fl:40042 = (Apply line::- (Quote
ClassType java.lang.Object kawa.lib.lists.car(gnu.lists.Pair)
::gnu.expr.PrimProcedure) (Ref//#)))) (Let#665 line::-: ((b#7472/fl:40042 =
(Apply line::- (Quote ClassType java.lang.Object
kawa.lib.lists.car(gnu.lists.Pair) ::gnu.expr.PrimProcedure) (Ref//#))))
(Let#668 line::-: ((a#7473/fl:40042 = (Apply line::- (Quote ClassType
java.lang.Object kawa.lib.lists.cadr(java.lang.Object)
::gnu.expr.PrimProcedure) (Ref//#)))) (Let#671 line::-:
((calculus#7474/fl:40042 = (Let#675 line::-: ((x#7475/fl:40042 = (Apply
line::- (Quote ClassType java.lang.Object
kawa.lib.lists.memq(java.lang.Object,java.lang.Object)
::gnu.expr.PrimProcedure) (Quote expt ::gnu.mapping.SimpleSymbol)
(Ref//#)))) (If (If (Ref//#) (Ref//#) (Apply line::-: (Ref//#) (Let#681
line::- ((null#7477/fl:42::kawa.lang.TemplateScope = (Apply =>  (Quote
ClassType kawa.lang.TemplateScope kawa.lang.TemplateScope.make()
::gnu.expr.PrimProcedure)))) (Apply (Quote ClassType java.lang.Object
kawa.lang.SyntaxTemplate.execute(java.lang.Object[],kawa.lang.TemplateScope)
::gnu.expr.PrimProcedure) (Quote kawa.lang.SyntaxTemplate@55120f99
::kawa.lang.SyntaxTemplate) (Quote #!null ::(type of null)) (Ref//#)))
(Ref//#))) (Apply line::- (Ref//#) (Ref//#) (Ref//#) (Ref//#)) (Apply
line::- (Ref//#) (Ref//#) (Ref//#) (Ref//#)))))) (Apply [tailcall] line::-:
(Ref//#) (Apply line::- (Quote ClassType java.lang.Object
kawa.lib.lists.cdr(gnu.lists.Pair) ::gnu.expr.PrimProcedure) (Ref//#))
(Apply =>  line::-: (Quote ClassType gnu.lists.Pair
kawa.lib.lists.cons(java.lang.Object,java.lang.Object)
::gnu.expr.PrimProcedure) (Ref//#) (Apply line::- (Quote ClassType
java.lang.Object kawa.lib.lists.cddr(java.lang.Object)
::gnu.expr.PrimProcedure) (Ref//#))) (Ref//#) (Ref//#))))))

i post this in hope the problem could be fixed, that should not be very
hard as it is working in REPL but not in module and only with syntax
transformer use

if i want a way to avoid the problem i will post it

regards,

damien

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

* Re: bug in kawa syntax transformer?
  2024-06-29  8:13 bug in kawa syntax transformer? Damien Mattei
@ 2024-06-29  9:03 ` Damien Mattei
  2024-06-29 14:16   ` Per Bothner
  0 siblings, 1 reply; 7+ messages in thread
From: Damien Mattei @ 2024-06-29  9:03 UTC (permalink / raw)
  To: kawa mailing list

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

i'm sure it is a kawa bug because i ported all the code to Guile and it
works perfectly.

On Sat, Jun 29, 2024 at 10:13 AM Damien Mattei <damien.mattei@gmail.com>
wrote:

>
>
> hello,
>
> still the bu i was talking about, the behavior is this:
>
> it is some code made of modules , it is working well in REPL:
>
> i compute 3 * 5 + 2:
>
> #|kawa:1|# (import (nfx))
> #|kawa:2|# ($nfx$ 3 * 5 + 2)
> !0-generic : terms=(3 * 5 + 2)
> !0-generic : operator-precedence=((#<syntax#387 expt in #815>
>                                    #<syntax#388 ** in #816>)
>                                   (#<syntax#389 * in #817>
>                                    #<syntax#390 / in #818>
>                                    #<syntax#391 % in #819>)
>                                   (#<syntax#392 + in #820>
>                                    #<syntax#393 - in #821>)
>                                   (#<syntax#394 << in #822>
>                                    #<syntax#395 >> in #823>)
>                                   (#<syntax#396 & in #824>
>                                    #<syntax#397 ∣ in #825>)
>                                   (#<syntax#398 < in #826>
>                                    #<syntax#399 > in #827>
>                                    #<syntax#400 = in #828>
>                                    #<syntax#401 ≠ in #829>
>                                    #<syntax#402 <= in #830>
>                                    #<syntax#403 >= in #831>
>                                    #<syntax#404 <> in #832>)
>                                   (#<syntax#405 and in #833>)
>                                   (#<syntax#406 or in #834>)
>                                   (#<syntax#378 <- in #806>
>                                    #<syntax#379 -> in #807>
>                                    #<syntax#380 ← in #808>
>                                    #<syntax#381 → in #809>
>                                    #<syntax#382 := in #810>
>                                    #<syntax#383 <v in #811>
>                                    #<syntax#384 v> in #812>
>                                    #<syntax#385 ⇜ in #813>
>                                    #<syntax#386 ⇝ in #814>)
>                                   (#<syntax#373 <+ in #801>
>                                    #<syntax#374 +> in #802>
>                                    #<syntax#375 ⥆ in #803>
>                                    #<syntax#376 ⥅ in #804>
>                                    #<syntax#377 :+ in #805>))
> !*-generic : terms = (2 + 5 * 3)
> !*-generic : operator-groups = ((#<syntax#387 expt in #815>
>                                  #<syntax#388 ** in #816>)
>                                 (#<syntax#389 * in #817>
>                                  #<syntax#390 / in #818>
>                                  #<syntax#391 % in #819>)
>                                 (#<syntax#392 + in #820>
>                                  #<syntax#393 - in #821>)
>                                 (#<syntax#394 << in #822>
>                                  #<syntax#395 >> in #823>)
>                                 (#<syntax#396 & in #824>
>                                  #<syntax#397 ∣ in #825>)
>                                 (#<syntax#398 < in #826>
>                                  #<syntax#399 > in #827>
>                                  #<syntax#400 = in #828>
>                                  #<syntax#401 ≠ in #829>
>                                  #<syntax#402 <= in #830>
>                                  #<syntax#403 >= in #831>
>                                  #<syntax#404 <> in #832>)
>                                 (#<syntax#405 and in #833>)
>                                 (#<syntax#406 or in #834>)
>                                 (#<syntax#378 <- in #806>
>                                  #<syntax#379 -> in #807>
>                                  #<syntax#380 ← in #808>
>                                  #<syntax#381 → in #809>
>                                  #<syntax#382 := in #810>
>                                  #<syntax#383 <v in #811>
>                                  #<syntax#384 v> in #812>
>                                  #<syntax#385 ⇜ in #813>
>                                  #<syntax#386 ⇝ in #814>)
>                                 (#<syntax#373 <+ in #801>
>                                  #<syntax#374 +> in #802>
>                                  #<syntax#375 ⥆ in #803>
>                                  #<syntax#376 ⥅ in #804>
>                                  #<syntax#377 :+ in #805>))
>
> !** : terms = (2 + 5 * 3)
> !** : operators = (#<syntax#387 expt in #815> #<syntax#388 ** in #816>)
> !** : stack = ()
> !** : terms = (+ 5 * 3)
> !** : operators = (#<syntax#387 expt in #815> #<syntax#388 ** in #816>)
> !** : stack = (2)
> !** : terms = (5 * 3)
> !** : operators = (#<syntax#387 expt in #815> #<syntax#388 ** in #816>)
> !** : stack = (+ 2)
> !** : terms = (* 3)
> !** : operators = (#<syntax#387 expt in #815> #<syntax#388 ** in #816>)
> !** : stack = (5 + 2)
> !** : terms = (3)
> !** : operators = (#<syntax#387 expt in #815> #<syntax#388 ** in #816>)
> !** : stack = (* 5 + 2)
> !** : terms = ()
> !** : operators = (#<syntax#387 expt in #815> #<syntax#388 ** in #816>)
> !** : stack = (3 * 5 + 2)
> !**-generic cond case 2 : stack =(3 * 5 + 2)
> !**-generic : terms =()
> !*-generic : rv-tms =(3 * 5 + 2)
> !*-generic : terms = (3 * 5 + 2)
> !*-generic : operator-groups = ((#<syntax#389 * in #817>
>                                  #<syntax#390 / in #818>
>                                  #<syntax#391 % in #819>)
>                                 (#<syntax#392 + in #820>
>                                  #<syntax#393 - in #821>)
>                                 (#<syntax#394 << in #822>
>                                  #<syntax#395 >> in #823>)
>                                 (#<syntax#396 & in #824>
>                                  #<syntax#397 ∣ in #825>)
>                                 (#<syntax#398 < in #826>
>                                  #<syntax#399 > in #827>
>                                  #<syntax#400 = in #828>
>                                  #<syntax#401 ≠ in #829>
>                                  #<syntax#402 <= in #830>
>                                  #<syntax#403 >= in #831>
>                                  #<syntax#404 <> in #832>)
>                                 (#<syntax#405 and in #833>)
>                                 (#<syntax#406 or in #834>)
>                                 (#<syntax#378 <- in #806>
>                                  #<syntax#379 -> in #807>
>                                  #<syntax#380 ← in #808>
>                                  #<syntax#381 → in #809>
>                                  #<syntax#382 := in #810>
>                                  #<syntax#383 <v in #811>
>                                  #<syntax#384 v> in #812>
>                                  #<syntax#385 ⇜ in #813>
>                                  #<syntax#386 ⇝ in #814>)
>                                 (#<syntax#373 <+ in #801>
>                                  #<syntax#374 +> in #802>
>                                  #<syntax#375 ⥆ in #803>
>                                  #<syntax#376 ⥅ in #804>
>                                  #<syntax#377 :+ in #805>))
>
> !** : terms = (3 * 5 + 2)
> !** : operators = (#<syntax#389 * in #817> #<syntax#390 / in #818>
>                    #<syntax#391 % in #819>)
> !** : stack = ()
> !** : terms = (* 5 + 2)
> !** : operators = (#<syntax#389 * in #817> #<syntax#390 / in #818>
>                    #<syntax#391 % in #819>)
> !** : stack = (3)
> !** : terms = (5 + 2)
> !** : operators = (#<syntax#389 * in #817> #<syntax#390 / in #818>
>                    #<syntax#391 % in #819>)
> !** : stack = (* 3)
> !** : terms = (+ 2)
> !** : operators = (#<syntax#389 * in #817> #<syntax#390 / in #818>
>                    #<syntax#391 % in #819>)
> !** : stack = ((* 3 5))
> !** : terms = (2)
> !** : operators = (#<syntax#389 * in #817> #<syntax#390 / in #818>
>                    #<syntax#391 % in #819>)
> !** : stack = (+ (* 3 5))
> !** : terms = ()
> !** : operators = (#<syntax#389 * in #817> #<syntax#390 / in #818>
>                    #<syntax#391 % in #819>)
> !** : stack = (2 + (* 3 5))
> !**-generic cond case 1 : stack =(2 + (* 3 5))
> !**-generic : terms =()
> !**-generic : rs =((* 3 5) + 2)
> !*-generic : rv-tms =((* 3 5) + 2)
> !*-generic : terms = ((* 3 5) + 2)
> !*-generic : operator-groups = ((#<syntax#392 + in #820>
>                                  #<syntax#393 - in #821>)
>                                 (#<syntax#394 << in #822>
>                                  #<syntax#395 >> in #823>)
>                                 (#<syntax#396 & in #824>
>                                  #<syntax#397 ∣ in #825>)
>                                 (#<syntax#398 < in #826>
>                                  #<syntax#399 > in #827>
>                                  #<syntax#400 = in #828>
>                                  #<syntax#401 ≠ in #829>
>                                  #<syntax#402 <= in #830>
>                                  #<syntax#403 >= in #831>
>                                  #<syntax#404 <> in #832>)
>                                 (#<syntax#405 and in #833>)
>                                 (#<syntax#406 or in #834>)
>                                 (#<syntax#378 <- in #806>
>                                  #<syntax#379 -> in #807>
>                                  #<syntax#380 ← in #808>
>                                  #<syntax#381 → in #809>
>                                  #<syntax#382 := in #810>
>                                  #<syntax#383 <v in #811>
>                                  #<syntax#384 v> in #812>
>                                  #<syntax#385 ⇜ in #813>
>                                  #<syntax#386 ⇝ in #814>)
>                                 (#<syntax#373 <+ in #801>
>                                  #<syntax#374 +> in #802>
>                                  #<syntax#375 ⥆ in #803>
>                                  #<syntax#376 ⥅ in #804>
>                                  #<syntax#377 :+ in #805>))
>
> !** : terms = ((* 3 5) + 2)
> !** : operators = (#<syntax#392 + in #820> #<syntax#393 - in #821>)
> !** : stack = ()
> !** : terms = (+ 2)
> !** : operators = (#<syntax#392 + in #820> #<syntax#393 - in #821>)
> !** : stack = ((* 3 5))
> !** : terms = (2)
> !** : operators = (#<syntax#392 + in #820> #<syntax#393 - in #821>)
> !** : stack = (+ (* 3 5))
> !** : terms = ()
> !** : operators = (#<syntax#392 + in #820> #<syntax#393 - in #821>)
> !** : stack = ((+ (* 3 5) 2))
> !**-generic cond case 1 : stack =((+ (* 3 5) 2))
> !**-generic : terms =()
> !**-generic : rs =((+ (* 3 5) 2))
> !*-generic : rv-tms =((+ (* 3 5) 2))
> !*-generic : terms = ((+ (* 3 5) 2))
> !*-generic : operator-groups = ((#<syntax#394 << in #822>
>                                  #<syntax#395 >> in #823>)
>                                 (#<syntax#396 & in #824>
>                                  #<syntax#397 ∣ in #825>)
>                                 (#<syntax#398 < in #826>
>                                  #<syntax#399 > in #827>
>                                  #<syntax#400 = in #828>
>                                  #<syntax#401 ≠ in #829>
>                                  #<syntax#402 <= in #830>
>                                  #<syntax#403 >= in #831>
>                                  #<syntax#404 <> in #832>)
>                                 (#<syntax#405 and in #833>)
>                                 (#<syntax#406 or in #834>)
>                                 (#<syntax#378 <- in #806>
>                                  #<syntax#379 -> in #807>
>                                  #<syntax#380 ← in #808>
>                                  #<syntax#381 → in #809>
>                                  #<syntax#382 := in #810>
>                                  #<syntax#383 <v in #811>
>                                  #<syntax#384 v> in #812>
>                                  #<syntax#385 ⇜ in #813>
>                                  #<syntax#386 ⇝ in #814>)
>                                 (#<syntax#373 <+ in #801>
>                                  #<syntax#374 +> in #802>
>                                  #<syntax#375 ⥆ in #803>
>                                  #<syntax#376 ⥅ in #804>
>                                  #<syntax#377 :+ in #805>))
>
>
> 17
>
> it is a long debug display to compute 3 * 5 + 2 = 17
>
> now when i try the computation in a module:
>
> (define-library (test-nfx) ; R7RS
>
>   (import
>  (kawa base)
>
>  (operators-list)
>  (n-arity)
>  (infix-with-precedence-to-prefix)
>  (nfx))
>
>
>   (define x ($nfx$ 3 * 5 + 2))
>   (display x) (newline)
>
> )
>
>
> here is the output:
>
> #|kawa:1|# (import (test-nfx))
> !0-generic : terms=(3 * 5 + 2)
> !0-generic : operator-precedence=((#<syntax#355 expt in #783>
>                                    #<syntax#356 ** in #784>)
>                                   (#<syntax#357 * in #785>
>                                    #<syntax#358 / in #786>
>                                    #<syntax#359 % in #787>)
>                                   (#<syntax#360 + in #788>
>                                    #<syntax#361 - in #789>)
>                                   (#<syntax#362 << in #790>
>                                    #<syntax#363 >> in #791>)
>                                   (#<syntax#364 & in #792>
>                                    #<syntax#365 ∣ in #793>)
>                                   (#<syntax#366 < in #794>
>                                    #<syntax#367 > in #795>
>                                    #<syntax#368 = in #796>
>                                    #<syntax#369 ≠ in #797>
>                                    #<syntax#370 <= in #798>
>                                    #<syntax#371 >= in #799>
>                                    #<syntax#372 <> in #800>)
>                                   (#<syntax#373 and in #801>)
>                                   (#<syntax#374 or in #802>)
>                                   (#<syntax#346 <- in #774>
>                                    #<syntax#347 -> in #775>
>                                    #<syntax#348 ← in #776>
>                                    #<syntax#349 → in #777>
>                                    #<syntax#350 := in #778>
>                                    #<syntax#351 <v in #779>
>                                    #<syntax#352 v> in #780>
>                                    #<syntax#353 ⇜ in #781>
>                                    #<syntax#354 ⇝ in #782>)
>                                   (#<syntax#341 <+ in #769>
>                                    #<syntax#342 +> in #770>
>                                    #<syntax#343 ⥆ in #771>
>                                    #<syntax#344 ⥅ in #772>
>                                    #<syntax#345 :+ in #773>))
> !*-generic : terms = (2 + 5 * 3)
> !*-generic : operator-groups = ((#<syntax#355 expt in #783>
>                                  #<syntax#356 ** in #784>)
>                                 (#<syntax#357 * in #785>
>                                  #<syntax#358 / in #786>
>                                  #<syntax#359 % in #787>)
>                                 (#<syntax#360 + in #788>
>                                  #<syntax#361 - in #789>)
>                                 (#<syntax#362 << in #790>
>                                  #<syntax#363 >> in #791>)
>                                 (#<syntax#364 & in #792>
>                                  #<syntax#365 ∣ in #793>)
>                                 (#<syntax#366 < in #794>
>                                  #<syntax#367 > in #795>
>                                  #<syntax#368 = in #796>
>                                  #<syntax#369 ≠ in #797>
>                                  #<syntax#370 <= in #798>
>                                  #<syntax#371 >= in #799>
>                                  #<syntax#372 <> in #800>)
>                                 (#<syntax#373 and in #801>)
>                                 (#<syntax#374 or in #802>)
>                                 (#<syntax#346 <- in #774>
>                                  #<syntax#347 -> in #775>
>                                  #<syntax#348 ← in #776>
>                                  #<syntax#349 → in #777>
>                                  #<syntax#350 := in #778>
>                                  #<syntax#351 <v in #779>
>                                  #<syntax#352 v> in #780>
>                                  #<syntax#353 ⇜ in #781>
>                                  #<syntax#354 ⇝ in #782>)
>                                 (#<syntax#341 <+ in #769>
>                                  #<syntax#342 +> in #770>
>                                  #<syntax#343 ⥆ in #771>
>                                  #<syntax#344 ⥅ in #772>
>                                  #<syntax#345 :+ in #773>))
>
> !** : terms = (2 + 5 * 3)
> !** : operators = (#<syntax#355 expt in #783> #<syntax#356 ** in #784>)
> !** : stack = ()
> !** : terms = (+ 5 * 3)
> !** : operators = (#<syntax#355 expt in #783> #<syntax#356 ** in #784>)
> !** : stack = (2)
> !** : terms = (5 * 3)
> !** : operators = (#<syntax#355 expt in #783> #<syntax#356 ** in #784>)
> !** : stack = (+ 2)
> !** : terms = (* 3)
> !** : operators = (#<syntax#355 expt in #783> #<syntax#356 ** in #784>)
> !** : stack = (5 + 2)
> !** : terms = (3)
> !** : operators = (#<syntax#355 expt in #783> #<syntax#356 ** in #784>)
> !** : stack = (* 5 + 2)
> !** : terms = ()
> !** : operators = (#<syntax#355 expt in #783> #<syntax#356 ** in #784>)
> !** : stack = (3 * 5 + 2)
> !**-generic cond case 2 : stack =(3 * 5 + 2)
> !**-generic : terms =()
> !*-generic : rv-tms =(3 * 5 + 2)
> !*-generic : terms = (3 * 5 + 2)
> !*-generic : operator-groups = ((#<syntax#357 * in #785>
>                                  #<syntax#358 / in #786>
>                                  #<syntax#359 % in #787>)
>                                 (#<syntax#360 + in #788>
>                                  #<syntax#361 - in #789>)
>                                 (#<syntax#362 << in #790>
>                                  #<syntax#363 >> in #791>)
>                                 (#<syntax#364 & in #792>
>                                  #<syntax#365 ∣ in #793>)
>                                 (#<syntax#366 < in #794>
>                                  #<syntax#367 > in #795>
>                                  #<syntax#368 = in #796>
>                                  #<syntax#369 ≠ in #797>
>                                  #<syntax#370 <= in #798>
>                                  #<syntax#371 >= in #799>
>                                  #<syntax#372 <> in #800>)
>                                 (#<syntax#373 and in #801>)
>                                 (#<syntax#374 or in #802>)
>                                 (#<syntax#346 <- in #774>
>                                  #<syntax#347 -> in #775>
>                                  #<syntax#348 ← in #776>
>                                  #<syntax#349 → in #777>
>                                  #<syntax#350 := in #778>
>                                  #<syntax#351 <v in #779>
>                                  #<syntax#352 v> in #780>
>                                  #<syntax#353 ⇜ in #781>
>                                  #<syntax#354 ⇝ in #782>)
>                                 (#<syntax#341 <+ in #769>
>                                  #<syntax#342 +> in #770>
>                                  #<syntax#343 ⥆ in #771>
>                                  #<syntax#344 ⥅ in #772>
>                                  #<syntax#345 :+ in #773>))
>
> !** : terms = (3 * 5 + 2)
> !** : operators = (#<syntax#357 * in #785> #<syntax#358 / in #786>
>                    #<syntax#359 % in #787>)
> !** : stack = ()
> !** : terms = (* 5 + 2)
> !** : operators = (#<syntax#357 * in #785> #<syntax#358 / in #786>
>                    #<syntax#359 % in #787>)
> !** : stack = (3)
> !** : terms = (5 + 2)
> !** : operators = (#<syntax#357 * in #785> #<syntax#358 / in #786>
>                    #<syntax#359 % in #787>)
> !** : stack = (* 3)
> !** : terms = (+ 2)
> !** : operators = (#<syntax#357 * in #785> #<syntax#358 / in #786>
>                    #<syntax#359 % in #787>)
> !** : stack = ((* 3 5))
> !** : terms = (2)
> !** : operators = (#<syntax#357 * in #785> #<syntax#358 / in #786>
>                    #<syntax#359 % in #787>)
> !** : stack = (+ (* 3 5))
> !** : terms = ()
> !** : operators = (#<syntax#357 * in #785> #<syntax#358 / in #786>
>                    #<syntax#359 % in #787>)
> !** : stack = (2 + (* 3 5))
> !**-generic cond case 1 : stack =(2 + (* 3 5))
> !**-generic : terms =()
> !**-generic : rs =((* 3 5) + 2)
> !*-generic : rv-tms =151 3 168 13 151 14 25 7473stack7459 151 3 168 13 152
> 6 17 7479terms7458 151 3 168 13 153 6 18 7485stack7459 151 3 168 13 156 12
> 157 42 156 16 38 7498operators7460 7501x7475 7502x7475 156 12 157 42
> 7504member-syntax7445 157 24 30ClassType
> kawa.lang.TemplateScope7507null7477 7508operators7460 158 10 31
> 7509calc-generic7462 7511op7471 7512b7472 7513a7473 159 10 31
> 7514calc-generic7462 7516op7471 7517a7473 7518b7472 163 5 168 12
> 7520!**-generic7449 163 18 29 7524terms7458ClassType gnu.lists.Pair164 4
> 165 23 7527calculus7474 165 10 22 7530stack7459 7531operators7460
> 7532creator7461(Let#662 line::-: ((op#7471/fl:40042 = (Apply line::- (Quote
> ClassType java.lang.Object kawa.lib.lists.car(gnu.lists.Pair)
> ::gnu.expr.PrimProcedure) (Ref//#)))) (Let#665 line::-: ((b#7472/fl:40042 =
> (Apply line::- (Quote ClassType java.lang.Object
> kawa.lib.lists.car(gnu.lists.Pair) ::gnu.expr.PrimProcedure) (Ref//#))))
> (Let#668 line::-: ((a#7473/fl:40042 = (Apply line::- (Quote ClassType
> java.lang.Object kawa.lib.lists.cadr(java.lang.Object)
> ::gnu.expr.PrimProcedure) (Ref//#)))) (Let#671 line::-:
> ((calculus#7474/fl:40042 = (Let#675 line::-: ((x#7475/fl:40042 = (Apply
> line::- (Quote ClassType java.lang.Object
> kawa.lib.lists.memq(java.lang.Object,java.lang.Object)
> ::gnu.expr.PrimProcedure) (Quote expt ::gnu.mapping.SimpleSymbol)
> (Ref//#)))) (If (If (Ref//#) (Ref//#) (Apply line::-: (Ref//#) (Let#681
> line::- ((null#7477/fl:42::kawa.lang.TemplateScope = (Apply =>  (Quote
> ClassType kawa.lang.TemplateScope kawa.lang.TemplateScope.make()
> ::gnu.expr.PrimProcedure)))) (Apply (Quote ClassType java.lang.Object
> kawa.lang.SyntaxTemplate.execute(java.lang.Object[],kawa.lang.TemplateScope)
> ::gnu.expr.PrimProcedure) (Quote kawa.lang.SyntaxTemplate@55120f99
> ::kawa.lang.SyntaxTemplate) (Quote #!null ::(type of null)) (Ref//#)))
> (Ref//#))) (Apply line::- (Ref//#) (Ref//#) (Ref//#) (Ref//#)) (Apply
> line::- (Ref//#) (Ref//#) (Ref//#) (Ref//#)))))) (Apply [tailcall] line::-:
> (Ref//#) (Apply line::- (Quote ClassType java.lang.Object
> kawa.lib.lists.cdr(gnu.lists.Pair) ::gnu.expr.PrimProcedure) (Ref//#))
> (Apply =>  line::-: (Quote ClassType gnu.lists.Pair
> kawa.lib.lists.cons(java.lang.Object,java.lang.Object)
> ::gnu.expr.PrimProcedure) (Ref//#) (Apply line::- (Quote ClassType
> java.lang.Object kawa.lib.lists.cddr(java.lang.Object)
> ::gnu.expr.PrimProcedure) (Ref//#))) (Ref//#) (Ref//#))))))
> !*-generic : terms = 151 3 168 13 151 14 25 7473stack7459 151 3 168 13 152
> 6 17 7479terms7458 151 3 168 13 153 6 18 7485stack7459 151 3 168 13 156 12
> 157 42 156 16 38 7498operators7460 7501x7475 7502x7475 156 12 157 42
> 7504member-syntax7445 157 24 30ClassType
> kawa.lang.TemplateScope7507null7477 7508operators7460 158 10 31
> 7509calc-generic7462 7511op7471 7512b7472 7513a7473 159 10 31
> 7514calc-generic7462 7516op7471 7517a7473 7518b7472 163 5 168 12
> 7520!**-generic7449 163 18 29 7524terms7458ClassType gnu.lists.Pair164 4
> 165 23 7527calculus7474 165 10 22 7530stack7459 7531operators7460
> 7532creator7461(Let#662 line::-: ((op#7471/fl:40042 = (Apply line::- (Quote
> ClassType java.lang.Object kawa.lib.lists.car(gnu.lists.Pair)
> ::gnu.expr.PrimProcedure) (Ref//#)))) (Let#665 line::-: ((b#7472/fl:40042 =
> (Apply line::- (Quote ClassType java.lang.Object
> kawa.lib.lists.car(gnu.lists.Pair) ::gnu.expr.PrimProcedure) (Ref//#))))
> (Let#668 line::-: ((a#7473/fl:40042 = (Apply line::- (Quote ClassType
> java.lang.Object kawa.lib.lists.cadr(java.lang.Object)
> ::gnu.expr.PrimProcedure) (Ref//#)))) (Let#671 line::-:
> ((calculus#7474/fl:40042 = (Let#675 line::-: ((x#7475/fl:40042 = (Apply
> line::- (Quote ClassType java.lang.Object
> kawa.lib.lists.memq(java.lang.Object,java.lang.Object)
> ::gnu.expr.PrimProcedure) (Quote expt ::gnu.mapping.SimpleSymbol)
> (Ref//#)))) (If (If (Ref//#) (Ref//#) (Apply line::-: (Ref//#) (Let#681
> line::- ((null#7477/fl:42::kawa.lang.TemplateScope = (Apply =>  (Quote
> ClassType kawa.lang.TemplateScope kawa.lang.TemplateScope.make()
> ::gnu.expr.PrimProcedure)))) (Apply (Quote ClassType java.lang.Object
> kawa.lang.SyntaxTemplate.execute(java.lang.Object[],kawa.lang.TemplateScope)
> ::gnu.expr.PrimProcedure) (Quote kawa.lang.SyntaxTemplate@55120f99
> ::kawa.lang.SyntaxTemplate) (Quote #!null ::(type of null)) (Ref//#)))
> (Ref//#))) (Apply line::- (Ref//#) (Ref//#) (Ref//#) (Ref//#)) (Apply
> line::- (Ref//#) (Ref//#) (Ref//#) (Ref//#)))))) (Apply [tailcall] line::-:
> (Ref//#) (Apply line::- (Quote ClassType java.lang.Object
> kawa.lib.lists.cdr(gnu.lists.Pair) ::gnu.expr.PrimProcedure) (Ref//#))
> (Apply =>  line::-: (Quote ClassType gnu.lists.Pair
> kawa.lib.lists.cons(java.lang.Object,java.lang.Object)
> ::gnu.expr.PrimProcedure) (Ref//#) (Apply line::- (Quote ClassType
> java.lang.Object kawa.lib.lists.cddr(java.lang.Object)
> ::gnu.expr.PrimProcedure) (Ref//#))) (Ref//#) (Ref//#))))))
> !*-generic : operator-groups = ((#<syntax#360 + in #788>
>                                  #<syntax#361 - in #789>)
>                                 (#<syntax#362 << in #790>
>                                  #<syntax#363 >> in #791>)
>                                 (#<syntax#364 & in #792>
>                                  #<syntax#365 ∣ in #793>)
>                                 (#<syntax#366 < in #794>
>                                  #<syntax#367 > in #795>
>                                  #<syntax#368 = in #796>
>                                  #<syntax#369 ≠ in #797>
>                                  #<syntax#370 <= in #798>
>                                  #<syntax#371 >= in #799>
>                                  #<syntax#372 <> in #800>)
>                                 (#<syntax#373 and in #801>)
>                                 (#<syntax#374 or in #802>)
>                                 (#<syntax#346 <- in #774>
>                                  #<syntax#347 -> in #775>
>                                  #<syntax#348 ← in #776>
>                                  #<syntax#349 → in #777>
>                                  #<syntax#350 := in #778>
>                                  #<syntax#351 <v in #779>
>                                  #<syntax#352 v> in #780>
>                                  #<syntax#353 ⇜ in #781>
>                                  #<syntax#354 ⇝ in #782>)
>                                 (#<syntax#341 <+ in #769>
>                                  #<syntax#342 +> in #770>
>                                  #<syntax#343 ⥆ in #771>
>                                  #<syntax#344 ⥅ in #772>
>                                  #<syntax#345 :+ in #773>))
>
> (import (test-nfx))
> /Users/mattei/Scheme-PLUS-for-Kawa/test-nfx.scm:15:13: evaluating syntax
> transformer '$nfx$' threw Argument #1 (null) to 'cdr' has wrong type
> (expected: gnu.lists.Pair)
>     gnu.mapping.CallContext.matchError(CallContext.java:185)
>     gnu.expr.PrimProcedure.applyToConsumerX(PrimProcedure.java:250)
>     gnu.expr.PrimProcedure.applyToConsumer(PrimProcedure.java:189)
>     gnu.mapping.CallContext.runUntilDone(CallContext.java:586)
>     gnu.mapping.CallContext.getFromContext(CallContext.java:616)
>     gnu.expr.Expression.eval(Expression.java:52)
>     gnu.expr.ApplyExp.apply(ApplyExp.java:161)
>     gnu.expr.IfExp.apply(IfExp.java:43)
>     gnu.expr.Expression.applyMethodExpression(Expression.java:41)
>     gnu.mapping.CallContext.runUntilDone(CallContext.java:586)
>     gnu.mapping.CallContext.getFromContext(CallContext.java:616)
>     gnu.expr.Expression.eval(Expression.java:52)
>     gnu.expr.IfExp.apply(IfExp.java:40)
>     gnu.expr.LetExp.apply(LetExp.java:72)
>     gnu.expr.BeginExp.apply(BeginExp.java:123)
>     gnu.expr.LambdaExp$Closure.applyToConsumer(LambdaExp.java:2144)
>     gnu.mapping.CallContext.runUntilDone(CallContext.java:586)
>     gnu.mapping.CallContext.getFromContext(CallContext.java:616)
>     gnu.expr.Expression.eval(Expression.java:52)
>     gnu.expr.ApplyExp.apply(ApplyExp.java:161)
>     gnu.expr.IfExp.apply(IfExp.java:43)
>     gnu.expr.Expression.applyMethodExpression(Expression.java:41)
>     gnu.mapping.CallContext.runUntilDone(CallContext.java:586)
>     gnu.mapping.CallContext.getFromContext(CallContext.java:616)
>     gnu.expr.Expression.eval(Expression.java:52)
>     gnu.expr.Expression.eval(Expression.java:67)
>     gnu.expr.SetExp.apply(SetExp.java:108)
>     gnu.expr.Expression.applyMethodExpression(Expression.java:41)
>     gnu.mapping.CallContext.runUntilDone(CallContext.java:586)
>     gnu.mapping.CallContext.getFromContext(CallContext.java:616)
>     gnu.expr.Expression.eval(Expression.java:52)
>     gnu.expr.BeginExp.apply(BeginExp.java:117)
>     gnu.expr.LetExp.apply(LetExp.java:72)
>     gnu.expr.LambdaExp$Closure.applyToConsumer(LambdaExp.java:2144)
>     gnu.mapping.CallContext.runUntilDone(CallContext.java:586)
>     gnu.mapping.CallContext.getFromContext(CallContext.java:616)
>     gnu.expr.Expression.eval(Expression.java:52)
>     gnu.expr.ApplyExp.apply(ApplyExp.java:161)
>     gnu.expr.BeginExp.apply(BeginExp.java:123)
>     gnu.expr.LetExp.apply(LetExp.java:72)
>     gnu.expr.Expression.applyMethodExpression(Expression.java:41)
>     gnu.mapping.CallContext.runUntilDone(CallContext.java:586)
>     gnu.mapping.CallContext.getFromContext(CallContext.java:616)
>     gnu.expr.Expression.eval(Expression.java:52)
>     gnu.expr.LetExp.evalVariable(LetExp.java:26)
>     gnu.expr.LetExp.apply(LetExp.java:60)
>     gnu.expr.LetExp.apply(LetExp.java:72)
>     gnu.expr.IfExp.apply(IfExp.java:41)
>     gnu.expr.Expression.applyMethodExpression(Expression.java:41)
>     gnu.mapping.CallContext.runUntilDone(CallContext.java:586)
>     gnu.mapping.CallContext.getFromContext(CallContext.java:616)
>     gnu.expr.Expression.eval(Expression.java:52)
>     gnu.expr.BlockExp.apply(BlockExp.java:58)
>     gnu.expr.LetExp.apply(LetExp.java:72)
>     gnu.expr.LetExp.apply(LetExp.java:72)
>     gnu.expr.LambdaExp$Closure.applyToConsumer(LambdaExp.java:2144)
>     gnu.mapping.CallContext.runUntilDone(CallContext.java:586)
>     gnu.mapping.CallContext.runUntilValue(CallContext.java:669)
>     gnu.mapping.Procedure.apply1(Procedure.java:154)
>     kawa.lang.Macro.expand(Macro.java:205)
>     kawa.lang.Macro.rewriteForm(Macro.java:107)
>     kawa.lang.Translator.apply_rewrite(Translator.java:181)
>     kawa.lang.Translator.rewrite_pair(Translator.java:408)
>     kawa.lang.Translator.rewrite(Translator.java:798)
>     kawa.lang.Translator.rewrite(Translator.java:778)
>     kawa.lang.Translator.rewrite_with_position(Translator.java:1475)
>     kawa.lang.Translator.rewrite_car(Translator.java:136)
>     kawa.standard.define.rewriteForm(define.java:265)
>     kawa.lang.Translator.apply_rewrite(Translator.java:181)
>     kawa.lang.Translator.rewrite_pair(Translator.java:361)
>     kawa.lang.Translator.rewrite(Translator.java:798)
>     kawa.lang.Translator.rewrite(Translator.java:778)
>     kawa.lang.Translator.rewriteInBody(Translator.java:708)
>     kawa.lang.Translator.rewriteBody(Translator.java:1778)
>     kawa.lang.Translator.resolveModule(Translator.java:1959)
>     gnu.kawa.lispexpr.LispLanguage.resolve(LispLanguage.java:154)
>     gnu.expr.Compilation.process(Compilation.java:1754)
>     gnu.expr.ModuleInfo.loadEager(ModuleInfo.java:337)
>     kawa.standard.require.importDefinitions(require.java:289)
>
> kawa.standard.ImportFromLibrary.handleImport(ImportFromLibrary.java:486)
>
> kawa.standard.ImportFromLibrary.scanImportSet1(ImportFromLibrary.java:295)
>
> kawa.standard.ImportFromLibrary.scanImportSet(ImportFromLibrary.java:263)
>     kawa.standard.ImportFromLibrary.scanForm(ImportFromLibrary.java:96)
>     kawa.lang.Translator.scanForm(Translator.java:1623)
>     kawa.lang.Translator.scanBody(Translator.java:1680)
>     kawa.standard.begin.scanForm(begin.java:23)
>     kawa.lang.Translator.scanForm(Translator.java:1623)
>     gnu.kawa.lispexpr.LispLanguage.parse(LispLanguage.java:117)
>     gnu.expr.Language.parse(Language.java:765)
>     gnu.expr.Language.parse(Language.java:759)
>     gnu.kawa.io.JLineInPort.parse(JLineInPort.java:97)
>
> org.jline.reader.impl.LineReaderImpl.acceptLine(LineReaderImpl.java:2982)
>     org.jline.reader.impl.LineReaderImpl$1.apply(LineReaderImpl.java:3796)
>     org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:665)
>     org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:454)
>     gnu.kawa.io.JLineInPort$KawaParsedLine.parse(JLineInPort.java:292)
>
> java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
>     java.base/java.lang.reflect.Method.invoke(Method.java:580)
>     kawa.Shell.run(Shell.java:261)
>     kawa.Shell.run(Shell.java:196)
>     kawa.Shell.run(Shell.java:183)
>     kawa.repl.processArgs(repl.java:724)
>     kawa.repl.main(repl.java:830)
>
> the display dump show that , the called procedure !**-generic compute well
> the result but when the result is send to the calling procedure !*-generic
> it changed:
> the called procedure !**-generic return rs =((* 3 5) + 2)
> and the calling procedure !*-generic get : rv-tms =151 3 168 13 151 14 25
> 7473stack7459 151 3 ........
>
>
> !**-generic : rs =((* 3 5) + 2)
> !*-generic : rv-tms =151 3 168 13 151 14 25 7473stack7459 151 3 168 13 152
> 6 17 7479terms7458 151 3 168 13 153 6 18 7485stack7459 151 3 168 13 156 12
> 157 42 156 16 38 7498operators7460 7501x7475 7502x7475 156 12 157 42
> 7504member-syntax7445 157 24 30ClassType
> kawa.lang.TemplateScope7507null7477 7508operators7460 158 10 31
> 7509calc-generic7462 7511op7471 7512b7472 7513a7473 159 10 31
> 7514calc-generic7462 7516op7471 7517a7473 7518b7472 163 5 168 12
> 7520!**-generic7449 163 18 29 7524terms7458ClassType gnu.lists.Pair164 4
> 165 23 7527calculus7474 165 10 22 7530stack7459 7531operators7460
> 7532creator7461(Let#662 line::-: ((op#7471/fl:40042 = (Apply line::- (Quote
> ClassType java.lang.Object kawa.lib.lists.car(gnu.lists.Pair)
> ::gnu.expr.PrimProcedure) (Ref//#)))) (Let#665 line::-: ((b#7472/fl:40042 =
> (Apply line::- (Quote ClassType java.lang.Object
> kawa.lib.lists.car(gnu.lists.Pair) ::gnu.expr.PrimProcedure) (Ref//#))))
> (Let#668 line::-: ((a#7473/fl:40042 = (Apply line::- (Quote ClassType
> java.lang.Object kawa.lib.lists.cadr(java.lang.Object)
> ::gnu.expr.PrimProcedure) (Ref//#)))) (Let#671 line::-:
> ((calculus#7474/fl:40042 = (Let#675 line::-: ((x#7475/fl:40042 = (Apply
> line::- (Quote ClassType java.lang.Object
> kawa.lib.lists.memq(java.lang.Object,java.lang.Object)
> ::gnu.expr.PrimProcedure) (Quote expt ::gnu.mapping.SimpleSymbol)
> (Ref//#)))) (If (If (Ref//#) (Ref//#) (Apply line::-: (Ref//#) (Let#681
> line::- ((null#7477/fl:42::kawa.lang.TemplateScope = (Apply =>  (Quote
> ClassType kawa.lang.TemplateScope kawa.lang.TemplateScope.make()
> ::gnu.expr.PrimProcedure)))) (Apply (Quote ClassType java.lang.Object
> kawa.lang.SyntaxTemplate.execute(java.lang.Object[],kawa.lang.TemplateScope)
> ::gnu.expr.PrimProcedure) (Quote kawa.lang.SyntaxTemplate@55120f99
> ::kawa.lang.SyntaxTemplate) (Quote #!null ::(type of null)) (Ref//#)))
> (Ref//#))) (Apply line::- (Ref//#) (Ref//#) (Ref//#) (Ref//#)) (Apply
> line::- (Ref//#) (Ref//#) (Ref//#) (Ref//#)))))) (Apply [tailcall] line::-:
> (Ref//#) (Apply line::- (Quote ClassType java.lang.Object
> kawa.lib.lists.cdr(gnu.lists.Pair) ::gnu.expr.PrimProcedure) (Ref//#))
> (Apply =>  line::-: (Quote ClassType gnu.lists.Pair
> kawa.lib.lists.cons(java.lang.Object,java.lang.Object)
> ::gnu.expr.PrimProcedure) (Ref//#) (Apply line::- (Quote ClassType
> java.lang.Object kawa.lib.lists.cddr(java.lang.Object)
> ::gnu.expr.PrimProcedure) (Ref//#))) (Ref//#) (Ref//#))))))
>
> i post this in hope the problem could be fixed, that should not be very
> hard as it is working in REPL but not in module and only with syntax
> transformer use
>
> if i want a way to avoid the problem i will post it
>
> regards,
>
> damien
>
>

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

* Re: bug in kawa syntax transformer?
  2024-06-29  9:03 ` Damien Mattei
@ 2024-06-29 14:16   ` Per Bothner
  2024-06-29 15:32     ` Damien Mattei
  0 siblings, 1 reply; 7+ messages in thread
From: Per Bothner @ 2024-06-29 14:16 UTC (permalink / raw)
  To: Damien Mattei, kawa mailing list

Perhaps - or perhaps it depends on unspecified behavior.

In any case, I think you're going to have to debug this on your own.

On 6/29/24 2:03 AM, Damien Mattei via Kawa wrote:
> i'm sure it is a kawa bug because i ported all the code to Guile and it
> works perfectly.

-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

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

* Re: bug in kawa syntax transformer?
  2024-06-29 14:16   ` Per Bothner
@ 2024-06-29 15:32     ` Damien Mattei
  2024-06-30 20:56       ` Damien Mattei
  2024-07-01  8:54       ` Damien Mattei
  0 siblings, 2 replies; 7+ messages in thread
From: Damien Mattei @ 2024-06-29 15:32 UTC (permalink / raw)
  To: Per Bothner; +Cc: kawa mailing list

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

i find a way to make it run, i wanted to post the answer later....

it works now.

in summary the solution is:

for a module test-foo that use module foo you have to:

be at REPL and:

(import (foo))

(import (test-foo))

and it is ok.

but it is not the normal behavior , because as foo is already imported by
test-foo the module should works without also importing foo in REPL

example:

test-nfx.scm:

(define-library (test-nfx) ; R7RS

  (import
 (kawa base)

 (operators-list)
 (n-arity)
 (infix-with-precedence-to-prefix)
 (nfx))


  (define x ($nfx$ 3 * 5 + 2))
  (display x) (newline)

)

#|kawa:1|# (import (nfx))
#|kawa:2|# ($nfx$ 3 * 5 + 2)
17
#|kawa:3|# (import (test-nfx))
17


another example:

#|kawa:1|# (import (Scheme+))
#|kawa:2|#
#|kawa:3|# (bracket-apply #(1 2 3 4 5) 2)
bracket-apply : #'parsed-args=(#<syntax#2463 list in #3590> 2)
(bracket-apply #(1 2 3 4 5) 2)
3
#|kawa:4|# ($nfx$ 3 * 5 + 2)
17
#|kawa:5|# (exit)

for a whole program that use Scheme+:

#|kawa:1|# (import (Scheme+))

#|kawa:2|# (load
"exo_retropropagationNhidden_layers_matrix_v2_by_vectors4kawa.scm")

################## NOT ##################
*init* : nc=#(1 2 1)
z=#(#(0) #(0 0) #(0))
z̃=#(#(0) #(0 0) #(0))
define-overload-existing-operator : proc =#<procedure *>
define-overload-existing-operator : orig-proc =#<procedure *>
M=#(matrix@3811464b matrix@5f0a5848)
ᐁ=#(#(0) #(0 0) #(0))
nbiter=5000
exo_retropropagationNhidden_layers_matrix_v2_by_vectors4kawa.scm:145:2:
warning - no known slot 'apprentissage' in java.lang.Object
0
1000
2000
3000
4000
exo_retropropagationNhidden_layers_matrix_v2_by_vectors4kawa.scm:147:2:
warning - no known slot 'test' in java.lang.Object
Test des exemples :
#(1) --> #(0.005218051056863006) : on attendait #(0)
#(0) --> #(0.9937685906977904) : on attendait #(1)
Error on examples=3.3029259361846465E-5

################## XOR ##################
*init* : nc=#(2 8 1)
z=#(#(0 0) #(0 0 0 0 0 0 0 0) #(0))
z̃=#(#(0 0) #(0 0 0 0 0 0 0 0) #(0))
M=#(matrix@7fb313e3 matrix@771ede0d)
ᐁ=#(#(0 0) #(0 0 0 0 0 0 0 0) #(0))
nbiter=250000
exo_retropropagationNhidden_layers_matrix_v2_by_vectors4kawa.scm:160:2:
warning - no known slot 'apprentissage' in java.lang.Object
exo_retropropagationNhidden_layers_matrix_v2_by_vectors4kawa.scm:162:2:
warning - no known slot 'test' in java.lang.Object
Test des exemples :
#(1 0) --> #(0.9869979600720541) : on attendait #(1)
#(0 0) --> #(0.009586857552488845) : on attendait #(0)
#(0 1) --> #(0.9875938547018659) : on attendait #(1)
#(1 1) --> #(0.015785460599146515) : on attendait #(0)
Error on examples=3.32027043752617E-4

################## SINE ##################
*init* : nc=#(1 70 70 1)

but perheaps there is a solution with playing with import/require,
Kawa/R7RS  i will test any possible combinaison (? do not know the english
term)

the problem only happen with syntax transformer, if not , i would have
noticed already......or someone else....

Damien

On Sat, Jun 29, 2024 at 4:17 PM Per Bothner <per@bothner.com> wrote:

> Perhaps - or perhaps it depends on unspecified behavior.
>
> In any case, I think you're going to have to debug this on your own.
>
> On 6/29/24 2:03 AM, Damien Mattei via Kawa wrote:
> > i'm sure it is a kawa bug because i ported all the code to Guile and it
> > works perfectly.
>
> --
>         --Per Bothner
> per@bothner.com   http://per.bothner.com/
>

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

* Re: bug in kawa syntax transformer?
  2024-06-29 15:32     ` Damien Mattei
@ 2024-06-30 20:56       ` Damien Mattei
  2024-07-01  8:54       ` Damien Mattei
  1 sibling, 0 replies; 7+ messages in thread
From: Damien Mattei @ 2024-06-30 20:56 UTC (permalink / raw)
  To: Per Bothner, kawa mailing list

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

short answer:

there is a difference (that make crash and fail) between:
using (module-name "matrix") or (define-library (matrix) the r7rs style
,here the example (beginning of code only...):

(module-name "matrix")

;(define-library (matrix)

(export multiply-matrix-matrix
multiply-matrix-vector
matrix
matrix-v
create-matrix-by-function
dim-matrix
matrix-ref
matrix-set!
matrix-line-ref
matrix-line-set!
vector->matrix-column
matrix-column->vector

;;$ovrld-ht$
*
)

(import (Scheme+)
        (array))

;; first stage overloading
;(define orig* *)
(import (only (scheme base) (* orig*)))

(define-overload-existing-operator * orig*)


;; (matrix #(1 2 3))
;; matrix@4612b856


(define-simple-class matrix ()

  (v :: vector)

  ((*init* (vParam :: vector))
   (set! v vParam))

  )
....


long and truncated answer because i'm still investigating....

but it is better ,i was able to (load "program") without before (import
(Scheme+)) i will test moving all my modules with (module-name
"name-of-module") instead of the R7RS style... :

it is better, what is working and not:

(define-library (test-nfx) ; R7RS

  (import
 (kawa base)

 (operators-list)
 (n-arity)
 (infix-with-precedence-to-prefix)
 (nfx)
 )


  (define x ($nfx$ 3 * 5 + 2))
  (display x) (newline)

)

not working

but this works:

(require operators-list)
(require n-arity)
(require infix-with-precedence-to-prefix)
(require nfx)



  (define x ($nfx$ 3 * 5 + 2))
  (display x) (newline)


#|kawa:2|# (load "test-nfx-require.scm")
17


and also this:

#|kawa:1|# (load "test-nfx.scm")
17

in a program "loaded" with "load" this fails:

(require matrix)
(require Scheme+)

(require array)

;; first stage overloading
(import (only (kawa base) (+ orig+))) ; (* orig*)))


but this works:
(require Scheme+)
(require matrix)
(require array)

;; first stage overloading
(import (only (kawa base) (+ orig+))) ; (* orig*)))

so the order matters

but this fails in any order:
(import (Scheme+)
            (matrix)
            (array))

;; first stage overloading
(import (only (kawa base) (+ orig+))) ; (* orig*)))

but the modules works well as they are defined in R7RS:

;; use :

;;(import (Scheme+))
;; or :
;;(require Scheme+)


;;(module-name Scheme+)

(define-library (Scheme+) ; R7RS

  (import ;;(kawa base)
   ;;(only (scheme base) (do do-scheme)) ; only imports and rename do in
do-scheme
   (rename (kawa base) (do do-scheme)
              (if if-scheme)) ; standard imports and rename do in do-scheme
   (srfi 1) ; first ...
   (srfi 69); hash table
   (array)
   (for_next_step)
   (overload)

   (assignment)
   (bitwise)
   (block)
   (bracket-apply)
   (condx)
   (declare)
   (def)
   (exponential)
   (increment)
   (modulo)
   (nfx)
   (not-equal)
   (range)
   (repeat-until)
   (slice)
   (while-do)
   (if-then-else)

   ) ; end import




(export def
bracket-apply
;;$bracket-apply$next
: ;; $  see slice.scm
for
for-basic
for-next
for-basic/break
for-basic/break-cont
for/break-cont
for-each-in
in-range
reversed
<- ← :=
-> →
<+ ⥆ :+
+> ⥅
declare
$>
$+>
condx
<> ;; should not be compatible with 'cut' (srfi 26)
≠
**
<v v>
⇜ ⇝
repeat while do
if
%
<< >>
& ∣
$nfx$ ;;!*prec

$ovrld-ht$

define-overload-procedure
overload-procedure

define-overload-existing-procedure
overload-existing-procedure

define-overload-operator
overload-operator

define-overload-existing-operator
overload-existing-operator

define-overload-n-arity-operator
overload-n-arity-operator

define-overload-existing-n-arity-operator
overload-existing-n-arity-operator

;;overload-function

;;$ovrld-square-brackets-lst$

overload-square-brackets
;;find-getter-and-setter-for-overloaded-square-brackets
find-getter-for-overloaded-square-brackets
find-setter-for-overloaded-square-brackets

;;infix-operators-lst
;;set-infix-operators-lst!
;;replace-operator!
;;insert-operator!

) ; end export



) ; end module









On Sat, Jun 29, 2024 at 5:32 PM Damien Mattei <damien.mattei@gmail.com>
wrote:

> i find a way to make it run, i wanted to post the answer later....
>
> it works now.
>
> in summary the solution is:
>
> for a module test-foo that use module foo you have to:
>
> be at REPL and:
>
> (import (foo))
>
> (import (test-foo))
>
> and it is ok.
>
> but it is not the normal behavior , because as foo is already imported by
> test-foo the module should works without also importing foo in REPL
>
> example:
>
> test-nfx.scm:
>
> (define-library (test-nfx) ; R7RS
>
>   (import
>  (kawa base)
>
>  (operators-list)
>  (n-arity)
>  (infix-with-precedence-to-prefix)
>  (nfx))
>
>
>   (define x ($nfx$ 3 * 5 + 2))
>   (display x) (newline)
>
> )
>
> #|kawa:1|# (import (nfx))
> #|kawa:2|# ($nfx$ 3 * 5 + 2)
> 17
> #|kawa:3|# (import (test-nfx))
> 17
>
>
> another example:
>
> #|kawa:1|# (import (Scheme+))
> #|kawa:2|#
> #|kawa:3|# (bracket-apply #(1 2 3 4 5) 2)
> bracket-apply : #'parsed-args=(#<syntax#2463 list in #3590> 2)
> (bracket-apply #(1 2 3 4 5) 2)
> 3
> #|kawa:4|# ($nfx$ 3 * 5 + 2)
> 17
> #|kawa:5|# (exit)
>
> for a whole program that use Scheme+:
>
> #|kawa:1|# (import (Scheme+))
>
> #|kawa:2|# (load
> "exo_retropropagationNhidden_layers_matrix_v2_by_vectors4kawa.scm")
>
> ################## NOT ##################
> *init* : nc=#(1 2 1)
> z=#(#(0) #(0 0) #(0))
> z̃=#(#(0) #(0 0) #(0))
> define-overload-existing-operator : proc =#<procedure *>
> define-overload-existing-operator : orig-proc =#<procedure *>
> M=#(matrix@3811464b matrix@5f0a5848)
> ᐁ=#(#(0) #(0 0) #(0))
> nbiter=5000
> exo_retropropagationNhidden_layers_matrix_v2_by_vectors4kawa.scm:145:2:
> warning - no known slot 'apprentissage' in java.lang.Object
> 0
> 1000
> 2000
> 3000
> 4000
> exo_retropropagationNhidden_layers_matrix_v2_by_vectors4kawa.scm:147:2:
> warning - no known slot 'test' in java.lang.Object
> Test des exemples :
> #(1) --> #(0.005218051056863006) : on attendait #(0)
> #(0) --> #(0.9937685906977904) : on attendait #(1)
> Error on examples=3.3029259361846465E-5
>
> ################## XOR ##################
> *init* : nc=#(2 8 1)
> z=#(#(0 0) #(0 0 0 0 0 0 0 0) #(0))
> z̃=#(#(0 0) #(0 0 0 0 0 0 0 0) #(0))
> M=#(matrix@7fb313e3 matrix@771ede0d)
> ᐁ=#(#(0 0) #(0 0 0 0 0 0 0 0) #(0))
> nbiter=250000
> exo_retropropagationNhidden_layers_matrix_v2_by_vectors4kawa.scm:160:2:
> warning - no known slot 'apprentissage' in java.lang.Object
> exo_retropropagationNhidden_layers_matrix_v2_by_vectors4kawa.scm:162:2:
> warning - no known slot 'test' in java.lang.Object
> Test des exemples :
> #(1 0) --> #(0.9869979600720541) : on attendait #(1)
> #(0 0) --> #(0.009586857552488845) : on attendait #(0)
> #(0 1) --> #(0.9875938547018659) : on attendait #(1)
> #(1 1) --> #(0.015785460599146515) : on attendait #(0)
> Error on examples=3.32027043752617E-4
>
> ################## SINE ##################
> *init* : nc=#(1 70 70 1)
>
> but perheaps there is a solution with playing with import/require,
> Kawa/R7RS  i will test any possible combinaison (? do not know the english
> term)
>
> the problem only happen with syntax transformer, if not , i would have
> noticed already......or someone else....
>
> Damien
>
> On Sat, Jun 29, 2024 at 4:17 PM Per Bothner <per@bothner.com> wrote:
>
>> Perhaps - or perhaps it depends on unspecified behavior.
>>
>> In any case, I think you're going to have to debug this on your own.
>>
>> On 6/29/24 2:03 AM, Damien Mattei via Kawa wrote:
>> > i'm sure it is a kawa bug because i ported all the code to Guile and it
>> > works perfectly.
>>
>> --
>>         --Per Bothner
>> per@bothner.com   http://per.bothner.com/
>>
>

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

* Re: bug in kawa syntax transformer?
  2024-06-29 15:32     ` Damien Mattei
  2024-06-30 20:56       ` Damien Mattei
@ 2024-07-01  8:54       ` Damien Mattei
  2024-07-01 13:44         ` Damien Mattei
  1 sibling, 1 reply; 7+ messages in thread
From: Damien Mattei @ 2024-07-01  8:54 UTC (permalink / raw)
  To: Per Bothner; +Cc: kawa mailing list

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

i find a good rule with syntax-transformers, no matter r7rs or not...

you can use them in modules but when comes the time to start the whole
program at REPL use (load "program.scm") instead of (import (program)) or
(require program)

so when there is some syntax-transformers do not start your program by
(define-library (program) ...   or even (module-name program) but simply
put the code, and even your program is also considered as a module as any
file.scm in Kawa is considered as a module file.

but i'm still searching more on this problem....

On Sat, Jun 29, 2024 at 5:32 PM Damien Mattei <damien.mattei@gmail.com>
wrote:

> i find a way to make it run, i wanted to post the answer later....
>
> it works now.
>
> in summary the solution is:
>
> for a module test-foo that use module foo you have to:
>
> be at REPL and:
>
> (import (foo))
>
> (import (test-foo))
>
> and it is ok.
>
> but it is not the normal behavior , because as foo is already imported by
> test-foo the module should works without also importing foo in REPL
>
> example:
>
> test-nfx.scm:
>
> (define-library (test-nfx) ; R7RS
>
>   (import
>  (kawa base)
>
>  (operators-list)
>  (n-arity)
>  (infix-with-precedence-to-prefix)
>  (nfx))
>
>
>   (define x ($nfx$ 3 * 5 + 2))
>   (display x) (newline)
>
> )
>
> #|kawa:1|# (import (nfx))
> #|kawa:2|# ($nfx$ 3 * 5 + 2)
> 17
> #|kawa:3|# (import (test-nfx))
> 17
>
>
> another example:
>
> #|kawa:1|# (import (Scheme+))
> #|kawa:2|#
> #|kawa:3|# (bracket-apply #(1 2 3 4 5) 2)
> bracket-apply : #'parsed-args=(#<syntax#2463 list in #3590> 2)
> (bracket-apply #(1 2 3 4 5) 2)
> 3
> #|kawa:4|# ($nfx$ 3 * 5 + 2)
> 17
> #|kawa:5|# (exit)
>
> for a whole program that use Scheme+:
>
> #|kawa:1|# (import (Scheme+))
>
> #|kawa:2|# (load
> "exo_retropropagationNhidden_layers_matrix_v2_by_vectors4kawa.scm")
>
> ################## NOT ##################
> *init* : nc=#(1 2 1)
> z=#(#(0) #(0 0) #(0))
> z̃=#(#(0) #(0 0) #(0))
> define-overload-existing-operator : proc =#<procedure *>
> define-overload-existing-operator : orig-proc =#<procedure *>
> M=#(matrix@3811464b matrix@5f0a5848)
> ᐁ=#(#(0) #(0 0) #(0))
> nbiter=5000
> exo_retropropagationNhidden_layers_matrix_v2_by_vectors4kawa.scm:145:2:
> warning - no known slot 'apprentissage' in java.lang.Object
> 0
> 1000
> 2000
> 3000
> 4000
> exo_retropropagationNhidden_layers_matrix_v2_by_vectors4kawa.scm:147:2:
> warning - no known slot 'test' in java.lang.Object
> Test des exemples :
> #(1) --> #(0.005218051056863006) : on attendait #(0)
> #(0) --> #(0.9937685906977904) : on attendait #(1)
> Error on examples=3.3029259361846465E-5
>
> ################## XOR ##################
> *init* : nc=#(2 8 1)
> z=#(#(0 0) #(0 0 0 0 0 0 0 0) #(0))
> z̃=#(#(0 0) #(0 0 0 0 0 0 0 0) #(0))
> M=#(matrix@7fb313e3 matrix@771ede0d)
> ᐁ=#(#(0 0) #(0 0 0 0 0 0 0 0) #(0))
> nbiter=250000
> exo_retropropagationNhidden_layers_matrix_v2_by_vectors4kawa.scm:160:2:
> warning - no known slot 'apprentissage' in java.lang.Object
> exo_retropropagationNhidden_layers_matrix_v2_by_vectors4kawa.scm:162:2:
> warning - no known slot 'test' in java.lang.Object
> Test des exemples :
> #(1 0) --> #(0.9869979600720541) : on attendait #(1)
> #(0 0) --> #(0.009586857552488845) : on attendait #(0)
> #(0 1) --> #(0.9875938547018659) : on attendait #(1)
> #(1 1) --> #(0.015785460599146515) : on attendait #(0)
> Error on examples=3.32027043752617E-4
>
> ################## SINE ##################
> *init* : nc=#(1 70 70 1)
>
> but perheaps there is a solution with playing with import/require,
> Kawa/R7RS  i will test any possible combinaison (? do not know the english
> term)
>
> the problem only happen with syntax transformer, if not , i would have
> noticed already......or someone else....
>
> Damien
>
> On Sat, Jun 29, 2024 at 4:17 PM Per Bothner <per@bothner.com> wrote:
>
>> Perhaps - or perhaps it depends on unspecified behavior.
>>
>> In any case, I think you're going to have to debug this on your own.
>>
>> On 6/29/24 2:03 AM, Damien Mattei via Kawa wrote:
>> > i'm sure it is a kawa bug because i ported all the code to Guile and it
>> > works perfectly.
>>
>> --
>>         --Per Bothner
>> per@bothner.com   http://per.bothner.com/
>>
>

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

* Re: bug in kawa syntax transformer?
  2024-07-01  8:54       ` Damien Mattei
@ 2024-07-01 13:44         ` Damien Mattei
  0 siblings, 0 replies; 7+ messages in thread
From: Damien Mattei @ 2024-07-01 13:44 UTC (permalink / raw)
  To: Per Bothner; +Cc: kawa mailing list

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

all is working but i find a difference strange between Kawa and Guile
running this example in Scheme+:

(require Scheme+)

(define V (make-vector 5))

{V[2] <- 7}

(define x {3 * V[2] + 1})

(display x)
(newline)

the output for Kawa is:

<- : #'(index ...) = (2)
<- : #'parsed-args=(#<syntax#2588 list in #3793> 2)
$nfx$ : parsed-args=(+ (* 3 (bracket-apply V 2)) 1)

bracket-apply : #'parsed-args=(#<syntax#2598 list in #3807> 2)
22

and for Guile:

<- : #'(index ...) = (#<syntax:test-guile+.scm:6:3 2>)
<- : #'parsed-args=(#<syntax:assignment.scm:151:32 list>
#<syntax:test-guile+.scm:6:3 2>)
$nfx$ : parsed-args=(#<syntax:test-guile+.scm:8:20 +>
(#<syntax:test-guile+.scm:8:13 *> #<syntax:test-guile+.scm:8:11 3>
#<syntax:test-guile+.scm:8:15 ($bracket-apply$ V
#<syntax:test-guile+.scm:8:17 2>)>) #<syntax:test-guile+.scm:8:22 1>)
$bracket-apply$ : #'parsed-args=(#<syntax:bracket-apply.scm:129:30 list>
#<syntax:test-guile+.scm:8:17 2>)
;;; compiled
/Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/Users/mattei/AI_Deep_Learning/test-guile+.scm.go
22

the result is good but for un unknown reason the syntactic expression
manipulate by the syntax transformer in kawa display as a normal expression
but in guile it is a syntax expression:

Kawa:
(+ (* 3 (bracket-apply V 2)) 1)

Guile:
(#<syntax:test-guile+.scm:8:20 +> (#<syntax:test-guile+.scm:8:13 *>
#<syntax:test-guile+.scm:8:11 3> #<syntax:test-guile+.scm:8:15
($bracket-apply$ V #<syntax:test-guile+.scm:8:17 2>)>)
#<syntax:test-guile+.scm:8:22 1>)

This is surprising because i only got this behavior for infix ($nfx$ code)
not for other

The reader could be interested by the code itself here it is for Kawa:

;; use: (import (nfx))

(define-library (nfx) ; R7RS

  (import (kawa base)
 (n-arity)
 (infix-with-precedence-to-prefix)
 (operators-list) ;; bug transformers syntax
 )


  (export $nfx$)



;; #|kawa:1|# (import (nfx))
;; #|kawa:2|# ($nfx$ 3 * 5 + 2)
;; 17

(define-syntax $nfx$

  (lambda (stx)

    (syntax-case stx ()

      ;; note that to have $nfx$ called you need at minimum to have 2
different operator causing an operator precedence question
      ;; and then at least those 2 operators must be between operands each,
so there is a need for 3 operand
      ;; the syntax then looks like this : e1 op1 e2 op2 e3 ..., example :
3 * 4 + 2
      (($nfx$ e1 op1 e2 op2 e3 op ...) ; note: i add op because in scheme
op ... could be non existent

       ;;#'(list e1 op1 e2 op2 e3 op ...)

(with-syntax ;; let

      ((parsed-args
;; TODO : make n-arity for <- and <+ only (because could be false with ** ,
but not implemented in n-arity for now)

;; (begin
;;   (include "operators-list-definitions.scm")
;;   (include "infix-with-precedence-to-prefix-definitions.scm")
;;   (include "syntax-definitions.scm")
 (n-arity ;; this avoid : '{x <- y <- z <- t <- u <- 3 * 4 + 1}
  ;; SRFI-105.scm : !0 result = (<- (<- (<- (<- (<- x y) z) t) u) (+ (* 3
4) 1)) ;; fail set! ...
  ;; transform in : '(<- x y z t u (+ (* 3 4) 1))
  (!0-generic #'(e1 op1 e2 op2 e3 op ...) ; apply operator precedence rules
  ;;(!0-generic-syntax #'(e1 op1 e2 op2 e3 op ...)
     ;;infix-operators-lst-for-parser-syntax
     (get-infix-operators-lst-for-parser-syntax)
     (lambda (op a b) (list op a b))))


 ;) ; end let or begin
))
      (display "$nfx$ : parsed-args=") (display #'parsed-args) (newline)
      #'parsed-args)

))))

) ; end module

kawa at the difference of guile use a getter:

;;infix-operators-lst-for-parser-syntax
     (get-infix-operators-lst-for-parser-syntax)

defined in other files:

(define infix-operators-lst-for-parser-syntax

  (list
    (list #'expt #'**)
    (list #'* #'/ #'%)
    (list #'+ #'-)

    (list #'<< #'>>)

    (list #'& #'∣)

    (list #'< #'> #'= #'≠ #'<= #'>= #'<>)

    (list #'and)

    (list #'or)

    assignment-operator-syntax
    definition-operator-syntax
    )

  )


(define (get-infix-operators-lst-for-parser-syntax)
  infix-operators-lst-for-parser-syntax)

but the code for guile is almost this the same:

;; (use-modules (nfx))


(define-module (nfx)

  ;;#:use-module ((guile))

  #:use-module (n-arity)
  #:use-module (infix-with-precedence-to-prefix)
  #:use-module (operators-list)

  #:export ($nfx$))





;; scheme@(guile-user)>  ($nfx$ 3 * 5 + 2)
;; $1 = 17


(define-syntax $nfx$

  (lambda (stx)

    (syntax-case stx ()

      ;; note that to have $nfx$ called you need at minimum to have 2
different operator causing an operator precedence question
      ;; and then at least those 2 operators must be between operands each,
so there is a need for 3 operand
      ;; the syntax then looks like this : e1 op1 e2 op2 e3 ..., example :
3 * 4 + 2
      (($nfx$ e1 op1 e2 op2 e3 op ...) ; note: i add op because in scheme
op ... could be non existent

(with-syntax

      ((parsed-args
;; TODO : make n-arity for <- and <+ only (because could be false with ** ,
but not implemented in n-arity for now)


 (n-arity ;; this avoid : '{x <- y <- z <- t <- u <- 3 * 4 + 1}
  ;; SRFI-105.scm : !0 result = (<- (<- (<- (<- (<- x y) z) t) u) (+ (* 3
4) 1)) ;; fail set! ...
  ;; transform in : '(<- x y z t u (+ (* 3 4) 1))
  (!0-generic #'(e1 op1 e2 op2 e3 op ...) ; apply operator precedence rules
      infix-operators-lst-for-parser-syntax
      (lambda (op a b) (list op a b))))))
      (display "$nfx$ : parsed-args=") (display #'parsed-args) (newline)
      #'parsed-args)))))

so this is really strange to have a display without syntax in some place of
kawa code and with syntax in other place of kawa code....

but everything is working well.... perheaps i did not notice a difference
in the 2 codes....


On Mon, Jul 1, 2024 at 10:54 AM Damien Mattei <damien.mattei@gmail.com>
wrote:

> i find a good rule with syntax-transformers, no matter r7rs or not...
>
> you can use them in modules but when comes the time to start the whole
> program at REPL use (load "program.scm") instead of (import (program)) or
> (require program)
>
> so when there is some syntax-transformers do not start your program by
> (define-library (program) ...   or even (module-name program) but simply
> put the code, and even your program is also considered as a module as any
> file.scm in Kawa is considered as a module file.
>
> but i'm still searching more on this problem....
>
> On Sat, Jun 29, 2024 at 5:32 PM Damien Mattei <damien.mattei@gmail.com>
> wrote:
>
>> i find a way to make it run, i wanted to post the answer later....
>>
>> it works now.
>>
>> in summary the solution is:
>>
>> for a module test-foo that use module foo you have to:
>>
>> be at REPL and:
>>
>> (import (foo))
>>
>> (import (test-foo))
>>
>> and it is ok.
>>
>> but it is not the normal behavior , because as foo is already imported by
>> test-foo the module should works without also importing foo in REPL
>>
>> example:
>>
>> test-nfx.scm:
>>
>> (define-library (test-nfx) ; R7RS
>>
>>   (import
>>  (kawa base)
>>
>>  (operators-list)
>>  (n-arity)
>>  (infix-with-precedence-to-prefix)
>>  (nfx))
>>
>>
>>   (define x ($nfx$ 3 * 5 + 2))
>>   (display x) (newline)
>>
>> )
>>
>> #|kawa:1|# (import (nfx))
>> #|kawa:2|# ($nfx$ 3 * 5 + 2)
>> 17
>> #|kawa:3|# (import (test-nfx))
>> 17
>>
>>
>> another example:
>>
>> #|kawa:1|# (import (Scheme+))
>> #|kawa:2|#
>> #|kawa:3|# (bracket-apply #(1 2 3 4 5) 2)
>> bracket-apply : #'parsed-args=(#<syntax#2463 list in #3590> 2)
>> (bracket-apply #(1 2 3 4 5) 2)
>> 3
>> #|kawa:4|# ($nfx$ 3 * 5 + 2)
>> 17
>> #|kawa:5|# (exit)
>>
>> for a whole program that use Scheme+:
>>
>> #|kawa:1|# (import (Scheme+))
>>
>> #|kawa:2|# (load
>> "exo_retropropagationNhidden_layers_matrix_v2_by_vectors4kawa.scm")
>>
>> ################## NOT ##################
>> *init* : nc=#(1 2 1)
>> z=#(#(0) #(0 0) #(0))
>> z̃=#(#(0) #(0 0) #(0))
>> define-overload-existing-operator : proc =#<procedure *>
>> define-overload-existing-operator : orig-proc =#<procedure *>
>> M=#(matrix@3811464b matrix@5f0a5848)
>> ᐁ=#(#(0) #(0 0) #(0))
>> nbiter=5000
>> exo_retropropagationNhidden_layers_matrix_v2_by_vectors4kawa.scm:145:2:
>> warning - no known slot 'apprentissage' in java.lang.Object
>> 0
>> 1000
>> 2000
>> 3000
>> 4000
>> exo_retropropagationNhidden_layers_matrix_v2_by_vectors4kawa.scm:147:2:
>> warning - no known slot 'test' in java.lang.Object
>> Test des exemples :
>> #(1) --> #(0.005218051056863006) : on attendait #(0)
>> #(0) --> #(0.9937685906977904) : on attendait #(1)
>> Error on examples=3.3029259361846465E-5
>>
>> ################## XOR ##################
>> *init* : nc=#(2 8 1)
>> z=#(#(0 0) #(0 0 0 0 0 0 0 0) #(0))
>> z̃=#(#(0 0) #(0 0 0 0 0 0 0 0) #(0))
>> M=#(matrix@7fb313e3 matrix@771ede0d)
>> ᐁ=#(#(0 0) #(0 0 0 0 0 0 0 0) #(0))
>> nbiter=250000
>> exo_retropropagationNhidden_layers_matrix_v2_by_vectors4kawa.scm:160:2:
>> warning - no known slot 'apprentissage' in java.lang.Object
>> exo_retropropagationNhidden_layers_matrix_v2_by_vectors4kawa.scm:162:2:
>> warning - no known slot 'test' in java.lang.Object
>> Test des exemples :
>> #(1 0) --> #(0.9869979600720541) : on attendait #(1)
>> #(0 0) --> #(0.009586857552488845) : on attendait #(0)
>> #(0 1) --> #(0.9875938547018659) : on attendait #(1)
>> #(1 1) --> #(0.015785460599146515) : on attendait #(0)
>> Error on examples=3.32027043752617E-4
>>
>> ################## SINE ##################
>> *init* : nc=#(1 70 70 1)
>>
>> but perheaps there is a solution with playing with import/require,
>> Kawa/R7RS  i will test any possible combinaison (? do not know the english
>> term)
>>
>> the problem only happen with syntax transformer, if not , i would have
>> noticed already......or someone else....
>>
>> Damien
>>
>> On Sat, Jun 29, 2024 at 4:17 PM Per Bothner <per@bothner.com> wrote:
>>
>>> Perhaps - or perhaps it depends on unspecified behavior.
>>>
>>> In any case, I think you're going to have to debug this on your own.
>>>
>>> On 6/29/24 2:03 AM, Damien Mattei via Kawa wrote:
>>> > i'm sure it is a kawa bug because i ported all the code to Guile and it
>>> > works perfectly.
>>>
>>> --
>>>         --Per Bothner
>>> per@bothner.com   http://per.bothner.com/
>>>
>>

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

end of thread, other threads:[~2024-07-01 13:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-29  8:13 bug in kawa syntax transformer? Damien Mattei
2024-06-29  9:03 ` Damien Mattei
2024-06-29 14:16   ` Per Bothner
2024-06-29 15:32     ` Damien Mattei
2024-06-30 20:56       ` Damien Mattei
2024-07-01  8:54       ` Damien Mattei
2024-07-01 13:44         ` Damien Mattei

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).