Re: [racket-users] puzzled by date / date*

2016-09-22 Thread 'John Clements' via Racket Users

> On Sep 22, 2016, at 12:38, Geoffrey Knauth  wrote:
> 
> Now I see how silly I was in what I wrote above.  In each case I specified 
> time 14:51 and got 18:51, which means it is still interpreting my input as 
> local time.  I want to be able to specify 1851Z and have it come out 1851Z, 
> not 2251Z.  I hope this makes sense.

doesn’t ‘find-seconds’ do that?

#lang racket

(require racket/date)

(define d1 (find-seconds 0 51 14 22 9 2016 #f))

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


signature.asc
Description: PGP signature


Re: [racket-users] [ANN] New package: live-free-or-die

2016-09-22 Thread Leif Andersen
> Also, with typed/racket/unsafe the optimizer *is* still run, so that's
not any better *unless* you selectively choose what you want to be unsafe.

Woops, you are absolutely correct, I meant:

typed/racket/no-check


~Leif Andersen

On Thu, Sep 22, 2016 at 10:27 PM, Alex Knauth  wrote:

>
> On Sep 22, 2016, at 9:39 PM, Jay McCarthy  wrote:
>
> If I knew how, I'd do unsafe-in, but I just know how to fake a typed
> context. The whole point is to use the optimizer so libraries like math are
> usable.
>
>
> Libraries like math/array would still be usable without the optimizer.
>
> What you really want is a version of require (or a require transformer)
> that would allow untyped code to *selectively* unsafely require typed code.
> I would want to import as few things unsafely as possible.
>
> It's impossible to choose what to be unsafe about if it's an
> all-or-nothing imperative flag like that.
>
> On Friday, September 23, 2016, Leif Andersen 
> wrote:
>
>> Umm...if you're going to do this, why is it imperative, and not a require
>> transformer?
>>
>> Also, I kind of agree with Matthias here...sigh. :'( Like, as far as I
>> can tell, this is even worse then typed/racket/unsafe, as the optimizer is
>> still run. O_o
>>
>
> Also, with typed/racket/unsafe the optimizer *is* still run, so that's not
> any better *unless* you selectively choose what you want to be unsafe.
>
> This is worse, but not because of the optimizer; because of the
> all-or-nothing part.
>
> Alex Knauth
>
>

-- 
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] [ANN] New package: live-free-or-die

2016-09-22 Thread Alex Knauth

> On Sep 22, 2016, at 9:39 PM, Jay McCarthy  wrote:
> 
> If I knew how, I'd do unsafe-in, but I just know how to fake a typed context. 
> The whole point is to use the optimizer so libraries like math are usable. 

Libraries like math/array would still be usable without the optimizer. 

What you really want is a version of require (or a require transformer) that 
would allow untyped code to *selectively* unsafely require typed code. I would 
want to import as few things unsafely as possible.

It's impossible to choose what to be unsafe about if it's an all-or-nothing 
imperative flag like that.

> On Friday, September 23, 2016, Leif Andersen  > wrote:
> Umm...if you're going to do this, why is it imperative, and not a require 
> transformer?
> 
> Also, I kind of agree with Matthias here...sigh. :'( Like, as far as I can 
> tell, this is even worse then typed/racket/unsafe, as the optimizer is still 
> run. O_o

Also, with typed/racket/unsafe the optimizer *is* still run, so that's not any 
better *unless* you selectively choose what you want to be unsafe.

This is worse, but not because of the optimizer; because of the all-or-nothing 
part.

Alex Knauth

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


[racket-users] Re: [ANN] New package: live-free-or-die

2016-09-22 Thread Jay McCarthy
If I knew how, I'd do unsafe-in, but I just know how to fake a typed
context. The whole point is to use the optimizer so libraries like math are
usable.

Jay

On Friday, September 23, 2016, Leif Andersen  wrote:

> Umm...if you're going to do this, why is it imperative, and not a require
> transformer?
>
> Also, I kind of agree with Matthias here...sigh. :'( Like, as far as I can
> tell, this is even worse then typed/racket/unsafe, as the optimizer is
> still run. O_o
>
>
>
> ~Leif Andersen
>
> On Thu, Sep 22, 2016 at 9:16 PM, Matthew Butterick  > wrote:
>
>> On Sep 22, 2016, at 9:23 AM, Matthias Felleisen > > wrote:
>>
>> > I checked the calendar, because I thought I had gone into hibernation
>> > and woken up on April Fool’s day.
>>
>>
>> Those of us who have lived in New Hampshire take this matter quite
>> seriously.
>>
>> We've also learned to endure the teasing of people who live in
>> Taxachusetts.
>>
>> I raise a butternut munchkin to Jay.
>>
>> --
>> 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.
>


-- 
Jay McCarthy
Associate Professor
PLT @ CS @ UMass Lowell
http://jeapostrophe.github.io

   "Wherefore, be not weary in well-doing,
  for ye are laying the foundation of a great work.
And out of small things proceedeth that which is great."
  - D 64:33

-- 
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] RacketCon: thanks!

2016-09-22 Thread Leif Andersen
> I wish every day could be RacketCon.

Oh god...while that would be fun...the AV nightmare...we'd need a dedicated
AV team to handle that... :/


~Leif Andersen

On Thu, Sep 22, 2016 at 9:08 PM, Matthew Butterick  wrote:

