[racket-users] Some help with syntax-parse: macro in macro

2015-07-31 Thread Deren Dohoda
Suppose I have a macro (experiment ...) which is intended, among other things, 
to be composed of uses of a macro (collect ...). 

For instance:
(experiment
  (collect ...)
  (collect ...) ...)

To my understanding, collect is not a literal. Can I turn the collect macro 
itself into a syntax class somehow? Should I instead create a dummy literal 
collect for this purpose, and then create a (collect* ...) macro?

Thanks for any advice.

Deren

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Some help with syntax-parse: macro in macro

2015-07-31 Thread Stephen Chang
You might want to specify collect in #:datum-literals if it is not a
defined name.

Can you describe some usage examples? That may lead to better insight
for the implementation.

On Fri, Jul 31, 2015 at 11:49 AM, Deren Dohoda deren.doh...@gmail.com wrote:
 Suppose I have a macro (experiment ...) which is intended, among other 
 things, to be composed of uses of a macro (collect ...).

 For instance:
 (experiment
   (collect ...)
   (collect ...) ...)

 To my understanding, collect is not a literal. Can I turn the collect macro 
 itself into a syntax class somehow? Should I instead create a dummy literal 
 collect for this purpose, and then create a (collect* ...) macro?

 Thanks for any advice.

 Deren

 --
 You received this message because you are subscribed to the Google Groups 
 Racket Users group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to racket-users+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Some help with syntax-parse: macro in macro

2015-07-31 Thread Deren Dohoda
Hi Stephen,

At the moment, collect is syntax, itself defined through syntax-parse. So
you suggest making collect a literal and changing the underlying macro
name?

It's part of a #lang experiment I'm writing which manages a series of
actions from a controller. The file, when required, provides a (run
controller model) procedure which takes a controller for executing (collect
...) actions and a model to store the data returned by the (collect ...)
output.

Right now what I have is something like this with some cluttering details
omitted
#lang experiment
(define-experiment
  (collect uv #:points 10 #:seconds 2) ; collect a point every 2 seconds 10
times
  (collect uv #:points 10 #:minutes 30)
  ...)

But it does no checking that it is called with anything other than
(define-experiment exps ...) which is Not Good.

This will eventually morph into something much more detailed, like
#lang experiment
(define-experiment
  (with-reference ; optional
(with-standard ; optional
  (collect uv #:points 10 #:seconds 10)
  (collect uv #:points 20 #:minutes 1)))
  (with-reference ; optional
(collect uv #:points 10 #:seconds 10)
(collect uv #:points 20 #:minutes 1)
(collect uv #:points 30 #:hours 1)))

And the (define-experiment ...) macro will need to reorder all this so it
makes sense in how a person interacts with a device. Describing an
experiment and running it are usually very different! So whatever strategy
is adopted for collect will multiply quickly.

I remember reading about how there are some gotchas with treating macro
names as literals in patterns (maybe this is a syntax-case problem?) and I
wanted to avoid just assuming things.

Deren

On Fri, Jul 31, 2015 at 12:05 PM, Stephen Chang stch...@ccs.neu.edu wrote:

 You might want to specify collect in #:datum-literals if it is not a
 defined name.

 Can you describe some usage examples? That may lead to better insight
 for the implementation.

 On Fri, Jul 31, 2015 at 11:49 AM, Deren Dohoda deren.doh...@gmail.com
 wrote:
  Suppose I have a macro (experiment ...) which is intended, among other
 things, to be composed of uses of a macro (collect ...).
 
  For instance:
  (experiment
(collect ...)
(collect ...) ...)
 
  To my understanding, collect is not a literal. Can I turn the collect
 macro itself into a syntax class somehow? Should I instead create a dummy
 literal collect for this purpose, and then create a (collect* ...) macro?
 
  Thanks for any advice.
 
  Deren
 
  --
  You received this message because you are subscribed to the Google
 Groups Racket Users group.
  To unsubscribe from this group and stop receiving emails from it, send
 an email to racket-users+unsubscr...@googlegroups.com.
  For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.