Re: [racket-users] 2d animations with 2k+ polygons?

2016-04-07 Thread 'John Clements' via Racket Users

> On Apr 7, 2016, at 7:58 AM, Jay McCarthy  wrote:
> 
> mode-lambda is intended for this kind of work load. Try taking the demo, 
> going to the "rand" workload (line 140) and change in the in-range for W to 
> something like (* 10 W) (which would be 2.5k) and evaluating the performance. 
> I also just recently discovered an optimization I can make in mode-lambda but 
> haven't had time to implement it. If it's not adequate, I can make sometime 
> to do it.

Up side: 2.5k sprites seem to work fine.

Down side: the documentation for ‘lux’ is giving me fits. The names all seem 
chosen as an elaborate pun on those used by 2htdp/uniiverse, and there are no 
examples.

Still plugging,

John


-- 
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] What do you use macros for?

2016-04-07 Thread David Storrs
That's very cool, Dan.  Thanks for the example.  (Although, shouldn't -4^2
+ 4^2 = 32, not 31?)

If/when you do the 'further challenges' section, could you post the result
here?  It looks like it would be useful.

Dave


On Thu, Apr 7, 2016 at 1:53 PM, Daniel Prager 
wrote:

> On Thu, Apr 7, 2016 at 4:13 PM, Rickard Andersson <
> rickard.m.anders...@gmail.com> wrote:
>
>> > What have you used them for?
>>
>> https://github.com/GoNZooo/gonz/blob/master/gonz/define-test.rkt
>>
>> It's a macro that allows me to bundle expected inputs with expected
>> outputs for those inputs together with a contract definition, meaning
>> I have a tighter coupling of test-cases together with definitions of
>> functions without a bunch of `(module+ test ...)`.
>>
>
> That's a neat example, both as motivation for those asking "why macros?"
> and folks like me who want to get better at writing them.
>
> For a bit of learning-by-doing I was able to easily change Rickard's macro
> to get a different surface syntax that correctly processes:
>
> (define/cti (square2 x y)
>   contract:
>   (integer? integer? . -> . integer?)
>
>   tests:
>   [2 3 -> 13]
>   [1 2 -> 5]
>   [-4 4 -> 31]
>
>   implementation:
>   (+ (expt x 2) (expt y 2)))
>
> Further challenges:
>
>- allow the "contract:" and "tests:" sections to be blank, but print a
>warning
>- add handling for default, keyword and rest parameters
>
> Dan
>

-- 
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] Trying to kill process created by process

2016-04-07 Thread Matthew Flatt
When you use `system` or `process`, the immediate new process runs a
shell. The shell process then starts another one to run the command
that you give it.

I recommend using `process*` to avoid the shell process and to avoid
encoding issues when passing arguments:

 (define racket (find-executable-path "racket"))
 ... (process* racket "sleeper.rkt") ...