> I agree. A terrific event. I wish every day could be RacketCon.
>
>
> On Sep 21, 2016, at 2:55 PM, 'John Clements' via Racket Users <
> racket-users@googlegroups.com> wrote:
>
> > SO glad I went to RacketCon this year. Great to meet you, great to see
> you. A bunch of community members now have faces in my mind.
> >
> > Many thanks for all the hard work from Vincent, Leif, Matthew B., etc.
> etc. etc.
>
> --
> 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] [ANN] New package: live-free-or-die

2016-09-22 Thread Leif Andersen
Umm...if you're going to do this, why is it imperative, and not a require
transformer?

Also, I kind of agree with Matthias here...sigh. :'( Like, as far as I can
tell, this is even worse then typed/racket/unsafe, as the optimizer is
still run. O_o



~Leif Andersen

On Thu, Sep 22, 2016 at 9:16 PM, Matthew Butterick  wrote:

> On Sep 22, 2016, at 9:23 AM, Matthias Felleisen 
> wrote:
>
> > I checked the calendar, because I thought I had gone into hibernation
> > and woken up on April Fool’s day.
>
>
> Those of us who have lived in New Hampshire take this matter quite
> seriously.
>
> We've also learned to endure the teasing of people who live in
> Taxachusetts.
>
> I raise a butternut munchkin to Jay.
>
> --
> 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] [ANN] New package: live-free-or-die

2016-09-22 Thread Matthew Butterick
On Sep 22, 2016, at 9:23 AM, Matthias Felleisen  wrote:

> I checked the calendar, because I thought I had gone into hibernation 
> and woken up on April Fool’s day. 


Those of us who have lived in New Hampshire take this matter quite seriously. 

We've also learned to endure the teasing of people who live in Taxachusetts.

I raise a butternut munchkin to Jay.

-- 
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] RacketCon: thanks!

2016-09-22 Thread Matthew Butterick
I agree. A terrific event. I wish every day could be RacketCon.


On Sep 21, 2016, at 2:55 PM, 'John Clements' via Racket Users 
 wrote:

> SO glad I went to RacketCon this year. Great to meet you, great to see you. A 
> bunch of community members now have faces in my mind. 
> 
> Many thanks for all the hard work from Vincent, Leif, Matthew B., etc. etc. 
> etc.

-- 
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] Custom command completion?

2016-09-22 Thread Sam Tobin-Hochstadt
Right now, `raco` doesn't have anything like that, for either built-in
or custom commands. What there is currently is this code:
https://github.com/racket/shell-completion which basically hard-codes
options, and calls `racket` to complete `raco` commands. It knows
specifically about `raco planet` so that it can complete for that.

You could write something that used `get-info` to get the relevant
information from a spec like you describe there, and add it to that
code. A warning: those completion scripts start slower than I'd like
when I use them, because of Racket's startup time.

Sam

