is it possible to define expand-time values?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

is it possible to define expand-time values?

Marco Maggi
...  in CHICKEN  5.0.0  or in  a  future release?   I  can find  nothing
relevant on the CHICKEN Wiki.  Here what they should do:

<http://marcomaggi.github.io/docs/vicare-scheme.html/iklib-expander-etv.html>

it would open a can of worms^H^H^H^H^H possibilities.
--
Marco Maggi

_______________________________________________
Chicken-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/chicken-users
Reply | Threaded
Open this post in threaded view
|

Re: is it possible to define expand-time values?

Peter Bex
On Sat, May 04, 2019 at 03:56:12PM +0200, Marco Maggi wrote:
> ...  in CHICKEN  5.0.0  or in  a  future release?   I  can find  nothing
> relevant on the CHICKEN Wiki.  Here what they should do:
>
> <http://marcomaggi.github.io/docs/vicare-scheme.html/iklib-expander-etv.html>
>
> it would open a can of worms^H^H^H^H^H possibilities.

Hi Marco,

This seems like a superfluous feature to me.

To give an example of the first example on the page you linked,
I would use this in a begin-for-syntax, like so:

(begin-for-syntax
  (define obj1 (+ 1 2 3)))

(define-syntax get-obj1
  (er-macro-transformer
    (lambda (e r c)
      obj1)))

(get-obj1) => 6

Maybe I'm missing something, but this seems much simpler to me.

Cheers,
Peter

_______________________________________________
Chicken-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/chicken-users

signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: is it possible to define expand-time values?

Marco Maggi
In reply to this post by Marco Maggi
Marco Maggi wrote:

> ...  in CHICKEN  5.0.0  or in  a  future release?   I  can find  nothing
> relevant on the CHICKEN Wiki.  Here what they should do:

> <http://marcomaggi.github.io/docs/vicare-scheme.html/iklib-expander-etv.html>

> it would open a can of worms^H^H^H^H^H possibilities.

Lame self reply.  I see I can do something similar with:

   (define-for-syntax ciao (list 1 2 3))

   (define-syntax hello
     (ir-macro-transformer
       (lambda (input x y)
         (let ((it (cadr input)))
    (pretty-print (eval it))
    1))))
   
   (hello ciao)

but EVAL uses are ugly (and dangerous).
--
Marco Maggi

_______________________________________________
Chicken-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/chicken-users
Reply | Threaded
Open this post in threaded view
|

Re: is it possible to define expand-time values?

Marco Maggi
In reply to this post by Peter Bex
Peter Bex wrote:

> On Sat, May 04, 2019 at 03:56:12PM +0200, Marco Maggi wrote:
>> ...  in CHICKEN  5.0.0  or in  a  future release?   I  can find  nothing
>> relevant on the CHICKEN Wiki.  Here what they should do:

>> <http://marcomaggi.github.io/docs/vicare-scheme.html/iklib-expander-etv.html>

>> it would open a can of worms^H^H^H^H^H possibilities.

> Hi Marco,

> This seems like a superfluous feature to me.

> To give an example of the first example on the page you linked,
> I would use this in a begin-for-syntax, like so:

> (begin-for-syntax
>   (define obj1 (+ 1 2 3)))

> (define-syntax get-obj1
>   (er-macro-transformer
>     (lambda (e r c)
>       obj1)))

> (get-obj1) => 6

> Maybe I'm missing something, but this seems much simpler to me.

That  example just  shows the  mechanism, and  it is  not really  a good
example (I wrote it).  What I  am thinking of, as reference scenario, is
an infix-to-prefix macro  with infrastructure that allows  to define new
binary operators, in which the operator name is not necessarily equal to
the name of the function that implements the operation itself.

  So it should go like this:

   (define (spiffy-operation X Y)
     (do-something-spiffy-with X Y))

   (define-infix-binary-operator spiffy
     (right-binding-power 55)
     ...
     (procedure spiffy-operation))

   (infix 2 * 3 + 88 spiffy 99)

the  use of  the macro  DEFINE-INFIX-BINARY-OPERATOR should  expand into
something like:

   (define-syntax spiffy
     (make-expand-time-value
       (make-infix-operator 55 ... spiffy-operation)))

and the macro INFIX should parse  its input form and retrieve the record
instance of type "infix-operator" with code like:

   (if (expand-time-value? token)
       (let ((etv (retrieve-expand-time-value token)))
         (if (infix-operator? etv)
             (process-the-operator etv)
           ---))
     ---)

  I  think that  Racket's implementation  of the  infix-to-prefix syntax
does something like this (I have not checked).

  Another  use  case,  if  the  identifier "<fixnum>"  is  bound  to  an
appropriate expand-time value, we could expand.

   (define* (doit {X <fixnum>} {Y <fixnum>})
     ---)

into:

   (define (doit X Y)
     (assert (fixnum? X))
     (assert (fixnum? Y))
     ---)

--
Marco Maggi

_______________________________________________
Chicken-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/chicken-users
Reply | Threaded
Open this post in threaded view
|

Re: is it possible to define expand-time values?

Peter Bex
On Sat, May 04, 2019 at 09:06:08PM +0200, Marco Maggi wrote:

> That  example just  shows the  mechanism, and  it is  not really  a good
> example (I wrote it).  What I  am thinking of, as reference scenario, is
> an infix-to-prefix macro  with infrastructure that allows  to define new
> binary operators, in which the operator name is not necessarily equal to
> the name of the function that implements the operation itself.
>
>   So it should go like this:
>
>    (define (spiffy-operation X Y)
>      (do-something-spiffy-with X Y))
>
>    (define-infix-binary-operator spiffy
>      (right-binding-power 55)
>      ...
>      (procedure spiffy-operation))
>
>    (infix 2 * 3 + 88 spiffy 99)
I don't quite understand this example.  Nevertheless, I still get
the feeling that this is a concept that's unnecessary.

Cheers,
Peter

_______________________________________________
Chicken-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/chicken-users

signature.asc (499 bytes) Download Attachment