Another approach is to create a fresh process group for the shell
process, and then `((fifth pl) 'kill)` kills the whole group:

  (parameterize ([subprocess-group-enabled #t])
(process "racket sleeper.rkt"))

Finally, you could tell the shell to not create a subprocess and
instead replace itself with the other program"

  (process "exec racket sleeper.rkt")


At Thu, 7 Apr 2016 13:47:39 -0700 (PDT), Wayne Iba wrote:
> I'm having trouble with two interacting processes and am hoping someone can 
> point out whatever it is that I'm missing.  
> 
> Process A starts process B and interacts with it but conditionally needs to 
> kill it.  But using the procedure of one argument returned (as the fifth 
> element of a list) by process does not seem to kill it.  I've tried "kill -9 
> " with system with no joy either.  Here is my code and the output from 
> killer.
> ===
> ;code for sleeper in a separate file
> (define (sleeper)
>   (for ([i 7])
> (sleep 4)
> (printf "~a~%" i)(flush-output)))
> (sleeper)
> ===
> ;code for killer in another file -- I run this as "racket killer.rkt"
> (define (killer)
>   (let ([pl (process "racket sleeper.rkt")])
> (for ([l (in-port read-line (first pl))])
>   (printf "status: ~a~%" ((fifth pl) 'status))
>   (if (= (with-input-from-string l read) 2)
>   (begin
> ;(system (string-append "kill -9 " (number->string (third pl
> ((fifth pl) 'kill)
> )
>   (displayln l)))
> (close-input-port (first pl))
> (close-output-port (second pl))
> (close-input-port (fourth pl))
> ))
> (killer)
> ===
> ;; output from killer
> status: running
> status: running
> 0
> status: running
> 1
> status: running
> status: done-error
> 3
> status: done-error
> 4
> status: done-error
> 5
> status: done-error
> 6
> ===
> 
> So what am I missing?  Thanks in advance!
> 
> -- 
> 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] What do you use macros for?

2016-04-07 Thread Daniel Prager
On Thu, Apr 7, 2016 at 4:13 PM, Rickard Andersson <
rickard.m.anders...@gmail.com> wrote:

> > What have you used them for?
>
> https://github.com/GoNZooo/gonz/blob/master/gonz/define-test.rkt
>
> It's a macro that allows me to bundle expected inputs with expected
> outputs for those inputs together with a contract definition, meaning
> I have a tighter coupling of test-cases together with definitions of
> functions without a bunch of `(module+ test ...)`.
>

That's a neat example, both as motivation for those asking "why macros?"
and folks like me who want to get better at writing them.

For a bit of learning-by-doing I was able to easily change Rickard's macro
to get a different surface syntax that correctly processes:

(define/cti (square2 x y)
  contract:
  (integer? integer? . -> . integer?)

  tests:
  [2 3 -> 13]
  [1 2 -> 5]
  [-4 4 -> 31]

  implementation:
  (+ (expt x 2) (expt y 2)))

Further challenges:

   - allow the "contract:" and "tests:" sections to be blank, but print a
   warning
   - add handling for default, keyword and rest parameters

Dan

-- 
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] Trying to kill process created by process

2016-04-07 Thread Wayne Iba
I'm having trouble with two interacting processes and am hoping someone can 
point out whatever it is that I'm missing.  

Process A starts process B and interacts with it but conditionally needs to 
kill it.  But using the procedure of one argument returned (as the fifth 
element of a list) by process does not seem to kill it.  I've tried "kill -9 
" with system with no joy either.  Here is my code and the output from 
killer.
===
;code for sleeper in a separate file
(define (sleeper)
  (for ([i 7])
(sleep 4)
(printf "~a~%" i)(flush-output)))
(sleeper)
===
;code for killer in another file -- I run this as "racket killer.rkt"
(define (killer)
  (let ([pl (process "racket sleeper.rkt")])
(for ([l (in-port read-line (first pl))])
  (printf "status: ~a~%" ((fifth pl) 'status))
  (if (= (with-input-from-string l read) 2)
  (begin
;(system (string-append "kill -9 " (number->string (third pl
((fifth pl) 'kill)
)
  (displayln l)))
(close-input-port (first pl))
(close-output-port (second pl))
(close-input-port (fourth pl))
))
(killer)
===
;; output from killer
status: running
status: running
0
status: running
1
status: running
status: done-error
3
status: done-error
4
status: done-error
5
status: done-error
6
===

So what am I missing?  Thanks in advance!

-- 
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] mode-lambda example doesn't work?

2016-04-07 Thread Neil Van Dyke
Maybe someone should verbalize what many of us know: DrRacket is useful, 
and pretty neat.


I'm a long-time Emacs person, but DrRacket has some conveniences and 
killer features that keep me coming back.


(One of these days, I should get off my posterior, and learn how to make 
various personal-preference tweaks to DrRacket, like I have to Emacs.)


Neil V.

--
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] 6.4 + universe has mouse-based hiccups

2016-04-07 Thread Matthew Flatt
At Thu, 07 Apr 2016 15:05:12 -0400, "'John Clements' via Racket Users" wrote:
> > On Apr 7, 2016, at 8:34 AM, Matthew Flatt  wrote:
> > It looks like it's not a question of running DrRacket for a while, but
> > of having multiple tabs in DrRacket. And, more specifically, it's not
> > about DrRacket, but about showing a window containing a `tab-panel%`
> > instance that uses the 'no-border style on OS X.

The problem seems to happen only with 64-bit builds on 10.11. I don't
know why, but 10.11 changes the way that windows are drawn in a fairly
deep way, and it's probably something related to that change.

Fortunately, MiMo42 provides MMTabBarView as a replacement for
PSMTabBarControl. It only works on 64-bit 10.9 and up, but that covers
the case where PSMTabBarControl is a problem. Also, MMTabBarView
includes a Yosemite style. So, I've switched `racket/gui` (and
therefore DrRacket) to use MMTabBarView on 64-bit 10.10 and up.

> (You saw that I opened a PR for this? [...])

Yes, I'll close 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] 6.4 + universe has mouse-based hiccups

2016-04-07 Thread 'John Clements' via Racket Users

> On Apr 7, 2016, at 8:34 AM, Matthew Flatt  wrote:
> 
> It looks like it's not a question of running DrRacket for a while, but
> of having multiple tabs in DrRacket. And, more specifically, it's not
> about DrRacket, but about showing a window containing a `tab-panel%`
> instance that uses the 'no-border style on OS X.
> 
> 
…

> but don't run it. Start your universe program, and it should be ok.
> Start running the tab-panel program, and your universe program will
> misbehave. Close the frame created by the tab-panel program, and your
> universe program will behave correctly again.

Well, I tried the much simpler test of simply observing the problem, and then 
closing all of the other tabs, and the problem went away. Creating another tab 
brought the problem back.

Thanks!

(You saw that I opened a PR for this? Let me know if you want me to dig up the 
#.)

John



-- 
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] mode-lambda example doesn't work?

2016-04-07 Thread Robby Findler
On Thu, Apr 7, 2016 at 9:52 AM, Jay McCarthy  wrote:
> On Wed, Apr 6, 2016 at 8:18 PM, John Clements 
>> FWIW, I also notice exactly the same problem that I reported earlier when
>> using 2htdp; on a long-running DrR process, swirling the mouse while the
>> program is running reduces the frame rate.
>>
>> In particular, in this case, it reduces it… to zero. In fact, the FPS
>> computation in the title bar also disappears. As soon as the mouse stops
>> moving, the motion begins again. As with the other report, the problem
>> doesn’t appear to exist at the command-line—but then, running at the
>> command-line is pretty much guaranteed not to give rise to a long-running
>> process. As with the other problem I reported, restarting DrRacket makes the
>> problem go away.
>>
>
> As we see over and over on the mailing list, DrRacket is not a reliable way
> to run Racket programs. I don't recommend using it with mode-lambda.

As it turns out, this has nothing to do with DrRacket or the
undeniable problems that Jay mentions in his followup message in this
thread. More precisely, I followed the instructions Matthew posted in
another thread earlier today [1] and this problem seems to be the same
problem as that one.

Maybe it would be good to try to avoid messages like these, if for no
other reason than to keep my heartbeat in a healthy range? :) DrRacket
is something I've spent approximately 45% of my life trying to improve
and while I can agree it isn't as good as it could be, more
constructive criticism is a better way to go? Dare I suggest pull
requests? :)

Peace,
Robby

[1] https://groups.google.com/forum/#!topic/racket-users/WHIYeUgsXLw

-- 
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] What do you use macros for?

2016-04-07 Thread David Storrs
That makes sense.  Thank you, Rickard.

On Wed, Apr 6, 2016 at 11:13 PM, Rickard Andersson <
rickard.m.anders...@gmail.com> wrote:

> > What have you used them for?
>
> While it's certainly not the most impactful macro in the world, I was
> pretty pleased with being able to do this:
>
> https://github.com/GoNZooo/gonz/blob/master/gonz/define-test.rkt
>
> It's a macro that allows me to bundle expected inputs with expected
> outputs for those inputs together with a contract definition, meaning
> I have a tighter coupling of test-cases together with definitions of
> functions without a bunch of `(module+ test ...)`.
>
> > What do they do that a function couldn't?
>
> In this case we're actually generating the `(module+ test ...)` entries
> based on the lists inside the macro, but then simply appending these to
> our generated code, meaning they won't be defined in a function (which
> they can't), but rather added as if we were doing it manually.
>
> The manual variant for the first example in this file would look as
> follows:
>
> (define/contract (square x)
>   (integer? . -> . integer?)
>   (expt x 2))
>
> (module+ test
>   (check-equal? (square 2) 4)
>   (check-equal? (square 3) 9)
>   (check-equal? (square 5) 25))
>
> We're skipping straight to defining inputs and outputs, only because we
> are using macros.
>
> > What are good times to use them
>
> In this case I wanted to succinctly define test cases for functions and
> for this to be tighter coupled to function definitions, but you can't
> call `module+` while inside a function, so the only real solution is to
> lift that content outside the function definition.
>
> > ... what are their drawbacks?
>
> The obvious drawback here is that this macro is next to useless for
> anyone else when they stumble upon it. When you have an actually useful
> macro (I hesitate to call this one universally useful, though I like it
> myself), this is solved by great documentation facilities, like
> Scribble, as well as good macro constructs that will help you guide your
> user through proper usage.
>
> On Wed, Apr 06, 2016 at 05:19:05PM -0700, David Storrs wrote:
> > Hi folks,
> >
> > Macros are one of the biggest features that people list as the advantages
> > of LISP / Scheme, and I don't really understand them.  I get the basics
> --
> > they can create new code structures -- but not the implications  What
> have
> > you used them for, and what do they do that a function couldn't?  What
> are
> > good times to use them, and what are their drawbacks?
> >
> > Dave
> >
> > --
> > 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] 6.4 + universe has mouse-based hiccups

2016-04-07 Thread Matthew Flatt
It looks like it's not a question of running DrRacket for a while, but
of having multiple tabs in DrRacket. And, more specifically, it's not
about DrRacket, but about showing a window containing a `tab-panel%`
instance that uses the 'no-border style on OS X.

For example, start DrRacket with your program in one window. Create a
new window (not a new tab) and paste in

 #lang racket/gui

 (define f (new frame%
[label "Slower"]
[width 200]))
 (new tab-panel%
  [choices '("A" "B")]
  [parent f]
  [style '(no-border)])
 (send f show #t)

but don't run it. Start your universe program, and it should be ok.
Start running the tab-panel program, and your universe program will
misbehave. Close the frame created by the tab-panel program, and your
universe program will behave correctly again.

Using the 'no-border style for `tab-panel%` triggers the use of a
third-party widget PSMTabBarControl, so I think the problem must be in
that widget's implementation or its interaction with the `racket/gui`
event loop. In any case, now that I know that PSBTamBarControl is
relevant, I should be able to fix it soon.

At Wed, 06 Apr 2016 18:10:05 -0400, "John Clements" wrote:
> 
> > On Apr 6, 2016, at 9:02 AM, Matthew Flatt  wrote:
> > 
> > If the problem happens after DrRacket has been running for a while,
> > then that's good information and definitely a problem to investigate.
> 
> I can confirm that (after 3-5 hours of development work) the problem is back.
> 
> I also shortened the program down to about 36 lines (below). Finally, once 
> again I restarted DrR and the problem went away.
> 
> I’ll go ahead and file a bug report, I guess.
> 
> Okay, done.
> 
> John
> 
> 
> #lang racket
> 
> (require 2htdp/universe
> 2htdp/image)
> 
> (define r (rectangle 40 40 'solid 'green))
> 
> ;; represents a position on the screen
> (struct posn (x y) #:transparent)
> 
> ;; in seconds:
> (define TRANSITION-TIME 1)
> 
> ;; in frames per second
> (define FRAME-RATE 40)
> 
> (define SCENEWIDTH 400)
> (define SCENEHEIGHT 300)
> 
> (define transition-frames (* TRANSITION-TIME FRAME-RATE))
> 
> ;; given frame number, overlay
> ;; image at the correct location
> (define (draw-world w)
>   (define frac (/ (modulo w transition-frames) transition-frames))
>   (define 1-frac (- 1 frac))
>   (place-image r (+ (* 1-frac 50) (* frac 100))
>(+ (* 1-frac 120) (* frac 115))
>bg-scene))
> 
> (define bg-scene (empty-scene SCENEWIDTH SCENEHEIGHT))
> 
> (big-bang 0
>   [to-draw draw-world]
>   [on-tick add1 (/ 1 FRAME-RATE)])
> 
> 
> 
> > 
> > Thanks!

-- 
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] 2d animations with 2k+ polygons?

2016-04-07 Thread Jay McCarthy
mode-lambda is intended for this kind of work load. Try taking the demo,
going to the "rand" workload (line 140) and change in the in-range for W to
something like (* 10 W) (which would be 2.5k) and evaluating the
performance. I also just recently discovered an optimization I can make in
mode-lambda but haven't had time to implement it. If it's not adequate, I
can make sometime to do it.

Jay

On Wed, Apr 6, 2016 at 8:27 PM, 'John Clements' via Racket Users <
racket-users@googlegroups.com> wrote:

> I’m trying to create a simple fixed animation with about 2k polygons
> moving on a simple background. Not surprisingly, things start to slow down
> pretty badly once I’m animating 2k polygons at a time, even when every one
> of these polygons is (freeze (rectangle 5 5 ‘solid ‘blue)). My question is
> this: what’s the best tool for building an animation like this? Should I go
> straight to OpenGL? Jay, would your mode-lambda be good for this?
>
> John
>
>
>
> --
> 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] mode-lambda example doesn't work?

2016-04-07 Thread Jay McCarthy
On Wed, Apr 6, 2016 at 8:18 PM, John Clements 
wrote:

>
> > On Apr 6, 2016, at 2:43 AM, Jay McCarthy  wrote:
> >
> > Hi John,
> >
> > I'd like to debug the glClear error with you. I'll have to look up the
> error to figure out where to go on it though, so I'll get back to you.
> >
> > However, the screen you see is expected. The demo has a few modes and
> the default is the text display mode and it is showing that it can display
> unicode characters overlay'd on each other. Your characters look different
> than mine, but I assume that is because you do not have the default font,
> which is Matthew Butterick's Triplicate T4c (the only font I use on my
> system). If you press various keys, the mode will change:
> >
> > r - display a set of random sprites at random spins/etc with half in
> static positions (optimized) and half moving dynamically
> > g - display a small set of sprites in a uniform grid
> > b - display a visually pleasing example involving little blocks
> > t - display a single sprite inside of a tiled layer (the screen looks
> like it has many sprites, but really it is just one)
> > w - display a few sprites that are wrapped around the edges of a
> torus-like layer (each color sprite is actually there once but is wrapped
> around the edges)
> > x - display characters (default)
> >
> > The most interesting mode is b and while it is active you can press 's'
> to induce vomiting mode where the mode-7 effect is enabled.
>
> Ah! okay, these all worked fine. maybe a comment at the top?
>

Sure, the intention was to have the example be something you really studied
the code of, but I can add that to help its demo-ness


>
> FWIW, I also notice exactly the same problem that I reported earlier when
> using 2htdp; on a long-running DrR process, swirling the mouse while the
> program is running reduces the frame rate.
>
> In particular, in this case, it reduces it… to zero. In fact, the FPS
> computation in the title bar also disappears. As soon as the mouse stops
> moving, the motion begins again. As with the other report, the problem
> doesn’t appear to exist at the command-line—but then, running at the
> command-line is pretty much guaranteed not to give rise to a long-running
> process. As with the other problem I reported, restarting DrRacket makes
> the problem go away.
>
>
As we see over and over on the mailing list, DrRacket is not a reliable way
to run Racket programs. I don't recommend using it with mode-lambda.

Jay


> Hmm…
>
> John
>
> >
> > So please go through the various modes to see if they all work and
> if you just want to see something vaguely pretty, check out b then s.
> >
> > Jay
> >
> >
> > On Wed, Apr 6, 2016 at 12:01 AM, John Clements <
> cleme...@brinckerhoff.org> wrote:
> > I want a sprite library, and it looks like mode-lambda is the obvious
> choice. However, when I try to run the “one.rkt” example that’s a part of
> mode-lambda, I get a screen with no motion that looks a bit like garbage
> (though with live frame rate figures), and this text in the definitions
> window:
> >
> > Welcome to DrRacket, version 6.4.0.15--2016-03-29(-/f) [3m].
> > Language: racket/base, with debugging; memory limit: 512 MB.
> > You are using OpenGL (4 1)
> > '#(#(416.0 234.0) #(1.0 1.0) #(416.0 234.0) #(416.0 234.0) #(800.0
> 578.0))
> > . . ../backend/gl.rkt:281:9: OpenGL error in procedure glClear: Error
> code 1286.
> >
> > Any idea what’s going on? I’m assuming this isn’t the intended behavior.
> This is on a "MacBook Pro (Retina, 13-inch, Early 2015)", running OS X
> 10.11.4 with a "Intel Iris Graphics 6100 1536 MB” card.
> >
> > John
> >
> > Here’s a screenshot of what I see in the opened window:
> >
> > 
> >
> >
> >
> > --
> > 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.
>
>
>
>


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


[racket-users] Re: macros within expressions.

2016-04-07 Thread 'Richard Adler' via Racket Users

Thanks everyone for your help.

-- 
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: macros within expressions.

2016-04-07 Thread 'Richard Adler' via Racket Users

This is a simplified example. I trying to learn how macros work inside 
expressions as well as at the start of expressions.

-- 
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] quoting in posts to this email list

2016-04-07 Thread Norman Gray


Greetings.

On 7 Apr 2016, at 5:13, Neil Van Dyke wrote:

I suggest that people posting replies to posts on this email list try 
to *minimize* quoting of the previous post(s).


add1

Oh, for the sake of my poor heart, and the strain on it from my dark 
mutterings when disentangling top-posting: (add1 (add1 (add1 
(what-neil-said


All the best,

Norman


--
Norman Gray  :  https://nxg.me.uk
SUPA School of Physics and Astronomy, University of Glasgow, UK

--
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] What do you use macros for?

2016-04-07 Thread Rickard Andersson
> What have you used them for?

While it's certainly not the most impactful macro in the world, I was
pretty pleased with being able to do this:

https://github.com/GoNZooo/gonz/blob/master/gonz/define-test.rkt

It's a macro that allows me to bundle expected inputs with expected
outputs for those inputs together with a contract definition, meaning
I have a tighter coupling of test-cases together with definitions of
functions without a bunch of `(module+ test ...)`.

> What do they do that a function couldn't?

In this case we're actually generating the `(module+ test ...)` entries
based on the lists inside the macro, but then simply appending these to
our generated code, meaning they won't be defined in a function (which
they can't), but rather added as if we were doing it manually.

The manual variant for the first example in this file would look as
follows:

(define/contract (square x)
  (integer? . -> . integer?)
  (expt x 2))

(module+ test
  (check-equal? (square 2) 4)
  (check-equal? (square 3) 9)
  (check-equal? (square 5) 25))

We're skipping straight to defining inputs and outputs, only because we
are using macros.

> What are good times to use them

In this case I wanted to succinctly define test cases for functions and
for this to be tighter coupled to function definitions, but you can't
call `module+` while inside a function, so the only real solution is to
lift that content outside the function definition.

> ... what are their drawbacks?

The obvious drawback here is that this macro is next to useless for
anyone else when they stumble upon it. When you have an actually useful
macro (I hesitate to call this one universally useful, though I like it
myself), this is solved by great documentation facilities, like
Scribble, as well as good macro constructs that will help you guide your
user through proper usage.

On Wed, Apr 06, 2016 at 05:19:05PM -0700, David Storrs wrote:
> Hi folks,
> 
> Macros are one of the biggest features that people list as the advantages
> of LISP / Scheme, and I don't really understand them.  I get the basics --
> they can create new code structures -- but not the implications  What have
> you used them for, and what do they do that a function couldn't?  What are
> good times to use them, and what are their drawbacks?
> 
> Dave
> 
> -- 
> 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.