Re: [racket-users] How to check if a symbol is defined before calling it?

2018-02-18 Thread Robby Findler
Glad you found something that works!

For the record, being in a pkg and being an app are not mutually exclusive.
DrRacket, for example, enjoys both statuses.

Robby

On Sun, Feb 18, 2018 at 5:41 PM Alex Harsanyi 
wrote:

>
> Hi Robby,
>
> On Sunday, February 18, 2018 at 10:33:09 AM UTC+8, Robby Findler wrote:
>>
>> FWIW, the approach that is less friendly to your clients but perhaps
>> easier for you (and maybe good enough for them) is to declare a
>> dependency on a specific version in the info.rkt file of your pkg. The
>> pkg system will ensure that the latest version is used.
>>
>
> I have an application, not a package, so there is no "info.rkt" file in
> which to declare dependencies.  I do not use any external packages or
> features specific to a Racket version, so I did not need any version
> management of the libraries I use.  This is the first case where I need
> something that is not present in all racket versions -- in fact,currently,
> it is only present in an unreleased version.
>
> The suggested `dynamic-require` approach seems simple enough and it is
> probably more user (developer) friendly.  It also has the benefit that I
> understand how it works :-)
>
> Best Regards,
> Alex.
>
> --
> 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] How to check if a symbol is defined before calling it?

2018-02-18 Thread Alex Harsanyi

Hi Robby,

On Sunday, February 18, 2018 at 10:33:09 AM UTC+8, Robby Findler wrote:
>
> FWIW, the approach that is less friendly to your clients but perhaps 
> easier for you (and maybe good enough for them) is to declare a 
> dependency on a specific version in the info.rkt file of your pkg. The 
> pkg system will ensure that the latest version is used. 
>

I have an application, not a package, so there is no "info.rkt" file in 
which to declare dependencies.  I do not use any external packages or 
features specific to a Racket version, so I did not need any version 
management of the libraries I use.  This is the first case where I need 
something that is not present in all racket versions -- in fact,currently, 
it is only present in an unreleased version. 

The suggested `dynamic-require` approach seems simple enough and it is 
probably more user (developer) friendly.  It also has the benefit that I 
understand how it works :-)

Best Regards,
Alex.

-- 
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] big-bang + right click?

2018-02-18 Thread Stephen Foster
Cool!  I was able to get it working with Lux.  Thanks!

On Saturday, February 17, 2018 at 9:34:19 AM UTC-8, Jay McCarthy wrote:
>
> FWIW Stephen, I have another package called `lux` that tries to be a 
> "professional" big-bang and it supports stuff like this. 
>
> The documentation is here: http://docs.racket-lang.org/lux/index.html 
>
> But I suggest checking out the two examples first. 
>
> val-demo --- 
> https://github.com/jeapostrophe/lux/blob/master/examples/val-demo.rkt 
> --- Shows how you can use 2htdp/image or pict to make your scenes and 
> it shows how the generic event-handler receives key events from 
> racket/gui. 
>
> spin --- https://github.com/jeapostrophe/lux/blob/master/examples/spin.rkt 
> --- is a little more complicated and shows how you get mouse event 
> structures as well as demonstrating that lux can be used recursively. 
> [For comparison, if you call big-bang inside a big-bang handler, then 
> a new window opens up. In lux, the same window is taken over and the 
> result from the inner call is returned to the call site. This can be 
> used to make things like pause screens, menus, and so on fairly 
> nicely.] 
>
> Jay 
>
> -- 
> -=[ Jay McCarthy   http://jeapostrophe.github.io]=- 
> -=[ Associate ProfessorPLT @ CS @ UMass Lowell ]=- 
> -=[ Moses 1:33: And worlds without number have I created; ]=- 
>

-- 
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: How to check if a symbol is defined before calling it?

2018-02-18 Thread Jack Firth

>
> The recent plot library introduces a new function, `point-pict` which is 
> not yet available as part of a Racket distribution, and the plot package 
> has to be installed separately from GitHub for this function.
>
> In my code I would like to be able to check if this function is available 
> before calling it, so my code compiles correctly even if the function is 
> not available.
>

In addition to the `dynamic-require` solution, you can do this statically 
with macros and `identifier-binding`:

(define-simple-macro (begin-when-bound id:id body ...+)
  #:with (body* ...) (if (identifier-binding #'id) #'(body ...) #'())
  (begin body* ...))

Warning: I have only written the above code, not run it. See also the 
version-case  package 
for a similar, more fleshed out concept.

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