On Thu, Sep 22, 2016 at 5:37 PM, Jack Firth  wrote:
> Right, but shell completion varies by shell implementaiton so I was hoping 
> that raco
> would have some built-in completion script that racket installs, and that 
> script would
> dispatch to some racket code that implements custom completion for a 
> particular command
> I'd like to stick something like this in an info.rkt file:
>
> (define raco-commands
>   '(("some-command" command-impl-mod "Some command" 20 #:complete-with 
> (completion-impl-mod completion-procedure-binding
>
> ...and have `raco` setup a single completion script on installation that 
> notices when you're
> completing a command with custom completion and dispatches to it. That way I 
> don't have
> to figure out how to get raco pkg install to put shell scripts in the right 
> places.
>
> --
> 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] Custom command completion?

2016-09-22 Thread Jack Firth
Right, but shell completion varies by shell implementaiton so I was hoping that 
raco
would have some built-in completion script that racket installs, and that 
script would
dispatch to some racket code that implements custom completion for a particular 
command
I'd like to stick something like this in an info.rkt file:

(define raco-commands
  '(("some-command" command-impl-mod "Some command" 20 #:complete-with 
(completion-impl-mod completion-procedure-binding

...and have `raco` setup a single completion script on installation that 
notices when you're
completing a command with custom completion and dispatches to it. That way I 
don't have
to figure out how to get raco pkg install to put shell scripts in the right 
places.

-- 
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] Custom command completion?

2016-09-22 Thread Sam Tobin-Hochstadt
Shell completion (at least for bash, which I know best) isn't handled
by `raco` at all -- it's all done in bash. So I think you'd have to do
some shell script hacking.

Sam

On Thu, Sep 22, 2016 at 5:30 PM, Jack Firth  wrote:
> If I have a `raco` command that I want to add command completion too, how can 
> I do that?
> Ideally I'm looking for some way to tell raco to dispatch to a particular 
> function whenever
> shell completion is requested for any uses of my raco command. If there is no 
> way to do this
> right now, what would I need to build for it?
>
> --
> 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.


[racket-users] Custom command completion?

2016-09-22 Thread Jack Firth
If I have a `raco` command that I want to add command completion too, how can I 
do that?
Ideally I'm looking for some way to tell raco to dispatch to a particular 
function whenever
shell completion is requested for any uses of my raco command. If there is no 
way to do this
right now, what would I need to build for it?

-- 
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] sequence of moments?

2016-09-22 Thread Jon Zeppieri


> On Sep 22, 2016, at 3:57 PM, Jon Zeppieri  wrote:
> 
> 
> 
>>> On Sep 22, 2016, at 3:43 PM, Geoffrey Knauth  wrote:
>>> 
>>> On Thursday, September 22, 2016 at 3:17:50 PM UTC-4, Jon Zeppieri wrote:
>>> Oh, sorry: I thought you wanted a sequence of moments from start and end 
>>> *seconds*. If you're starting with moments, you could just repeatedly add a 
>>> second (if that's the increment you want).
>> 
>> The increment is a day (specifically 2016-01-01 through 2016-08-31, 00Z each 
>> day.  I was looking for a sequence so I could convert it a list and then map 
>> a function that takes a moment over the list.
> 
> I'm on my phone right now, so I can't actually test any code, but it should 
> be pretty straightforward to create this:
> 
> (make-do-sequence
>  values
>  (lambda (x) (+days x 1))
>  start-moment
>  (lambda (x) (moment  #f
>  #f)
> 
> You may want to use an explicit offset resolver with +days, in case you land 
> on a moment that doesn't exist in your chosen time zone.
> 

Oh, but if you're just using UTC moments, you might consider using datetime 
instead of moment. That way you don't need to worry about discontinuous 
timelines at all.


>> 
>> -- 
>> 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] sequence of moments?

2016-09-22 Thread Geoffrey Knauth
Looks great, thank you!

-- 
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] sequence of moments?

2016-09-22 Thread Jon Zeppieri


> On Sep 22, 2016, at 3:43 PM, Geoffrey Knauth  wrote:
> 
>> On Thursday, September 22, 2016 at 3:17:50 PM UTC-4, Jon Zeppieri wrote:
>> Oh, sorry: I thought you wanted a sequence of moments from start and end 
>> *seconds*. If you're starting with moments, you could just repeatedly add a 
>> second (if that's the increment you want).
> 
> The increment is a day (specifically 2016-01-01 through 2016-08-31, 00Z each 
> day.  I was looking for a sequence so I could convert it a list and then map 
> a function that takes a moment over the list.

I'm on my phone right now, so I can't actually test any code, but it should be 
pretty straightforward to create this:

(make-do-sequence
  values
  (lambda (x) (+days x 1))
  start-moment
  (lambda (x) (moment 
> -- 
> 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] sequence of moments?

2016-09-22 Thread Geoffrey Knauth
On Thursday, September 22, 2016 at 3:17:50 PM UTC-4, Jon Zeppieri wrote:
> Oh, sorry: I thought you wanted a sequence of moments from start and end 
> *seconds*. If you're starting with moments, you could just repeatedly add a 
> second (if that's the increment you want).

The increment is a day (specifically 2016-01-01 through 2016-08-31, 00Z each 
day.  I was looking for a sequence so I could convert it a list and then map a 
function that takes a moment over the list.

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


[racket-users] Re: puzzled by date / date*

2016-09-22 Thread Geoffrey Knauth
Now I see how silly I was in what I wrote above.  In each case I specified time 
14:51 and got 18:51, which means it is still interpreting my input as local 
time.  I want to be able to specify 1851Z and have it come out 1851Z, not 
2251Z.  I hope this makes sense.

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


[racket-users] puzzled by date / date*

2016-09-22 Thread Geoffrey Knauth
After not getting what I wanted (I got epoch seconds reflecting an 
interpretation of my input as Local Time), I got what I wanted (epoch seconds 
interpreting my input as UTC), but now that it is working, using date* vs. 
date, I'm not sure why, when I vary inputs, I see no change in the output.

(define d1 (date* 0 51 14 22 9 2016 0 0 #f 0 0 "GMT"))
(date*->seconds d1)
; 1474570260 which is Thu, 22 Sep 2016 18:51:00 GMT per 
http://www.epochconverter.com/

(define d2 (date* 0 51 14 22 9 2016 0 0 #f 0 0 "UTC"))
(date*->seconds d2)
; 1474570260 which is Thu, 22 Sep 2016 18:51:00 GMT per 
http://www.epochconverter.com/

(define d3 (date* 0 51 14 22 9 2016 0 0 #f 0 0 "PartyTime!"))
(date*->seconds d3)
; 1474570260 which is Thu, 22 Sep 2016 18:51:00 GMT per 
http://www.epochconverter.com/

(define d4 (date* 0 51 14 22 9 2016 0 0 #f -14400 0 "You have a standard 
galactic week to respond. Sorry."))
(date*->seconds d4)
; 1474570260 which is Thu, 22 Sep 2016 18:51:00 GMT per 
http://www.epochconverter.com/

(define d5 (date* 0 51 14 22 9 2016 0 0 #f 14400 0 "Time is relative. --AE"))
(date*->seconds d5)
; 1474570260 which is Thu, 22 Sep 2016 18:51:00 GMT per 
http://www.epochconverter.com/

(define d6 (date* 0 51 14 22 9 2016 0 0 #t -14400 0 "You can have anything you 
want, at Alice's Restaurant."))
(date*->seconds d6)
; 1474570260 which is Thu, 22 Sep 2016 18:51:00 GMT per 
http://www.epochconverter.com/

(define d7 (date* 0 51 14 22 9 2016 0 0 #t 0 0 "sigh"))
(date*->seconds d7)
; 1474570260 which is Thu, 22 Sep 2016 18:51:00 GMT per 
http://www.epochconverter.com/

-- 
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] sequence of moments?

2016-09-22 Thread Jon Zeppieri


> On Sep 22, 2016, at 3:12 PM, Jon Zeppieri  wrote:
> 
> 
> 
>> On Sep 22, 2016, at 2:04 PM, Geoffrey Knauth  wrote:
>> 
>> Is it possible to build a sequence of moments?  (require gregor)
>> 
>> I had a sequence of seconds (since the epoch), as in:
>> 
>> (in-range start-seconds end-seconds seconds-in-a-day)
>> 
>> If I use moments, I'm wondering what goes in place of _HMM_:
>> 
>> (in-range start-moment end-moment _HMM_)
> 
> This should be more convenient than it is. There's a posix->datetime, and 
> then you'd have to construct a new moment from the resulting datetime's data, 
> plus a TZ. 
> 
> Internally, there's a function that makes this much easier, but it's not 
> provided. 
> 
> My apologies; I promise that the replacement library will make this easier.
> 
> - Jon
> 
> 

Oh, sorry: I thought you wanted a sequence of moments from start and end 
*seconds*. If you're starting with moments, you could just repeatedly add a 
second (if that's the increment you want).



>> 
>> -- 
>> You received this message because you we 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] sequence of moments?

2016-09-22 Thread Jon Zeppieri


> On Sep 22, 2016, at 2:04 PM, Geoffrey Knauth  wrote:
> 
> Is it possible to build a sequence of moments?  (require gregor)
> 
> I had a sequence of seconds (since the epoch), as in:
> 
>  (in-range start-seconds end-seconds seconds-in-a-day)
> 
> If I use moments, I'm wondering what goes in place of _HMM_:
> 
>  (in-range start-moment end-moment _HMM_)

This should be more convenient than it is. There's a posix->datetime, and then 
you'd have to construct a new moment from the resulting datetime's data, plus a 
TZ. 

Internally, there's a function that makes this much easier, but it's not 
provided. 

My apologies; I promise that the replacement library will make this easier.

- Jon


> 
> -- 
> You received this message because you we 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.


[racket-users] Re: moment->date or moment ... -> ... epoch-seconds

2016-09-22 Thread Jack Firth
On Thursday, September 22, 2016 at 10:55:11 AM UTC-7, Geoffrey Knauth wrote:
> I was using Racket's date. Then I found it was creating a local time when I 
> needed UTC. So I started using moments from (require gregor). Now I'm trying 
> to figure out how to get either a regular date from a moment, or better, how 
> I can get epoch seconds (from 1970-01-01T00:00:00Z) from a moment. I suppose 
> I could compute the since-epoch seconds difference myself, I just don't know 
> if it's in there already and I just missed it.
> 
> Geoff

I believe ->posix[1] is the function you're looking for

[1] 
https://docs.racket-lang.org/gregor/datetime-provider.html?q=gregor#%28def._%28%28lib._gregor%2Fmain..rkt%29._-~3eposix%29%29

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


[racket-users] Re: moment->date or moment ... -> ... epoch-seconds

2016-09-22 Thread Geoffrey Knauth
I solved my immediate problem by going back to dates and using:

(seconds->date secs-n [local-time?]) → date*?
  secs-n : real?
  local-time? : any/c = #t

and supplying #f as local-time.

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


[racket-users] sequence of moments?

2016-09-22 Thread Geoffrey Knauth
Is it possible to build a sequence of moments?  (require gregor)

I had a sequence of seconds (since the epoch), as in:

  (in-range start-seconds end-seconds seconds-in-a-day)

If I use moments, I'm wondering what goes in place of _HMM_:

  (in-range start-moment end-moment _HMM_)

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


[racket-users] moment->date or moment ... -> ... epoch-seconds

2016-09-22 Thread Geoffrey Knauth
I was using Racket's date. Then I found it was creating a local time when I 
needed UTC. So I started using moments from (require gregor). Now I'm trying to 
figure out how to get either a regular date from a moment, or better, how I can 
get epoch seconds (from 1970-01-01T00:00:00Z) from a moment. I suppose I could 
compute the since-epoch seconds difference myself, I just don't know if it's in 
there already and I just missed it.

Geoff

-- 
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] Re: Help with macros

2016-09-22 Thread C K Kashyap
Super!!! ... thanks a ton Jens.
Now I'll go over the docs to understand why it works :)
Regards,
Kashyap

On Thu, Sep 22, 2016 at 8:52 AM, Jens Axel Søgaard 
wrote:

> Here is a bit more.
>
> #lang racket
>
> (require (for-syntax syntax/parse racket/syntax)
>  syntax/parse/define)
>
> (define-simple-macro (define-primitive-application-syntax
> (primitive-name:id arg:id ...))
>   (define-simple-macro (primitive-name arg-expr:expr (... ...))
> (list 'primitive-name arg-expr (... ...
>
> (define-syntax (define-primitive stx)
>   (syntax-parse stx
> [(_ (primitive-name:id arg:id ...) body ...+)
>  #:with table-name (format-id #'primitive-name "~a-property-table"
> #'primitive-name)
>  #'(begin
> (define table-name (hash 'is-prime #t
>  'arg-count (length '(arg ...))
>  'emitter (lambda (arg ...) body ...)))
> (define-primitive-application-syntax (primitive-name arg ...)))]))
>
> (define-primitive (plus x y) (+ x y))
> plus-property-table
>
>
> 2016-09-22 17:36 GMT+02:00 C K Kashyap :
>
>> Thanks Jens ...
>> I think I'm almost thereI get this "primitive-name: pattern variable
>> cannot be used outside of a template in: primitive-name" at the very end
>> now
>>
>> (require syntax/parse/define)
>>
>> (define-simple-macro (define-primitive-application-syntax
>> (primitive-name:id arg:id ...))
>>   (define-simple-macro (primitive-name arg-expr:expr (... ...))
>> (list 'primitive-name arg-expr (... ...
>>
>> (define-syntax (define-primitive stx)
>>   (syntax-parse stx
>> [(_ (primitive-name:id arg:id ...) body ...+)
>>  #:with table-name
>> (format-id #'primitive-name "~a-property-table"
>> #'primitive-name)
>>  #'(begin
>> (define table-name (hash 'is-prime #t
>> 'arg-count (length '(arg ...))
>> 'emitter (lambda (arg ...) body ...
>>
>> (define-primitive-application-syntax (primitive-name arg
>> ...))])) ; ERROR here
>>
>>
>>
>> On Thu, Sep 22, 2016 at 8:30 AM, Jens Axel Søgaard > > wrote:
>>
>>> Remove the ().
>>>
>>> The construct syntax-case needs the () which in general can be a list of
>>> identifiers,
>>> but most often an empty list, (), is used. Any identifiers in the list
>>> are treated
>>> by syntax-case as a literal.
>>>
>>> The construct syntax-parse does not use a list of identifiers. It uses
>>> an alternative
>>> way of specifying literal identifiers.
>>>
>>> /Jens Axel
>>>
>>>
>>> 2016-09-22 17:27 GMT+02:00 C K Kashyap :
>>>
 Thanks Andrew ... I got past that error. I now get an error below -
 " syntax-parse: expected clause in: ()"

 (define-syntax (define-primitive stx)
   (syntax-parse stx () ; ERROR
 [(_ (primitive-name:id arg:id ...) body ...+)
  #:with table-name
 (format-id #'primitive-name "~a-property-table"
 #'primitive-name)
  #'(begin
 (define table-name (hash 'is-prime #t
 'arg-count (length '(arg ...))
 'emitter (lambda (arg ...) body ...

 (define-primitive-application-syntax (primitive-name arg
 ...))]))

 On Thu, Sep 22, 2016 at 8:21 AM, Andrew Kent  wrote:

> The '...' that is causing the error is a '...' at the level of the
> _initial/outer_ macro (define-primitive-application-syntax), and so
> your final use of '...' is trying to splice a parameter of the _initial
> macro_ (define-primitive-application-syntax), but you are actually
> trying to output a _literal_ '...' in the syntax you are generating 
> because
> you want it to be a part of the macro you are generating/defining via
> define-primitive-application-syntax (i.e. primitive-name).
>
> TL;DR you want this instead I believe:
>
> …
> (define-simple-macro (define-primitive-application-syntax
> (primitive-name:id arg:id ...))
>   (define-simple-macro (primitive-name arg-expr:expr (... ...))
> (list 'primitive-name arg-expr (... ...
>
> --
> 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.

>>>
>>>
>>>
>>> --
>>> --
>>> Jens Axel Søgaard
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Racket Users" 

Re: [racket-users] [ANN] New package: live-free-or-die

2016-09-22 Thread Matthias Felleisen

I checked the calendar, because I thought I had gone into hibernation 
and woken up on April Fool’s day. 

Argh. 




> On Sep 21, 2016, at 10:33 PM, Jay McCarthy  wrote:
> 
> I've just put a new package on the server: live-free-or-die
> 
> This package lets you escape from Typed Racket's contracts.
> 
> --
> 
> Here's a little example:
> 
> Suppose that "server.rkt" is:
> 
> ```
> #lang typed/racket
> 
> (: f ((Listof Float) -> Float))
> (define (f l)
>  (cond
>[(empty? l)
> 0.0]
>[else
> (+ (first l)
>(f (rest l)))]))
> 
> (provide f)
> ```
> 
> And that "client.rkt" is:
> 
> ```
> #lang racket/base
> (require live-free-or-die)
> (live-free-or-die!)
> 
> (require "server.rkt")
> (f (vector 1 2 3))
> ```
> 
> Then this is what you get when you run the program:
> 
> $ racket "client.rkt"
> zsh: segmentation fault  racket "client.rkt"
> 
> For your convenience, `live-free-or-die!` is also aliased to
> `Doctor-Tobin-Hochstadt:Tear-down-this-wall!`
> 
> --
> 
> Enjoy!
> 
> -- 
> Jay McCarthy
> Associate Professor
> PLT @ CS @ UMass Lowell
> http://jeapostrophe.github.io
> 
>   "Wherefore, be not weary in well-doing,
>  for ye are laying the foundation of a great work.
> And out of small things proceedeth that which is great."
>  - D 64:33
> 
> -- 
> 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] Re: Help with macros

2016-09-22 Thread Jens Axel Søgaard
Here is a bit more.

#lang racket

(require (for-syntax syntax/parse racket/syntax)
 syntax/parse/define)

(define-simple-macro (define-primitive-application-syntax
(primitive-name:id arg:id ...))
  (define-simple-macro (primitive-name arg-expr:expr (... ...))
(list 'primitive-name arg-expr (... ...

(define-syntax (define-primitive stx)
  (syntax-parse stx
[(_ (primitive-name:id arg:id ...) body ...+)
 #:with table-name (format-id #'primitive-name "~a-property-table"
#'primitive-name)
 #'(begin
(define table-name (hash 'is-prime #t
 'arg-count (length '(arg ...))
 'emitter (lambda (arg ...) body ...)))
(define-primitive-application-syntax (primitive-name arg ...)))]))

(define-primitive (plus x y) (+ x y))
plus-property-table


2016-09-22 17:36 GMT+02:00 C K Kashyap :

> Thanks Jens ...
> I think I'm almost thereI get this "primitive-name: pattern variable
> cannot be used outside of a template in: primitive-name" at the very end
> now
>
> (require syntax/parse/define)
>
> (define-simple-macro (define-primitive-application-syntax
> (primitive-name:id arg:id ...))
>   (define-simple-macro (primitive-name arg-expr:expr (... ...))
> (list 'primitive-name arg-expr (... ...
>
> (define-syntax (define-primitive stx)
>   (syntax-parse stx
> [(_ (primitive-name:id arg:id ...) body ...+)
>  #:with table-name
> (format-id #'primitive-name "~a-property-table"
> #'primitive-name)
>  #'(begin
> (define table-name (hash 'is-prime #t
> 'arg-count (length '(arg ...))
> 'emitter (lambda (arg ...) body ...
>
> (define-primitive-application-syntax (primitive-name arg ...))]))
> ; ERROR here
>
>
>
> On Thu, Sep 22, 2016 at 8:30 AM, Jens Axel Søgaard 
> wrote:
>
>> Remove the ().
>>
>> The construct syntax-case needs the () which in general can be a list of
>> identifiers,
>> but most often an empty list, (), is used. Any identifiers in the list
>> are treated
>> by syntax-case as a literal.
>>
>> The construct syntax-parse does not use a list of identifiers. It uses an
>> alternative
>> way of specifying literal identifiers.
>>
>> /Jens Axel
>>
>>
>> 2016-09-22 17:27 GMT+02:00 C K Kashyap :
>>
>>> Thanks Andrew ... I got past that error. I now get an error below -
>>> " syntax-parse: expected clause in: ()"
>>>
>>> (define-syntax (define-primitive stx)
>>>   (syntax-parse stx () ; ERROR
>>> [(_ (primitive-name:id arg:id ...) body ...+)
>>>  #:with table-name
>>> (format-id #'primitive-name "~a-property-table"
>>> #'primitive-name)
>>>  #'(begin
>>> (define table-name (hash 'is-prime #t
>>> 'arg-count (length '(arg ...))
>>> 'emitter (lambda (arg ...) body ...
>>>
>>> (define-primitive-application-syntax (primitive-name arg
>>> ...))]))
>>>
>>> On Thu, Sep 22, 2016 at 8:21 AM, Andrew Kent  wrote:
>>>
 The '...' that is causing the error is a '...' at the level of the
 _initial/outer_ macro (define-primitive-application-syntax), and so
 your final use of '...' is trying to splice a parameter of the _initial
 macro_ (define-primitive-application-syntax), but you are actually
 trying to output a _literal_ '...' in the syntax you are generating because
 you want it to be a part of the macro you are generating/defining via
 define-primitive-application-syntax (i.e. primitive-name).

 TL;DR you want this instead I believe:

 …
 (define-simple-macro (define-primitive-application-syntax
 (primitive-name:id arg:id ...))
   (define-simple-macro (primitive-name arg-expr:expr (... ...))
 (list 'primitive-name arg-expr (... ...

 --
 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.
>>>
>>
>>
>>
>> --
>> --
>> Jens Axel Søgaard
>>
>> --
>> 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.
>>
>
>


-- 
-- 
Jens Axel Søgaard

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe 

Re: [racket-users] Re: Help with macros

2016-09-22 Thread C K Kashyap
Thanks Jens ...
I think I'm almost thereI get this "primitive-name: pattern variable
cannot be used outside of a template in: primitive-name" at the very end
now

(require syntax/parse/define)

(define-simple-macro (define-primitive-application-syntax
(primitive-name:id arg:id ...))
  (define-simple-macro (primitive-name arg-expr:expr (... ...))
(list 'primitive-name arg-expr (... ...

(define-syntax (define-primitive stx)
  (syntax-parse stx
[(_ (primitive-name:id arg:id ...) body ...+)
 #:with table-name
(format-id #'primitive-name "~a-property-table"
#'primitive-name)
 #'(begin
(define table-name (hash 'is-prime #t
'arg-count (length '(arg ...))
'emitter (lambda (arg ...) body ...

(define-primitive-application-syntax (primitive-name arg ...))])) ;
ERROR here



On Thu, Sep 22, 2016 at 8:30 AM, Jens Axel Søgaard 
wrote:

> Remove the ().
>
> The construct syntax-case needs the () which in general can be a list of
> identifiers,
> but most often an empty list, (), is used. Any identifiers in the list are
> treated
> by syntax-case as a literal.
>
> The construct syntax-parse does not use a list of identifiers. It uses an
> alternative
> way of specifying literal identifiers.
>
> /Jens Axel
>
>
> 2016-09-22 17:27 GMT+02:00 C K Kashyap :
>
>> Thanks Andrew ... I got past that error. I now get an error below -
>> " syntax-parse: expected clause in: ()"
>>
>> (define-syntax (define-primitive stx)
>>   (syntax-parse stx () ; ERROR
>> [(_ (primitive-name:id arg:id ...) body ...+)
>>  #:with table-name
>> (format-id #'primitive-name "~a-property-table"
>> #'primitive-name)
>>  #'(begin
>> (define table-name (hash 'is-prime #t
>> 'arg-count (length '(arg ...))
>> 'emitter (lambda (arg ...) body ...
>>
>> (define-primitive-application-syntax (primitive-name arg ...))]))
>>
>> On Thu, Sep 22, 2016 at 8:21 AM, Andrew Kent  wrote:
>>
>>> The '...' that is causing the error is a '...' at the level of the
>>> _initial/outer_ macro (define-primitive-application-syntax), and so
>>> your final use of '...' is trying to splice a parameter of the _initial
>>> macro_ (define-primitive-application-syntax), but you are actually
>>> trying to output a _literal_ '...' in the syntax you are generating because
>>> you want it to be a part of the macro you are generating/defining via
>>> define-primitive-application-syntax (i.e. primitive-name).
>>>
>>> TL;DR you want this instead I believe:
>>>
>>> …
>>> (define-simple-macro (define-primitive-application-syntax
>>> (primitive-name:id arg:id ...))
>>>   (define-simple-macro (primitive-name arg-expr:expr (... ...))
>>> (list 'primitive-name arg-expr (... ...
>>>
>>> --
>>> 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.
>>
>
>
>
> --
> --
> Jens Axel Søgaard
>
> --
> 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] Re: Help with macros

2016-09-22 Thread Jens Axel Søgaard
Remove the ().

The construct syntax-case needs the () which in general can be a list of
identifiers,
but most often an empty list, (), is used. Any identifiers in the list are
treated
by syntax-case as a literal.

The construct syntax-parse does not use a list of identifiers. It uses an
alternative
way of specifying literal identifiers.

/Jens Axel


2016-09-22 17:27 GMT+02:00 C K Kashyap :

> Thanks Andrew ... I got past that error. I now get an error below -
> " syntax-parse: expected clause in: ()"
>
> (define-syntax (define-primitive stx)
>   (syntax-parse stx () ; ERROR
> [(_ (primitive-name:id arg:id ...) body ...+)
>  #:with table-name
> (format-id #'primitive-name "~a-property-table"
> #'primitive-name)
>  #'(begin
> (define table-name (hash 'is-prime #t
> 'arg-count (length '(arg ...))
> 'emitter (lambda (arg ...) body ...
>
> (define-primitive-application-syntax (primitive-name arg ...))]))
>
> On Thu, Sep 22, 2016 at 8:21 AM, Andrew Kent  wrote:
>
>> The '...' that is causing the error is a '...' at the level of the
>> _initial/outer_ macro (define-primitive-application-syntax), and so your
>> final use of '...' is trying to splice a parameter of the _initial macro_
>> (define-primitive-application-syntax), but you are actually trying to
>> output a _literal_ '...' in the syntax you are generating because you want
>> it to be a part of the macro you are generating/defining via
>> define-primitive-application-syntax (i.e. primitive-name).
>>
>> TL;DR you want this instead I believe:
>>
>> …
>> (define-simple-macro (define-primitive-application-syntax
>> (primitive-name:id arg:id ...))
>>   (define-simple-macro (primitive-name arg-expr:expr (... ...))
>> (list 'primitive-name arg-expr (... ...
>>
>> --
>> 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.
>



-- 
-- 
Jens Axel Søgaard

-- 
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] Re: Help with macros

2016-09-22 Thread C K Kashyap
Thanks Andrew ... I got past that error. I now get an error below -
" syntax-parse: expected clause in: ()"

(define-syntax (define-primitive stx)
  (syntax-parse stx () ; ERROR
[(_ (primitive-name:id arg:id ...) body ...+)
 #:with table-name
(format-id #'primitive-name "~a-property-table"
#'primitive-name)
 #'(begin
(define table-name (hash 'is-prime #t
'arg-count (length '(arg ...))
'emitter (lambda (arg ...) body ...

(define-primitive-application-syntax (primitive-name arg ...))]))

On Thu, Sep 22, 2016 at 8:21 AM, Andrew Kent  wrote:

> The '...' that is causing the error is a '...' at the level of the
> _initial/outer_ macro (define-primitive-application-syntax), and so your
> final use of '...' is trying to splice a parameter of the _initial macro_
> (define-primitive-application-syntax), but you are actually trying to
> output a _literal_ '...' in the syntax you are generating because you want
> it to be a part of the macro you are generating/defining via
> define-primitive-application-syntax (i.e. primitive-name).
>
> TL;DR you want this instead I believe:
>
> …
> (define-simple-macro (define-primitive-application-syntax
> (primitive-name:id arg:id ...))
>   (define-simple-macro (primitive-name arg-expr:expr (... ...))
> (list 'primitive-name arg-expr (... ...
>
> --
> 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.


[racket-users] Re: Help with macros

2016-09-22 Thread Andrew Kent
The '...' that is causing the error is a '...' at the level of the 
_initial/outer_ macro (define-primitive-application-syntax), and so your final 
use of '...' is trying to splice a parameter of the _initial macro_ 
(define-primitive-application-syntax), but you are actually trying to output a 
_literal_ '...' in the syntax you are generating because you want it to be a 
part of the macro you are generating/defining via 
define-primitive-application-syntax (i.e. primitive-name).

TL;DR you want this instead I believe:

…
(define-simple-macro (define-primitive-application-syntax (primitive-name:id 
arg:id ...))
  (define-simple-macro (primitive-name arg-expr:expr (... ...))
(list 'primitive-name arg-expr (... ...

-- 
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] Re: Help with macros

2016-09-22 Thread C K Kashyap
Thank you so much Jack,

This certainly helps! I was following the tutorial
http://www.greghendershott.com/fear-of-macros/ - It turns out that it too
recommends syntax-parse at the very end :)

When I tried this, I got "syntax: no pattern variables before ellipsis in
template in: ..."

(require syntax/parse/define)


(define-simple-macro (define-primitive-application-syntax
(primitive-name:id arg:id ...))
  (define-simple-macro (primitive-name arg-expr:expr (... ...))
(list 'primitive-name arg-expr ...))) ; ERROR here

(define-syntax (define-primitive stx)
  (syntax-parse stx ()
[(_ (primitive-name:id arg:id ...) body ...+)
 #:with table-name
(format-id #'primitive-name "~a-property-table"
#'primitive-name)
 #'(begin
(define table-name (hash 'is-prime #t
'arg-count (length '(arg ...))
'emitter (lambda (arg ...) body ...

(define-primitive-application-syntax (primitive-name arg ...))]))




Regards,
Kashyap

On Wed, Sep 21, 2016 at 2:05 PM, Jack Firth  wrote:

> Your `syntax-rules` macro-defined macro uses the name "b", but that name
> is already bound by the `syntax-case` step of `define-primitive`. So your
> expansion looks like this:
>
> (define-primitive (add a b c d) (print (+ a b c d)))
>
> =>
>
> (begin
>   (define add-property-table (make-hash))
>   (hash-set! add-property-table 'is-prime #t)
>   (hash-set! add-property-table 'arg-count (length '(a b c d)))
>   (hash-set! add-property-table 'emitter (lambda (a b c d) (print (+ a b c
> d)))
>   (define-syntax add
> (syntax-rules ()
>   ((add a) (list 'add a))
>   ((add a (print (+ a b c d))) (list 'add a (print (+ a b c d)))
>
> Note that `add` macro you create uses `(print (+ a b c d))` instead of `b`
> in the second pattern. You can rectify this by using a different name.
>
> However, here are a couple other notes to consider:
>
> - `syntax-case` is considered somewhat obsolete in the Racket community,
> `syntax-parse` allows for better-specified patterns and error messages.
> Your example with syntax parse would look like (synatx-parse stx [(_
> (primitive-name arg*:id ...) b:expr ...+) ]). This makes
> your macro throw a syntax error if anything used for `arg*` isn't an
> identifier, or if non-expression syntax (like a keyword) is used for `b`.
> - Construction of the "-property-table" identifier can be done much more
> concisely with `format-id`, making your DS/SS/SD shorthands unnecessary
> - Avoid mutable data structures unless you know you need mutation. Your
> `hash-set!` code can be easily expressed with a plain call to `hash`:
>
> (define table-name
>   (hash 'is-prime #t
> 'arg-count (length '(a b c d))
> 'emitter (lambda (a b c d) (print (+ a b c d)
>
> - When a macro defines a macro, the elipses (...) refer to the outer macro
> template. This is why you couldn't use ... in the `syntax-rules` macro you
> attempted to create. You can get around this by using two ellipses grouped
> together, like this:
>
> (define-syntax primitive-name
>   (syntax-rules ()
> ((primitive-name a (... ...)) (list 'primitive-name a (... ...)
>
> - It's considered good Racket style to use brackets for the clauses of
> `syntax-rules` / `syntax-case` / `syntax-parse`, like this:
>
> (syntax-case stx ()
>   [(pattern ...) body ...]
>   [(pattern ...) body ...]))
>
> - If you (require syntax/parse/define) you can use `define-simple-macro`
> (badly named, we know) in place of `define-syntax-rule`. They function
> similarly, but the former uses `syntax/parse` and thus lets you specify
> constraints like "this should be an identifier".
> - The macro you create for each primitive is exactly the same. It may be
> simpler to factor that out into a separate macro:
>
> (define-simple-macro (define-primitive-application-syntax
> (primitive-name:id arg:id ...))
>   (define-simple-macro (primitive-name arg-expr:expr (... ...))
> (list 'primitive-name arg-expr ...)))
>
> (define-syntax (define-primitive stx)
>   (syntax-parse stx ()
> [(_ (primitive-name:id arg:id ...) body ...+)
>  #:with table-name
> (format-id #'primitive-name "~a-property-table"
> #'primitive-name)
>  #'(begin
> (define table-name )
> (define-primitive-application-syntax (primitive-name arg ...))]))
>
> Hope this helps!
>
> --
> 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] Correcting documentation à la Beautiful Racket

2016-09-22 Thread Greg Trzeciak
Agree that adding more dependencies may be problematic. 
One solution would be instead of sending emails, to make this a true github 
issue creation method which can be done with a simple prepopulated HTML link, 
eg. (here title:"foo" and body:"bar"):
https://github.com/mbutterick/pollen/issues/new?title=foo=bar

This has the added benefit of issue tracking.
Assuming the scribble doc would store its github repository this would make it 
a convenient method to raise the issue regarding documentation encouraging 
people to do it. 

On Thursday, September 22, 2016 at 2:33:05 AM UTC+2, Matthew Butterick wrote:
> 
> I get meaningful messages frequently. To be fair, as a work in progress, 
> Beautiful Racket is wrong a lot more often than the Racket docs. Also, BR has 
> no corresponding mailing list or GitHub issues, as Racket does (and most 
> add-on Racket packages also do). Also, the comment form relies on being able 
> to send email, which requires cooperation with an SMTP server, which would 
> create a new network dependency that docs don't currently have (meaning, you 
> can install them on your local machine or use them offline and they work the 
> same way).

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