unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* 2 macros in one expression
@ 2023-04-14 11:02 Damien Mattei
  2023-04-14 14:49 ` Damien Mattei
  2023-04-15 13:49 ` Matt Wette
  0 siblings, 2 replies; 9+ messages in thread
From: Damien Mattei @ 2023-04-14 11:02 UTC (permalink / raw)
  To: guile-user

hello,

i have 2 macros used in one expression like this:
scheme@(guile-user)> (define i 2)
scheme@(guile-user)> {i <- i + 1}
and i got this error:
While compiling expression:
Syntax error:
unknown location: source expression failed to match any pattern in form <-

i use SRFI-105 so :
 '{i <- i + 1} expand in:
($nfx$ i <- i + 1)

and i'm expecting $nfx$ to be called but none of this happens:
scheme@(guile-user)> ($nfx$ i <- i + 1)
While compiling expression:
Syntax error:
unknown location: source expression failed to match any pattern in form <-

it seems to be the <- macro and i do not understand why?

any idea?

macros are defined like this for the beginning:
;; from file assignment.scm
(define-syntax <-

  (syntax-rules ()
    ;;  special form like : (<- ($bracket-apply$ T 3) ($bracket-apply$ T 4))

    ;; one dimension array, example: {a[4] <- 7}
    ;; $bracket-apply$ is from SRFI 105  bracket-apply is an argument of
the macro
    ((_ (bracket-apply container index) expr)

....

;; from file scheme-infix.scm
(define-syntax $nfx$
  (syntax-rules ()

    ((_ ident opspecial term1 op term2) (cond ((or (equal? (quote
opspecial) (quote <-)) (equal? (quote opspecial) (quote ←)))
      (begin
(display "$nfx$") (newline)
(opspecial ident (op term1 term2)))) ;; {ident <- {term1 op term2}}

...


it is in a module like this:

(define-module (Scheme+)

  #:use-module (growable-vector)
  #:use-module (srfi srfi-69) ;; Basic hash tables
  #:use-module (srfi srfi-31) ;; rec
  #:export ($nfx$ def $bracket-apply$ <- ← -> → <+ ⥆ +> ⥅ declare $ & condx
<> ≠ ** <v v> ⇜ ⇝ repeat)
  #:replace (do when unless))



(include-from-path "def.scm")
(include-from-path "array.scm")
(include-from-path "set-values-plus.scm")
(include-from-path "apply-square-brackets.scm")
(include-from-path "assignment.scm")
(include-from-path "declare.scm")
(include-from-path "condx.scm")
(include-from-path "block.scm")
(include-from-path "not-equal.scm")
(include-from-path "exponential.scm")
(include-from-path "while-do-when-unless.scm")
(include-from-path "repeat-until.scm")
(include-from-path "scheme-infix.scm")

if it can help.

Regards,
Damien


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

* Re: 2 macros in one expression
  2023-04-14 11:02 2 macros in one expression Damien Mattei
@ 2023-04-14 14:49 ` Damien Mattei
  2023-04-14 19:36   ` Damien Mattei
  2023-04-15 13:49 ` Matt Wette
  1 sibling, 1 reply; 9+ messages in thread
From: Damien Mattei @ 2023-04-14 14:49 UTC (permalink / raw)
  To: guile-user

i have found that the error is related with this :

(define-syntax $nfx$
  (syntax-rules ()

    ((_ ident opspecial term1 op term2) (cond ((or (equal? (quote
opspecial) (quote <-)) (equal? (quote opspecial) (quote ←)))
      (begin
(display "$nfx$") (newline)
(opspecial ident (op term1 term2)))) ;; {ident <- term1 op term2}

     ((or (equal? (quote op) (quote ->)) (equal? (quote op) (quote →))) (op
term2 (opspecial ident term1))) ;; Warning: argument names of macro do not
reprensent the values contained in this case

     (else (! ident (quote opspecial) term1 op term2))))

this code works:
scheme@(guile-user)> (define i 2)
scheme@(guile-user)> {i <- i + 1}
$nfx$
3

but if i change the last line of the else clause by removing the quote of
opspecial:
(else (! ident opspecial term1 op term2))))

it will fail:

scheme@(guile-user)> {i <- i + 1}
While compiling expression:
Syntax error:
unknown location: source expression failed to match any pattern in form <-

i understand the problem is with opspecial equal in this example to the
special form <-  but what i do not understand is why the code is then going
to the else clause as i know that previously it was on the same example
evaluating the first clause:
(begin
(display "$nfx$") (newline)
(opspecial ident (op term1 term2)))) ;; {ident <- term1 op term2}

???

On Fri, Apr 14, 2023 at 1:02 PM Damien Mattei <damien.mattei@gmail.com>
wrote:

> hello,
>
> i have 2 macros used in one expression like this:
> scheme@(guile-user)> (define i 2)
> scheme@(guile-user)> {i <- i + 1}
> and i got this error:
> While compiling expression:
> Syntax error:
> unknown location: source expression failed to match any pattern in form <-
>
> i use SRFI-105 so :
>  '{i <- i + 1} expand in:
> ($nfx$ i <- i + 1)
>
> and i'm expecting $nfx$ to be called but none of this happens:
> scheme@(guile-user)> ($nfx$ i <- i + 1)
> While compiling expression:
> Syntax error:
> unknown location: source expression failed to match any pattern in form <-
>
> it seems to be the <- macro and i do not understand why?
>
> any idea?
>
> macros are defined like this for the beginning:
> ;; from file assignment.scm
> (define-syntax <-
>
>   (syntax-rules ()
>     ;;  special form like : (<- ($bracket-apply$ T 3) ($bracket-apply$ T
> 4))
>
>     ;; one dimension array, example: {a[4] <- 7}
>     ;; $bracket-apply$ is from SRFI 105  bracket-apply is an argument of
> the macro
>     ((_ (bracket-apply container index) expr)
>
> ....
>
> ;; from file scheme-infix.scm
> (define-syntax $nfx$
>   (syntax-rules ()
>
>     ((_ ident opspecial term1 op term2) (cond ((or (equal? (quote
> opspecial) (quote <-)) (equal? (quote opspecial) (quote ←)))
>       (begin
> (display "$nfx$") (newline)
> (opspecial ident (op term1 term2)))) ;; {ident <- {term1 op term2}}
>
> ...
>
>
> it is in a module like this:
>
> (define-module (Scheme+)
>
>   #:use-module (growable-vector)
>   #:use-module (srfi srfi-69) ;; Basic hash tables
>   #:use-module (srfi srfi-31) ;; rec
>   #:export ($nfx$ def $bracket-apply$ <- ← -> → <+ ⥆ +> ⥅ declare $ &
> condx <> ≠ ** <v v> ⇜ ⇝ repeat)
>   #:replace (do when unless))
>
>
>
> (include-from-path "def.scm")
> (include-from-path "array.scm")
> (include-from-path "set-values-plus.scm")
> (include-from-path "apply-square-brackets.scm")
> (include-from-path "assignment.scm")
> (include-from-path "declare.scm")
> (include-from-path "condx.scm")
> (include-from-path "block.scm")
> (include-from-path "not-equal.scm")
> (include-from-path "exponential.scm")
> (include-from-path "while-do-when-unless.scm")
> (include-from-path "repeat-until.scm")
> (include-from-path "scheme-infix.scm")
>
> if it can help.
>
> Regards,
> Damien
>


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

* Re: 2 macros in one expression
  2023-04-14 14:49 ` Damien Mattei
@ 2023-04-14 19:36   ` Damien Mattei
  2023-04-15 11:35     ` Damien Mattei
  0 siblings, 1 reply; 9+ messages in thread
From: Damien Mattei @ 2023-04-14 19:36 UTC (permalink / raw)
  To: guile-user

i test my previous problem both with Racket and Guile, it gave the same
error , i isolated the problem out of SRFI 105 ,so it is not related to
SRFI 105, here is a simple code to test:

(define-syntax $nfx$
  (syntax-rules ()

    ((_ ident opspecial term1 op term2) (cond ((or (equal? (quote
opspecial) (quote <-)) (equal? (quote opspecial) (quote ←)))
      (begin
(display "$nfx$") (newline)
(opspecial ident (op term1 term2)))) ;; {ident <- term1 op term2}

     ((or (equal? (quote op) (quote ->)) (equal? (quote op) (quote →))) (op
term2 (opspecial ident term1))) ;; Warning: argument names of macro do not
reprensent the values contained in this case

     ;;(else (! (quote ident) (quote opspecial) (quote term1) (quote op)
(quote term2)))))
     (else (! ident opspecial term1 op term2))))))





(define-syntax <-

  (syntax-rules ()

    ((_ var expr)

     (begin
       ;;(display "<- : variable set!") (newline)
       (set! var expr)
       var))))

(define i 3)
> ($nfx$ i <- i + 1)
<-: bad syntax in: <-

it works only if i change the last line of $nfx$:

(else (! ident (quote opspecial) term1 op term2))))))

note: ! which is a procedure is not defined in this example

On Fri, Apr 14, 2023 at 4:49 PM Damien Mattei <damien.mattei@gmail.com>
wrote:

> i have found that the error is related with this :
>
> (define-syntax $nfx$
>   (syntax-rules ()
>
>     ((_ ident opspecial term1 op term2) (cond ((or (equal? (quote
> opspecial) (quote <-)) (equal? (quote opspecial) (quote ←)))
>       (begin
> (display "$nfx$") (newline)
> (opspecial ident (op term1 term2)))) ;; {ident <- term1 op term2}
>
>      ((or (equal? (quote op) (quote ->)) (equal? (quote op) (quote →)))
> (op term2 (opspecial ident term1))) ;; Warning: argument names of macro do
> not reprensent the values contained in this case
>
>      (else (! ident (quote opspecial) term1 op term2))))
>
> this code works:
> scheme@(guile-user)> (define i 2)
> scheme@(guile-user)> {i <- i + 1}
> $nfx$
> 3
>
> but if i change the last line of the else clause by removing the quote of
> opspecial:
> (else (! ident opspecial term1 op term2))))
>
> it will fail:
>
> scheme@(guile-user)> {i <- i + 1}
> While compiling expression:
> Syntax error:
> unknown location: source expression failed to match any pattern in form <-
>
> i understand the problem is with opspecial equal in this example to the
> special form <-  but what i do not understand is why the code is then going
> to the else clause as i know that previously it was on the same example
> evaluating the first clause:
> (begin
> (display "$nfx$") (newline)
> (opspecial ident (op term1 term2)))) ;; {ident <- term1 op term2}
>
> ???
>
> On Fri, Apr 14, 2023 at 1:02 PM Damien Mattei <damien.mattei@gmail.com>
> wrote:
>
>> hello,
>>
>> i have 2 macros used in one expression like this:
>> scheme@(guile-user)> (define i 2)
>> scheme@(guile-user)> {i <- i + 1}
>> and i got this error:
>> While compiling expression:
>> Syntax error:
>> unknown location: source expression failed to match any pattern in form <-
>>
>> i use SRFI-105 so :
>>  '{i <- i + 1} expand in:
>> ($nfx$ i <- i + 1)
>>
>> and i'm expecting $nfx$ to be called but none of this happens:
>> scheme@(guile-user)> ($nfx$ i <- i + 1)
>> While compiling expression:
>> Syntax error:
>> unknown location: source expression failed to match any pattern in form <-
>>
>> it seems to be the <- macro and i do not understand why?
>>
>> any idea?
>>
>> macros are defined like this for the beginning:
>> ;; from file assignment.scm
>> (define-syntax <-
>>
>>   (syntax-rules ()
>>     ;;  special form like : (<- ($bracket-apply$ T 3) ($bracket-apply$ T
>> 4))
>>
>>     ;; one dimension array, example: {a[4] <- 7}
>>     ;; $bracket-apply$ is from SRFI 105  bracket-apply is an argument of
>> the macro
>>     ((_ (bracket-apply container index) expr)
>>
>> ....
>>
>> ;; from file scheme-infix.scm
>> (define-syntax $nfx$
>>   (syntax-rules ()
>>
>>     ((_ ident opspecial term1 op term2) (cond ((or (equal? (quote
>> opspecial) (quote <-)) (equal? (quote opspecial) (quote ←)))
>>       (begin
>> (display "$nfx$") (newline)
>> (opspecial ident (op term1 term2)))) ;; {ident <- {term1 op term2}}
>>
>> ...
>>
>>
>> it is in a module like this:
>>
>> (define-module (Scheme+)
>>
>>   #:use-module (growable-vector)
>>   #:use-module (srfi srfi-69) ;; Basic hash tables
>>   #:use-module (srfi srfi-31) ;; rec
>>   #:export ($nfx$ def $bracket-apply$ <- ← -> → <+ ⥆ +> ⥅ declare $ &
>> condx <> ≠ ** <v v> ⇜ ⇝ repeat)
>>   #:replace (do when unless))
>>
>>
>>
>> (include-from-path "def.scm")
>> (include-from-path "array.scm")
>> (include-from-path "set-values-plus.scm")
>> (include-from-path "apply-square-brackets.scm")
>> (include-from-path "assignment.scm")
>> (include-from-path "declare.scm")
>> (include-from-path "condx.scm")
>> (include-from-path "block.scm")
>> (include-from-path "not-equal.scm")
>> (include-from-path "exponential.scm")
>> (include-from-path "while-do-when-unless.scm")
>> (include-from-path "repeat-until.scm")
>> (include-from-path "scheme-infix.scm")
>>
>> if it can help.
>>
>> Regards,
>> Damien
>>
>


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

* Re: 2 macros in one expression
  2023-04-14 19:36   ` Damien Mattei
@ 2023-04-15 11:35     ` Damien Mattei
  0 siblings, 0 replies; 9+ messages in thread
From: Damien Mattei @ 2023-04-15 11:35 UTC (permalink / raw)
  To: guile-user

just understood my error:
quote is a macro, so it stop the evaluation of the other macro <- and <- is
expanded in the else even if this branch will not be executed and the error
arise.

On Fri, Apr 14, 2023 at 9:36 PM Damien Mattei <damien.mattei@gmail.com>
wrote:

> i test my previous problem both with Racket and Guile, it gave the same
> error , i isolated the problem out of SRFI 105 ,so it is not related to
> SRFI 105, here is a simple code to test:
>
> (define-syntax $nfx$
>   (syntax-rules ()
>
>     ((_ ident opspecial term1 op term2) (cond ((or (equal? (quote
> opspecial) (quote <-)) (equal? (quote opspecial) (quote ←)))
>       (begin
> (display "$nfx$") (newline)
> (opspecial ident (op term1 term2)))) ;; {ident <- term1 op term2}
>
>      ((or (equal? (quote op) (quote ->)) (equal? (quote op) (quote →)))
> (op term2 (opspecial ident term1))) ;; Warning: argument names of macro do
> not reprensent the values contained in this case
>
>      ;;(else (! (quote ident) (quote opspecial) (quote term1) (quote op)
> (quote term2)))))
>      (else (! ident opspecial term1 op term2))))))
>
>
>
>
>
> (define-syntax <-
>
>   (syntax-rules ()
>
>     ((_ var expr)
>
>      (begin
>        ;;(display "<- : variable set!") (newline)
>        (set! var expr)
>        var))))
>
> (define i 3)
> > ($nfx$ i <- i + 1)
> <-: bad syntax in: <-
>
> it works only if i change the last line of $nfx$:
>
> (else (! ident (quote opspecial) term1 op term2))))))
>
> note: ! which is a procedure is not defined in this example
>
> On Fri, Apr 14, 2023 at 4:49 PM Damien Mattei <damien.mattei@gmail.com>
> wrote:
>
>> i have found that the error is related with this :
>>
>> (define-syntax $nfx$
>>   (syntax-rules ()
>>
>>     ((_ ident opspecial term1 op term2) (cond ((or (equal? (quote
>> opspecial) (quote <-)) (equal? (quote opspecial) (quote ←)))
>>       (begin
>> (display "$nfx$") (newline)
>> (opspecial ident (op term1 term2)))) ;; {ident <- term1 op term2}
>>
>>      ((or (equal? (quote op) (quote ->)) (equal? (quote op) (quote →)))
>> (op term2 (opspecial ident term1))) ;; Warning: argument names of macro do
>> not reprensent the values contained in this case
>>
>>      (else (! ident (quote opspecial) term1 op term2))))
>>
>> this code works:
>> scheme@(guile-user)> (define i 2)
>> scheme@(guile-user)> {i <- i + 1}
>> $nfx$
>> 3
>>
>> but if i change the last line of the else clause by removing the quote of
>> opspecial:
>> (else (! ident opspecial term1 op term2))))
>>
>> it will fail:
>>
>> scheme@(guile-user)> {i <- i + 1}
>> While compiling expression:
>> Syntax error:
>> unknown location: source expression failed to match any pattern in form <-
>>
>> i understand the problem is with opspecial equal in this example to the
>> special form <-  but what i do not understand is why the code is then going
>> to the else clause as i know that previously it was on the same example
>> evaluating the first clause:
>> (begin
>> (display "$nfx$") (newline)
>> (opspecial ident (op term1 term2)))) ;; {ident <- term1 op term2}
>>
>> ???
>>
>> On Fri, Apr 14, 2023 at 1:02 PM Damien Mattei <damien.mattei@gmail.com>
>> wrote:
>>
>>> hello,
>>>
>>> i have 2 macros used in one expression like this:
>>> scheme@(guile-user)> (define i 2)
>>> scheme@(guile-user)> {i <- i + 1}
>>> and i got this error:
>>> While compiling expression:
>>> Syntax error:
>>> unknown location: source expression failed to match any pattern in form
>>> <-
>>>
>>> i use SRFI-105 so :
>>>  '{i <- i + 1} expand in:
>>> ($nfx$ i <- i + 1)
>>>
>>> and i'm expecting $nfx$ to be called but none of this happens:
>>> scheme@(guile-user)> ($nfx$ i <- i + 1)
>>> While compiling expression:
>>> Syntax error:
>>> unknown location: source expression failed to match any pattern in form
>>> <-
>>>
>>> it seems to be the <- macro and i do not understand why?
>>>
>>> any idea?
>>>
>>> macros are defined like this for the beginning:
>>> ;; from file assignment.scm
>>> (define-syntax <-
>>>
>>>   (syntax-rules ()
>>>     ;;  special form like : (<- ($bracket-apply$ T 3) ($bracket-apply$ T
>>> 4))
>>>
>>>     ;; one dimension array, example: {a[4] <- 7}
>>>     ;; $bracket-apply$ is from SRFI 105  bracket-apply is an argument of
>>> the macro
>>>     ((_ (bracket-apply container index) expr)
>>>
>>> ....
>>>
>>> ;; from file scheme-infix.scm
>>> (define-syntax $nfx$
>>>   (syntax-rules ()
>>>
>>>     ((_ ident opspecial term1 op term2) (cond ((or (equal? (quote
>>> opspecial) (quote <-)) (equal? (quote opspecial) (quote ←)))
>>>       (begin
>>> (display "$nfx$") (newline)
>>> (opspecial ident (op term1 term2)))) ;; {ident <- {term1 op term2}}
>>>
>>> ...
>>>
>>>
>>> it is in a module like this:
>>>
>>> (define-module (Scheme+)
>>>
>>>   #:use-module (growable-vector)
>>>   #:use-module (srfi srfi-69) ;; Basic hash tables
>>>   #:use-module (srfi srfi-31) ;; rec
>>>   #:export ($nfx$ def $bracket-apply$ <- ← -> → <+ ⥆ +> ⥅ declare $ &
>>> condx <> ≠ ** <v v> ⇜ ⇝ repeat)
>>>   #:replace (do when unless))
>>>
>>>
>>>
>>> (include-from-path "def.scm")
>>> (include-from-path "array.scm")
>>> (include-from-path "set-values-plus.scm")
>>> (include-from-path "apply-square-brackets.scm")
>>> (include-from-path "assignment.scm")
>>> (include-from-path "declare.scm")
>>> (include-from-path "condx.scm")
>>> (include-from-path "block.scm")
>>> (include-from-path "not-equal.scm")
>>> (include-from-path "exponential.scm")
>>> (include-from-path "while-do-when-unless.scm")
>>> (include-from-path "repeat-until.scm")
>>> (include-from-path "scheme-infix.scm")
>>>
>>> if it can help.
>>>
>>> Regards,
>>> Damien
>>>
>>


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

* Re: 2 macros in one expression
  2023-04-14 11:02 2 macros in one expression Damien Mattei
  2023-04-14 14:49 ` Damien Mattei
@ 2023-04-15 13:49 ` Matt Wette
  2023-04-15 14:18   ` Damien Mattei
  1 sibling, 1 reply; 9+ messages in thread
From: Matt Wette @ 2023-04-15 13:49 UTC (permalink / raw)
  To: guile-user

Did you try using the following?

(define-syntax $nfx$
   (syntax-rules (<-)
     ((...


On 4/14/23 4:02 AM, Damien Mattei wrote:
> hello,
>
> i have 2 macros used in one expression like this:
> scheme@(guile-user)> (define i 2)
> scheme@(guile-user)> {i <- i + 1}
> and i got this error:
> While compiling expression:
> Syntax error:
> unknown location: source expression failed to match any pattern in form <-
>
> i use SRFI-105 so :
>   '{i <- i + 1} expand in:
> ($nfx$ i <- i + 1)
>
> and i'm expecting $nfx$ to be called but none of this happens:
> scheme@(guile-user)> ($nfx$ i <- i + 1)
> While compiling expression:
> Syntax error:
> unknown location: source expression failed to match any pattern in form <-
>
> it seems to be the <- macro and i do not understand why?
>
> any idea?
>
> macros are defined like this for the beginning:
> ;; from file assignment.scm
> (define-syntax <-
>
>    (syntax-rules ()
>      ;;  special form like : (<- ($bracket-apply$ T 3) ($bracket-apply$ T 4))
>
>      ;; one dimension array, example: {a[4] <- 7}
>      ;; $bracket-apply$ is from SRFI 105  bracket-apply is an argument of
> the macro
>      ((_ (bracket-apply container index) expr)
>
> ....
>
> ;; from file scheme-infix.scm
> (define-syntax $nfx$
>    (syntax-rules ()
>
>      ((_ ident opspecial term1 op term2) (cond ((or (equal? (quote
> opspecial) (quote <-)) (equal? (quote opspecial) (quote ←)))
>        (begin
> (display "$nfx$") (newline)
> (opspecial ident (op term1 term2)))) ;; {ident <- {term1 op term2}}
>
> ...
>
>
> it is in a module like this:
>
> (define-module (Scheme+)
>
>    #:use-module (growable-vector)
>    #:use-module (srfi srfi-69) ;; Basic hash tables
>    #:use-module (srfi srfi-31) ;; rec
>    #:export ($nfx$ def $bracket-apply$ <- ← -> → <+ ⥆ +> ⥅ declare $ & condx
> <> ≠ ** <v v> ⇜ ⇝ repeat)
>    #:replace (do when unless))
>
>
>
> (include-from-path "def.scm")
> (include-from-path "array.scm")
> (include-from-path "set-values-plus.scm")
> (include-from-path "apply-square-brackets.scm")
> (include-from-path "assignment.scm")
> (include-from-path "declare.scm")
> (include-from-path "condx.scm")
> (include-from-path "block.scm")
> (include-from-path "not-equal.scm")
> (include-from-path "exponential.scm")
> (include-from-path "while-do-when-unless.scm")
> (include-from-path "repeat-until.scm")
> (include-from-path "scheme-infix.scm")
>
> if it can help.
>
> Regards,
> Damien


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

* Re: 2 macros in one expression
  2023-04-15 13:49 ` Matt Wette
@ 2023-04-15 14:18   ` Damien Mattei
  2023-04-15 14:45     ` Damien Mattei
  0 siblings, 1 reply; 9+ messages in thread
From: Damien Mattei @ 2023-04-15 14:18 UTC (permalink / raw)
  To: Matt Wette; +Cc: guile-user

yes i tried it, i often get this answer :-) with this sort of problem i
recurrent have with macros and it never helps ,at the point i never
understood what is the use of this option in syntax-rules.

My error i think was to forget the expansion stage of macro expansion that
is always done for all the macros used in an expression at any level, even
if the code is not used in a branch of 'if ,'cond or other conditional the
macros will be expansed.

I will quote the <- in the opspecial and tried to eval it later, the
problem is with eval which is not really normalised between all
implementations of scheme concerning its environment of evaluation.
I will post the result.
The problem was also that in an infix evaluator i wanted to be able to
evaluate all procedure (that is ok) and all the macro too which is not
always possible with the evaluation technique i use ,it is hard to write an
infix evaluator with precedence in the language itself.But the problem
arise only with the special forms, so first i quoted them all but then i
can not find the difference in the language with '(sin 30) a procedure call
and '(1 2 3) a list when evealuating it is has sense  for (sin 30) but not
for (1 2 3)  then i removed all quotation and the macro problem arise...
just after i added some overloading functionalities in my Scheme+ when
using abstract types the evaluation of abstract object (list) with for
example the + operator overloaded became a problem.
Damien

On Sat, Apr 15, 2023 at 3:50 PM Matt Wette <matt.wette@gmail.com> wrote:

> Did you try using the following?
>
> (define-syntax $nfx$
>    (syntax-rules (<-)
>      ((...
>
>
> On 4/14/23 4:02 AM, Damien Mattei wrote:
> > hello,
> >
> > i have 2 macros used in one expression like this:
> > scheme@(guile-user)> (define i 2)
> > scheme@(guile-user)> {i <- i + 1}
> > and i got this error:
> > While compiling expression:
> > Syntax error:
> > unknown location: source expression failed to match any pattern in form
> <-
> >
> > i use SRFI-105 so :
> >   '{i <- i + 1} expand in:
> > ($nfx$ i <- i + 1)
> >
> > and i'm expecting $nfx$ to be called but none of this happens:
> > scheme@(guile-user)> ($nfx$ i <- i + 1)
> > While compiling expression:
> > Syntax error:
> > unknown location: source expression failed to match any pattern in form
> <-
> >
> > it seems to be the <- macro and i do not understand why?
> >
> > any idea?
> >
> > macros are defined like this for the beginning:
> > ;; from file assignment.scm
> > (define-syntax <-
> >
> >    (syntax-rules ()
> >      ;;  special form like : (<- ($bracket-apply$ T 3) ($bracket-apply$
> T 4))
> >
> >      ;; one dimension array, example: {a[4] <- 7}
> >      ;; $bracket-apply$ is from SRFI 105  bracket-apply is an argument of
> > the macro
> >      ((_ (bracket-apply container index) expr)
> >
> > ....
> >
> > ;; from file scheme-infix.scm
> > (define-syntax $nfx$
> >    (syntax-rules ()
> >
> >      ((_ ident opspecial term1 op term2) (cond ((or (equal? (quote
> > opspecial) (quote <-)) (equal? (quote opspecial) (quote ←)))
> >        (begin
> > (display "$nfx$") (newline)
> > (opspecial ident (op term1 term2)))) ;; {ident <- {term1 op term2}}
> >
> > ...
> >
> >
> > it is in a module like this:
> >
> > (define-module (Scheme+)
> >
> >    #:use-module (growable-vector)
> >    #:use-module (srfi srfi-69) ;; Basic hash tables
> >    #:use-module (srfi srfi-31) ;; rec
> >    #:export ($nfx$ def $bracket-apply$ <- ← -> → <+ ⥆ +> ⥅ declare $ &
> condx
> > <> ≠ ** <v v> ⇜ ⇝ repeat)
> >    #:replace (do when unless))
> >
> >
> >
> > (include-from-path "def.scm")
> > (include-from-path "array.scm")
> > (include-from-path "set-values-plus.scm")
> > (include-from-path "apply-square-brackets.scm")
> > (include-from-path "assignment.scm")
> > (include-from-path "declare.scm")
> > (include-from-path "condx.scm")
> > (include-from-path "block.scm")
> > (include-from-path "not-equal.scm")
> > (include-from-path "exponential.scm")
> > (include-from-path "while-do-when-unless.scm")
> > (include-from-path "repeat-until.scm")
> > (include-from-path "scheme-infix.scm")
> >
> > if it can help.
> >
> > Regards,
> > Damien
>


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

* Re: 2 macros in one expression
  2023-04-15 14:18   ` Damien Mattei
@ 2023-04-15 14:45     ` Damien Mattei
  2023-04-15 16:15       ` Damien Mattei
  0 siblings, 1 reply; 9+ messages in thread
From: Damien Mattei @ 2023-04-15 14:45 UTC (permalink / raw)
  To: Matt Wette; +Cc: guile-user

my problem is solved by quoting the variable that CAN store a special form
(example: <-) and forcing its evaluation !  : (eval (quote opspecial)
(interaction-environment))

here is my 'else clause:

(else (! ident (eval (quote opspecial) (current-namespace)) term1 op
term2))))))

for Racket, in Guile , not tested but it should be:
(else (! ident (eval (quote opspecial) (interaction-environment)) term1 op
term2))))))

again the else clause WILL NEVER be evaluated with opspecial being a
special form but it is always expanded and that was enought to make an
error.

I admit reading Kent Dybvig article on macro and with a good scheme (as
Guile) that implement some special feature  of the article and it should
exist a more elegant solution than : (eval (quote opspecial)
(interaction-environment))
quoting with immediate evaluation ! :-/
Damien



On Sat, Apr 15, 2023 at 4:18 PM Damien Mattei <damien.mattei@gmail.com>
wrote:

> yes i tried it, i often get this answer :-) with this sort of problem i
> recurrent have with macros and it never helps ,at the point i never
> understood what is the use of this option in syntax-rules.
>
> My error i think was to forget the expansion stage of macro expansion that
> is always done for all the macros used in an expression at any level, even
> if the code is not used in a branch of 'if ,'cond or other conditional the
> macros will be expansed.
>
> I will quote the <- in the opspecial and tried to eval it later, the
> problem is with eval which is not really normalised between all
> implementations of scheme concerning its environment of evaluation.
> I will post the result.
> The problem was also that in an infix evaluator i wanted to be able to
> evaluate all procedure (that is ok) and all the macro too which is not
> always possible with the evaluation technique i use ,it is hard to write an
> infix evaluator with precedence in the language itself.But the problem
> arise only with the special forms, so first i quoted them all but then i
> can not find the difference in the language with '(sin 30) a procedure call
> and '(1 2 3) a list when evealuating it is has sense  for (sin 30) but not
> for (1 2 3)  then i removed all quotation and the macro problem arise...
> just after i added some overloading functionalities in my Scheme+ when
> using abstract types the evaluation of abstract object (list) with for
> example the + operator overloaded became a problem.
> Damien
>
> On Sat, Apr 15, 2023 at 3:50 PM Matt Wette <matt.wette@gmail.com> wrote:
>
>> Did you try using the following?
>>
>> (define-syntax $nfx$
>>    (syntax-rules (<-)
>>      ((...
>>
>>
>> On 4/14/23 4:02 AM, Damien Mattei wrote:
>> > hello,
>> >
>> > i have 2 macros used in one expression like this:
>> > scheme@(guile-user)> (define i 2)
>> > scheme@(guile-user)> {i <- i + 1}
>> > and i got this error:
>> > While compiling expression:
>> > Syntax error:
>> > unknown location: source expression failed to match any pattern in form
>> <-
>> >
>> > i use SRFI-105 so :
>> >   '{i <- i + 1} expand in:
>> > ($nfx$ i <- i + 1)
>> >
>> > and i'm expecting $nfx$ to be called but none of this happens:
>> > scheme@(guile-user)> ($nfx$ i <- i + 1)
>> > While compiling expression:
>> > Syntax error:
>> > unknown location: source expression failed to match any pattern in form
>> <-
>> >
>> > it seems to be the <- macro and i do not understand why?
>> >
>> > any idea?
>> >
>> > macros are defined like this for the beginning:
>> > ;; from file assignment.scm
>> > (define-syntax <-
>> >
>> >    (syntax-rules ()
>> >      ;;  special form like : (<- ($bracket-apply$ T 3) ($bracket-apply$
>> T 4))
>> >
>> >      ;; one dimension array, example: {a[4] <- 7}
>> >      ;; $bracket-apply$ is from SRFI 105  bracket-apply is an argument
>> of
>> > the macro
>> >      ((_ (bracket-apply container index) expr)
>> >
>> > ....
>> >
>> > ;; from file scheme-infix.scm
>> > (define-syntax $nfx$
>> >    (syntax-rules ()
>> >
>> >      ((_ ident opspecial term1 op term2) (cond ((or (equal? (quote
>> > opspecial) (quote <-)) (equal? (quote opspecial) (quote ←)))
>> >        (begin
>> > (display "$nfx$") (newline)
>> > (opspecial ident (op term1 term2)))) ;; {ident <- {term1 op term2}}
>> >
>> > ...
>> >
>> >
>> > it is in a module like this:
>> >
>> > (define-module (Scheme+)
>> >
>> >    #:use-module (growable-vector)
>> >    #:use-module (srfi srfi-69) ;; Basic hash tables
>> >    #:use-module (srfi srfi-31) ;; rec
>> >    #:export ($nfx$ def $bracket-apply$ <- ← -> → <+ ⥆ +> ⥅ declare $ &
>> condx
>> > <> ≠ ** <v v> ⇜ ⇝ repeat)
>> >    #:replace (do when unless))
>> >
>> >
>> >
>> > (include-from-path "def.scm")
>> > (include-from-path "array.scm")
>> > (include-from-path "set-values-plus.scm")
>> > (include-from-path "apply-square-brackets.scm")
>> > (include-from-path "assignment.scm")
>> > (include-from-path "declare.scm")
>> > (include-from-path "condx.scm")
>> > (include-from-path "block.scm")
>> > (include-from-path "not-equal.scm")
>> > (include-from-path "exponential.scm")
>> > (include-from-path "while-do-when-unless.scm")
>> > (include-from-path "repeat-until.scm")
>> > (include-from-path "scheme-infix.scm")
>> >
>> > if it can help.
>> >
>> > Regards,
>> > Damien
>>
>


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

* Re: 2 macros in one expression
  2023-04-15 14:45     ` Damien Mattei
@ 2023-04-15 16:15       ` Damien Mattei
  2023-04-15 16:25         ` Damien Mattei
  0 siblings, 1 reply; 9+ messages in thread
From: Damien Mattei @ 2023-04-15 16:15 UTC (permalink / raw)
  To: Matt Wette; +Cc: guile-user

it works pretty well again now the new version is debugged, this code is
related to infix evaluation in Scheme+ with operator precedence , here is
an example:

;;; compiled
/Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3.0/Scheme+.scm.go
scheme@(guile-user)> { 4 + 3 * 2 - 19 < 0 - 4}
$1 = #t
scheme@(guile-user)> (define i 3)
scheme@(guile-user)> {i <- i + 1}
$2 = 4
scheme@(guile-user)> (define c 300000)
scheme@(guile-user)> (define v 299990)
scheme@(guile-user)> (define t 30)
scheme@(guile-user)> (define x 120)
scheme@(guile-user)> (declare xp)
scheme@(guile-user)> {xp <- {x - v * t} / (sqrt {1 - v ** 2 / c ** 2})}
$3 = -1102228130.2405226
scheme@(guile-user)> '{xp <- {x - v * t} / (sqrt {1 - v ** 2 / c ** 2})}
$4 = ($nfx$ xp <- ($nfx$ x - v * t) / (sqrt ($nfx$ 1 - v ** 2 / c ** 2)))

could be written also this way:
{c <+ 300000}
{v <+ 299990}
{t <+ 30}
{x <+ 120}
(declare xp)
{ xp <- {x - v * t} / (sqrt {1 - v ** 2 / c ** 2}) }
= -1102228130.2405226
xp
 = -1102228130.2405226

it is not far from what the Python syntax allow in term of readability:

c=300000
v=299990
t=30
x=120
xp = (x - v * t) / math.sqrt (1 - v ** 2 / c ** 2)
xp
-1102228130.2404253


On Sat, Apr 15, 2023 at 4:45 PM Damien Mattei <damien.mattei@gmail.com>
wrote:

> my problem is solved by quoting the variable that CAN store a special form
> (example: <-) and forcing its evaluation !  : (eval (quote opspecial)
> (interaction-environment))
>
> here is my 'else clause:
>
> (else (! ident (eval (quote opspecial) (current-namespace)) term1 op
> term2))))))
>
> for Racket, in Guile , not tested but it should be:
> (else (! ident (eval (quote opspecial) (interaction-environment)) term1 op
> term2))))))
>
> again the else clause WILL NEVER be evaluated with opspecial being a
> special form but it is always expanded and that was enought to make an
> error.
>
> I admit reading Kent Dybvig article on macro and with a good scheme (as
> Guile) that implement some special feature  of the article and it should
> exist a more elegant solution than : (eval (quote opspecial)
> (interaction-environment))
> quoting with immediate evaluation ! :-/
> Damien
>
>
>
> On Sat, Apr 15, 2023 at 4:18 PM Damien Mattei <damien.mattei@gmail.com>
> wrote:
>
>> yes i tried it, i often get this answer :-) with this sort of problem i
>> recurrent have with macros and it never helps ,at the point i never
>> understood what is the use of this option in syntax-rules.
>>
>> My error i think was to forget the expansion stage of macro expansion
>> that is always done for all the macros used in an expression at any level,
>> even if the code is not used in a branch of 'if ,'cond or other conditional
>> the macros will be expansed.
>>
>> I will quote the <- in the opspecial and tried to eval it later, the
>> problem is with eval which is not really normalised between all
>> implementations of scheme concerning its environment of evaluation.
>> I will post the result.
>> The problem was also that in an infix evaluator i wanted to be able to
>> evaluate all procedure (that is ok) and all the macro too which is not
>> always possible with the evaluation technique i use ,it is hard to write an
>> infix evaluator with precedence in the language itself.But the problem
>> arise only with the special forms, so first i quoted them all but then i
>> can not find the difference in the language with '(sin 30) a procedure call
>> and '(1 2 3) a list when evealuating it is has sense  for (sin 30) but not
>> for (1 2 3)  then i removed all quotation and the macro problem arise...
>> just after i added some overloading functionalities in my Scheme+ when
>> using abstract types the evaluation of abstract object (list) with for
>> example the + operator overloaded became a problem.
>> Damien
>>
>> On Sat, Apr 15, 2023 at 3:50 PM Matt Wette <matt.wette@gmail.com> wrote:
>>
>>> Did you try using the following?
>>>
>>> (define-syntax $nfx$
>>>    (syntax-rules (<-)
>>>      ((...
>>>
>>>
>>> On 4/14/23 4:02 AM, Damien Mattei wrote:
>>> > hello,
>>> >
>>> > i have 2 macros used in one expression like this:
>>> > scheme@(guile-user)> (define i 2)
>>> > scheme@(guile-user)> {i <- i + 1}
>>> > and i got this error:
>>> > While compiling expression:
>>> > Syntax error:
>>> > unknown location: source expression failed to match any pattern in
>>> form <-
>>> >
>>> > i use SRFI-105 so :
>>> >   '{i <- i + 1} expand in:
>>> > ($nfx$ i <- i + 1)
>>> >
>>> > and i'm expecting $nfx$ to be called but none of this happens:
>>> > scheme@(guile-user)> ($nfx$ i <- i + 1)
>>> > While compiling expression:
>>> > Syntax error:
>>> > unknown location: source expression failed to match any pattern in
>>> form <-
>>> >
>>> > it seems to be the <- macro and i do not understand why?
>>> >
>>> > any idea?
>>> >
>>> > macros are defined like this for the beginning:
>>> > ;; from file assignment.scm
>>> > (define-syntax <-
>>> >
>>> >    (syntax-rules ()
>>> >      ;;  special form like : (<- ($bracket-apply$ T 3)
>>> ($bracket-apply$ T 4))
>>> >
>>> >      ;; one dimension array, example: {a[4] <- 7}
>>> >      ;; $bracket-apply$ is from SRFI 105  bracket-apply is an argument
>>> of
>>> > the macro
>>> >      ((_ (bracket-apply container index) expr)
>>> >
>>> > ....
>>> >
>>> > ;; from file scheme-infix.scm
>>> > (define-syntax $nfx$
>>> >    (syntax-rules ()
>>> >
>>> >      ((_ ident opspecial term1 op term2) (cond ((or (equal? (quote
>>> > opspecial) (quote <-)) (equal? (quote opspecial) (quote ←)))
>>> >        (begin
>>> > (display "$nfx$") (newline)
>>> > (opspecial ident (op term1 term2)))) ;; {ident <- {term1 op term2}}
>>> >
>>> > ...
>>> >
>>> >
>>> > it is in a module like this:
>>> >
>>> > (define-module (Scheme+)
>>> >
>>> >    #:use-module (growable-vector)
>>> >    #:use-module (srfi srfi-69) ;; Basic hash tables
>>> >    #:use-module (srfi srfi-31) ;; rec
>>> >    #:export ($nfx$ def $bracket-apply$ <- ← -> → <+ ⥆ +> ⥅ declare $ &
>>> condx
>>> > <> ≠ ** <v v> ⇜ ⇝ repeat)
>>> >    #:replace (do when unless))
>>> >
>>> >
>>> >
>>> > (include-from-path "def.scm")
>>> > (include-from-path "array.scm")
>>> > (include-from-path "set-values-plus.scm")
>>> > (include-from-path "apply-square-brackets.scm")
>>> > (include-from-path "assignment.scm")
>>> > (include-from-path "declare.scm")
>>> > (include-from-path "condx.scm")
>>> > (include-from-path "block.scm")
>>> > (include-from-path "not-equal.scm")
>>> > (include-from-path "exponential.scm")
>>> > (include-from-path "while-do-when-unless.scm")
>>> > (include-from-path "repeat-until.scm")
>>> > (include-from-path "scheme-infix.scm")
>>> >
>>> > if it can help.
>>> >
>>> > Regards,
>>> > Damien
>>>
>>


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

* Re: 2 macros in one expression
  2023-04-15 16:15       ` Damien Mattei
@ 2023-04-15 16:25         ` Damien Mattei
  0 siblings, 0 replies; 9+ messages in thread
From: Damien Mattei @ 2023-04-15 16:25 UTC (permalink / raw)
  To: Matt Wette; +Cc: guile-user

the same expression in Scheme would be:

(set! xp (/ (- x (* v t)) (sqrt (- 1 (/ (expt v 2) (expt c 2))))))
> xp
-1102228130.2405226

a bit less readable than:
{xp <- {x - v * t} / (sqrt {1 - v ** 2 / c ** 2})}
-1102228130.2405226

or:
 {xp ← {x - v * t} / (sqrt {1 - v ** 2 / c ** 2})}
-1102228130.2405226

note: i admit the ← is hard to get on keyboards ;-)


On Sat, Apr 15, 2023 at 6:15 PM Damien Mattei <damien.mattei@gmail.com>
wrote:

> it works pretty well again now the new version is debugged, this code is
> related to infix evaluation in Scheme+ with operator precedence , here is
> an example:
>
> ;;; compiled
> /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3.0/Scheme+.scm.go
> scheme@(guile-user)> { 4 + 3 * 2 - 19 < 0 - 4}
> $1 = #t
> scheme@(guile-user)> (define i 3)
> scheme@(guile-user)> {i <- i + 1}
> $2 = 4
> scheme@(guile-user)> (define c 300000)
> scheme@(guile-user)> (define v 299990)
> scheme@(guile-user)> (define t 30)
> scheme@(guile-user)> (define x 120)
> scheme@(guile-user)> (declare xp)
> scheme@(guile-user)> {xp <- {x - v * t} / (sqrt {1 - v ** 2 / c ** 2})}
> $3 = -1102228130.2405226
> scheme@(guile-user)> '{xp <- {x - v * t} / (sqrt {1 - v ** 2 / c ** 2})}
> $4 = ($nfx$ xp <- ($nfx$ x - v * t) / (sqrt ($nfx$ 1 - v ** 2 / c ** 2)))
>
> could be written also this way:
> {c <+ 300000}
> {v <+ 299990}
> {t <+ 30}
> {x <+ 120}
> (declare xp)
> { xp <- {x - v * t} / (sqrt {1 - v ** 2 / c ** 2}) }
> = -1102228130.2405226
> xp
>  = -1102228130.2405226
>
> it is not far from what the Python syntax allow in term of readability:
>
> c=300000
> v=299990
> t=30
> x=120
> xp = (x - v * t) / math.sqrt (1 - v ** 2 / c ** 2)
> xp
> -1102228130.2404253
>
>
> On Sat, Apr 15, 2023 at 4:45 PM Damien Mattei <damien.mattei@gmail.com>
> wrote:
>
>> my problem is solved by quoting the variable that CAN store a special
>> form (example: <-) and forcing its evaluation !  : (eval (quote opspecial)
>> (interaction-environment))
>>
>> here is my 'else clause:
>>
>> (else (! ident (eval (quote opspecial) (current-namespace)) term1 op
>> term2))))))
>>
>> for Racket, in Guile , not tested but it should be:
>> (else (! ident (eval (quote opspecial) (interaction-environment)) term1
>> op term2))))))
>>
>> again the else clause WILL NEVER be evaluated with opspecial being a
>> special form but it is always expanded and that was enought to make an
>> error.
>>
>> I admit reading Kent Dybvig article on macro and with a good scheme (as
>> Guile) that implement some special feature  of the article and it should
>> exist a more elegant solution than : (eval (quote opspecial)
>> (interaction-environment))
>> quoting with immediate evaluation ! :-/
>> Damien
>>
>>
>>
>> On Sat, Apr 15, 2023 at 4:18 PM Damien Mattei <damien.mattei@gmail.com>
>> wrote:
>>
>>> yes i tried it, i often get this answer :-) with this sort of problem i
>>> recurrent have with macros and it never helps ,at the point i never
>>> understood what is the use of this option in syntax-rules.
>>>
>>> My error i think was to forget the expansion stage of macro expansion
>>> that is always done for all the macros used in an expression at any level,
>>> even if the code is not used in a branch of 'if ,'cond or other conditional
>>> the macros will be expansed.
>>>
>>> I will quote the <- in the opspecial and tried to eval it later, the
>>> problem is with eval which is not really normalised between all
>>> implementations of scheme concerning its environment of evaluation.
>>> I will post the result.
>>> The problem was also that in an infix evaluator i wanted to be able to
>>> evaluate all procedure (that is ok) and all the macro too which is not
>>> always possible with the evaluation technique i use ,it is hard to write an
>>> infix evaluator with precedence in the language itself.But the problem
>>> arise only with the special forms, so first i quoted them all but then i
>>> can not find the difference in the language with '(sin 30) a procedure call
>>> and '(1 2 3) a list when evealuating it is has sense  for (sin 30) but not
>>> for (1 2 3)  then i removed all quotation and the macro problem arise...
>>> just after i added some overloading functionalities in my Scheme+ when
>>> using abstract types the evaluation of abstract object (list) with for
>>> example the + operator overloaded became a problem.
>>> Damien
>>>
>>> On Sat, Apr 15, 2023 at 3:50 PM Matt Wette <matt.wette@gmail.com> wrote:
>>>
>>>> Did you try using the following?
>>>>
>>>> (define-syntax $nfx$
>>>>    (syntax-rules (<-)
>>>>      ((...
>>>>
>>>>
>>>> On 4/14/23 4:02 AM, Damien Mattei wrote:
>>>> > hello,
>>>> >
>>>> > i have 2 macros used in one expression like this:
>>>> > scheme@(guile-user)> (define i 2)
>>>> > scheme@(guile-user)> {i <- i + 1}
>>>> > and i got this error:
>>>> > While compiling expression:
>>>> > Syntax error:
>>>> > unknown location: source expression failed to match any pattern in
>>>> form <-
>>>> >
>>>> > i use SRFI-105 so :
>>>> >   '{i <- i + 1} expand in:
>>>> > ($nfx$ i <- i + 1)
>>>> >
>>>> > and i'm expecting $nfx$ to be called but none of this happens:
>>>> > scheme@(guile-user)> ($nfx$ i <- i + 1)
>>>> > While compiling expression:
>>>> > Syntax error:
>>>> > unknown location: source expression failed to match any pattern in
>>>> form <-
>>>> >
>>>> > it seems to be the <- macro and i do not understand why?
>>>> >
>>>> > any idea?
>>>> >
>>>> > macros are defined like this for the beginning:
>>>> > ;; from file assignment.scm
>>>> > (define-syntax <-
>>>> >
>>>> >    (syntax-rules ()
>>>> >      ;;  special form like : (<- ($bracket-apply$ T 3)
>>>> ($bracket-apply$ T 4))
>>>> >
>>>> >      ;; one dimension array, example: {a[4] <- 7}
>>>> >      ;; $bracket-apply$ is from SRFI 105  bracket-apply is an
>>>> argument of
>>>> > the macro
>>>> >      ((_ (bracket-apply container index) expr)
>>>> >
>>>> > ....
>>>> >
>>>> > ;; from file scheme-infix.scm
>>>> > (define-syntax $nfx$
>>>> >    (syntax-rules ()
>>>> >
>>>> >      ((_ ident opspecial term1 op term2) (cond ((or (equal? (quote
>>>> > opspecial) (quote <-)) (equal? (quote opspecial) (quote ←)))
>>>> >        (begin
>>>> > (display "$nfx$") (newline)
>>>> > (opspecial ident (op term1 term2)))) ;; {ident <- {term1 op term2}}
>>>> >
>>>> > ...
>>>> >
>>>> >
>>>> > it is in a module like this:
>>>> >
>>>> > (define-module (Scheme+)
>>>> >
>>>> >    #:use-module (growable-vector)
>>>> >    #:use-module (srfi srfi-69) ;; Basic hash tables
>>>> >    #:use-module (srfi srfi-31) ;; rec
>>>> >    #:export ($nfx$ def $bracket-apply$ <- ← -> → <+ ⥆ +> ⥅ declare $
>>>> & condx
>>>> > <> ≠ ** <v v> ⇜ ⇝ repeat)
>>>> >    #:replace (do when unless))
>>>> >
>>>> >
>>>> >
>>>> > (include-from-path "def.scm")
>>>> > (include-from-path "array.scm")
>>>> > (include-from-path "set-values-plus.scm")
>>>> > (include-from-path "apply-square-brackets.scm")
>>>> > (include-from-path "assignment.scm")
>>>> > (include-from-path "declare.scm")
>>>> > (include-from-path "condx.scm")
>>>> > (include-from-path "block.scm")
>>>> > (include-from-path "not-equal.scm")
>>>> > (include-from-path "exponential.scm")
>>>> > (include-from-path "while-do-when-unless.scm")
>>>> > (include-from-path "repeat-until.scm")
>>>> > (include-from-path "scheme-infix.scm")
>>>> >
>>>> > if it can help.
>>>> >
>>>> > Regards,
>>>> > Damien
>>>>
>>>


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

end of thread, other threads:[~2023-04-15 16:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-14 11:02 2 macros in one expression Damien Mattei
2023-04-14 14:49 ` Damien Mattei
2023-04-14 19:36   ` Damien Mattei
2023-04-15 11:35     ` Damien Mattei
2023-04-15 13:49 ` Matt Wette
2023-04-15 14:18   ` Damien Mattei
2023-04-15 14:45     ` Damien Mattei
2023-04-15 16:15       ` Damien Mattei
2023-04-15 16:25         ` 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).