Re: [racket-users] racket/contract warning

2016-03-30 Thread Tim Brown
Robby,

Maybe I’m being a bit thick, but that reply is a bit too cryptic for me
:-/

Should I be doing something?
[Can’t see how, since I’m just running racket]

Are the Racket devs being pestered to pass late-neg-projection where
they aren’t currently?

Or what?

Regards,

Tim

On 29/03/16 13:23, Robby Findler wrote:
> It is well known but maybe not well liked. :)
> 
> Robby
> 
> On Tuesday, March 29, 2016, Tim Brown  > wrote:
> 
> Folks,
> 
> I have just upgraded some software to use Racket 6.4. My code sets
> log-max-level to debug, and then cranks up the level on the more
> chatty contributors.
> 
> In 6.4, a new warning (or collection of warnings) is thrown by the
> racket/contract topic.
> 
> Is this intentional?
> 
> The warning is raised by doing nothing more than just running the
> Racket REPL:
> 
> ~~~
> $ PLTSTDERR=warning@racket/contract racket
> Welcome to Racket v6.4.
> racket/contract: no late-neg-projection passed to
> build-contract-property
>   (unpack24 . #(struct:srcloc
> # 271
> 0 8903 1608))
>   (|[running body]| . #(struct:srcloc
> # #f #f
> #f #f))
>   (|[traversing imports]| . #(struct:srcloc
> # #f
> #f #f #f))
> racket/contract: no late-neg-projection passed to
> build-contract-property
>   (unpack24 . #(struct:srcloc
> # 271
> 0 8903 1608))
>   (|[running body]| . #(struct:srcloc
> # #f #f
> #f #f))
> racket/contract: no late-neg-projection passed to
> build-contract-property
>   (unpack24 . #(struct:srcloc
> # 271
> 0 8903 1608))
>   (|[running body]| . #(struct:srcloc
> # #f #f
> #f #f))
> >
> ~~~


-- 
Tim Brown CEng MBCS 

City Computing Limited · www.cityc.co.uk
  City House · Sutton Park Rd · Sutton · Surrey · SM1 2AE · GB
T:+44 20 8770 2110 · F:+44 20 8770 2130

City Computing Limited registered in London No:1767817.
Registered Office: City House, Sutton Park Road, Sutton, Surrey, SM1 2AE
VAT No: GB 918 4680 96

-- 
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] racket/contract warning

2016-03-30 Thread Robby Findler
It is a note from the contract system to itself to help track down places
that should be improved. Please feel free to ignore it.

... Unless you want to try to fix it? I am happy to supply more of that
kind of infor if you care.

Robby

On Wednesday, March 30, 2016, Tim Brown  wrote:

> Robby,
>
> Maybe I’m being a bit thick, but that reply is a bit too cryptic for me
> :-/
>
> Should I be doing something?
> [Can’t see how, since I’m just running racket]
>
> Are the Racket devs being pestered to pass late-neg-projection where
> they aren’t currently?
>
> Or what?
>
> Regards,
>
> Tim
>
> On 29/03/16 13:23, Robby Findler wrote:
> > It is well known but maybe not well liked. :)
> >
> > Robby
> >
> > On Tuesday, March 29, 2016, Tim Brown  
> > > wrote:
> >
> > Folks,
> >
> > I have just upgraded some software to use Racket 6.4. My code sets
> > log-max-level to debug, and then cranks up the level on the more
> > chatty contributors.
> >
> > In 6.4, a new warning (or collection of warnings) is thrown by the
> > racket/contract topic.
> >
> > Is this intentional?
> >
> > The warning is raised by doing nothing more than just running the
> > Racket REPL:
> >
> > ~~~
> > $ PLTSTDERR=warning@racket/contract racket
> > Welcome to Racket v6.4.
> > racket/contract: no late-neg-projection passed to
> > build-contract-property
> >   (unpack24 . #(struct:srcloc
> > #
> 271
> > 0 8903 1608))
> >   (|[running body]| . #(struct:srcloc
> > #
> #f #f
> > #f #f))
> >   (|[traversing imports]| . #(struct:srcloc
> > #
> #f
> > #f #f #f))
> > racket/contract: no late-neg-projection passed to
> > build-contract-property
> >   (unpack24 . #(struct:srcloc
> > #
> 271
> > 0 8903 1608))
> >   (|[running body]| . #(struct:srcloc
> > # #f
> #f
> > #f #f))
> > racket/contract: no late-neg-projection passed to
> > build-contract-property
> >   (unpack24 . #(struct:srcloc
> > #
> 271
> > 0 8903 1608))
> >   (|[running body]| . #(struct:srcloc
> > #
> #f #f
> > #f #f))
> > >
> > ~~~
>
>
> --
> Tim Brown CEng MBCS >
> 
> City Computing Limited · www.cityc.co.uk
>   City House · Sutton Park Rd · Sutton · Surrey · SM1 2AE · GB
> T:+44 20 8770 2110 · F:+44 20 8770 2130
> 
> City Computing Limited registered in London No:1767817.
> Registered Office: City House, Sutton Park Road, Sutton, Surrey, SM1 2AE
> VAT No: GB 918 4680 96
>
> --
> 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] serialization of math/array

2016-03-30 Thread Berthold Bäuml
About two years ago I asked about the possibility to serialize math/array 
arrays:
http://lists.racket-lang.org/users/archive/2014-July/063410.html

Out of the box math arrays still result in #f when calling serializable?. I am 
wondering if there is any solution I could use to serialize at least arrays of 
float numbers.

Best,
Berthold

-- 
---
Berthold Bäuml -- Head of Autonomous Learning Robots Lab
DLR, Robotics and Mechatronics Center (RMC)
Münchner Str. 20, D-82234 Wessling
Phone +49 8153 282489
http://www.robotic.de/Berthold.Baeuml

-- 
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] serialization of math/array

2016-03-30 Thread Benjamin Greenman
Here's one hack.

#lang racket/base

(require
  math/array
 (prefix-in rkt: racket/serialize))

(define secret-key 'array)

(define (serialize val)
  (if (array? val)
(rkt:serialize (cons secret-key (array->list val)))
(rkt:serialize val)))

(define (deserialize val)
  (define d (rkt:deserialize val))
  (if (and (pair? d) (eq? secret-key (car d)))
(list->array (cdr d))
d))

(define arr (array #[0 1 2]))
(serialize arr)
(deserialize (serialize arr))

(Part of the issue serializing math/array is that it represents arrays as
functions under the hood)

-- 
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] How to call a macro on each element of a list

2016-03-30 Thread cnandi
Consider a toy macro defined as:

(define-syntax mysyn
(syntax-rules(fun)
  [(mysyn element ...)
   (begin
 #`(define fun
 (display element)...))]))

and a list:
(define l '(1 2 3))

Is there a way to call the macro like so: (mysyn l). When I try this, the 
syntax object created looks like: '(define fun (display l)). 
What I want it to look like is:

'(define fun 
   (display 1)
   (display 2)
   (display 3))


In other words, my question is whether/how I can pass the entire list to the 
macro and let the macro be expanded on each element of 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] How to call a macro on each element of a list

2016-03-30 Thread Neil Van Dyke
You had the right idea, if you're using `syntax-rules`, but there were a 
few small problems:


 BEGIN 
#lang racket

(define-syntax mysyn
  (syntax-rules ()
((_ NAME ELEMENTn ...)
 (define (NAME)
   (display ELEMENTn) ...

(mysyn fun 1 2 3)

(fun)
 END 

But, if you expect to be doing more macro work in the future, you 
probably want to learn `syntax-case` instead of `syntax-rules`. (Because 
`syntax-rules` is an old legacy form that has some major restrictions 
that get too cumbersome for many nontrivial purposes. `syntax-case`, on 
the other hand, is much more powerful, and `syntax-case` also provides a 
smooth path to the crazy-awesome `syntax-rules`, once one is ready to 
not be too intimidated by `syntax-rules` documentation.)


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] How to call a macro on each element of a list

2016-03-30 Thread Vincent St-Amour
A few things:

1. You're mixing elements of `syntax-rules` and `syntax-case` /
   `syntax-parse`. The former has an implicit template in its right-hand
   side, so you don't need the `#``, whereas you do with `syntax-case` /
   `syntax-parse`.

2. If you want this to define a function (as I'm guessing from the name
   `fun`), you should add parentheses around the name you're defining.

3. Because you're not trying to *match* the name `fun`, but only
   expanding to it, you don't need it in the literal list.

Here's a version that should do what you want:

(define-syntax mysyn
  (syntax-rules ()
[(mysyn element ...)
 (define (fun)
   (display element)
   ...)]))
(mysyn 1 2 3)

Or, using the simpler `define-syntax-rule`:

 (define-syntax-rule (mysyn element ...)
   (define (fun)
 (display element)
 ...))


Of course, it's usually best to use functions wherever possible, and
only use macros as a last resort. Assuming you're planning to use the
code (i.e., you're not using it to learn about macros), I'd write it
like this:

(define (fun . args) (for-each display args))

Functions compose more easily, and are easier to understand and to debug.

Vincent



On Wed, 30 Mar 2016 15:06:24 -0500,
cna...@cs.washington.edu wrote:
> 
> Consider a toy macro defined as:
> 
> (define-syntax mysyn
> (syntax-rules(fun)
>   [(mysyn element ...)
>(begin
>  #`(define fun
>  (display element)...))]))
> 
> and a list:
> (define l '(1 2 3))
> 
> Is there a way to call the macro like so: (mysyn l). When I try this, the 
> syntax object created looks like: '(define fun (display l)). 
> What I want it to look like is:
> 
> '(define fun 
>(display 1)
>(display 2)
>(display 3))
> 
> 
> In other words, my question is whether/how I can pass the entire list to the 
> macro and let the macro be expanded on each element of 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.


Re: [racket-users] How to call a macro on each element of a list

2016-03-30 Thread Neil Van Dyke

Oops, I usually end up typing one of the names wrong.  Summary:

* syntax-case -- good one to start with, smooth path to syntax-parse

* syntax-parse -- best thing ever, but documentation is intimidating, so 
maybe start with syntax-case instead


* syntax-rules -- old, limited, no smooth path, you probably don't want 
to ever use this, though you'll occasionally you'll see an old-timer use 
it when they're in a hurry


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] How to call a macro on each element of a list

2016-03-30 Thread Robby Findler
Perhaps we should improve the syntax-parse documentation? I found the
overview and examples to be pretty good, tho.

Robby


On Wed, Mar 30, 2016 at 3:42 PM, Neil Van Dyke  wrote:
> Oops, I usually end up typing one of the names wrong.  Summary:
>
> * syntax-case -- good one to start with, smooth path to syntax-parse
>
> * syntax-parse -- best thing ever, but documentation is intimidating, so
> maybe start with syntax-case instead
>
> * syntax-rules -- old, limited, no smooth path, you probably don't want to
> ever use this, though you'll occasionally you'll see an old-timer use it
> when they're in a hurry
>
>
> 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.

-- 
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 call a macro on each element of a list

2016-03-30 Thread Neil Van Dyke

Robby Findler wrote on 03/30/2016 04:45 PM:

Perhaps we should improve the syntax-parse documentation? I found the
overview and examples to be pretty good, tho.


When the goal is to teach syntax extension, maybe it would make sense to 
pick *one* syntax extension form to introduce to people, and stick with 
it throughout all the teaching.


(I have never understood the approach of throwing a few of the different 
forms at people in rapid-fire, changing syntax/convention/model on 
people before they hardly have any experience.  "First, let's show you 
*this* way; and then, when you want to do something more powerful, 
forget what you know, and do it this *other* way; and, hey, let me show 
you these other tools that are out there, isn't this all great."   Then 
they sit down to start experimenting, and they get confused and 
discouraged for no good reason, over trivia of all the different tools 
that happen to exist.  Latest data point is this person, who was 
stumbling over quasisyntax in syntax-rules.  That's just discouraging 
for the person, when what I'd prefer to see is constructionist 
immersion, and learning the more more important ideas about application 
of syntax extension.)


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] How to call a macro on each element of a list

2016-03-30 Thread cnandi
On Wednesday, March 30, 2016 at 1:45:09 PM UTC-7, Robby Findler wrote:
> Perhaps we should improve the syntax-parse documentation? I found the
> overview and examples to be pretty good, tho.
> 
> Robby
> 
> 
> On Wed, Mar 30, 2016 at 3:42 PM, Neil Van Dyke  wrote:
> > Oops, I usually end up typing one of the names wrong.  Summary:
> >
> > * syntax-case -- good one to start with, smooth path to syntax-parse
> >
> > * syntax-parse -- best thing ever, but documentation is intimidating, so
> > maybe start with syntax-case instead
> >
> > * syntax-rules -- old, limited, no smooth path, you probably don't want to
> > ever use this, though you'll occasionally you'll see an old-timer use it
> > when they're in a hurry
> >
> >
> > 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.

Thank you for the feedback. Indeed I am not using macros just for learning them 
but for generating code that I will run later. The example I gave here was a 
toy one. 

However, my problem is still not resolved because in all the suggestions above, 
 I still need to explicitly pass all the arguments to mysyn such as: 
(mysyn 1 2 3). Is there a way to pass a list l by its name and not its values. 
For instance, If l is '(1 2 3)
I want to be able to call the macro as (mysyn l) and not (mysyn 1 2 3). Is this 
possible?

-- 
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 call a macro on each element of a list

2016-03-30 Thread Alexis King
> However, my problem is still not resolved because in all the suggestions 
> above,  I still need to explicitly pass all the arguments to mysyn such as: 
> (mysyn 1 2 3). Is there a way to pass a list l by its name and not its 
> values. 
> For instance, If l is '(1 2 3)
> I want to be able to call the macro as (mysyn l) and not (mysyn 1 2 3). Is 
> this possible?

Yes, it is possible, but not precisely in the way you describe. Macros run at 
compile-time, so if you create a definition (which exists at runtime), it will 
not be available when the macro runs (simply because that code has not been run 
yet!). However, you can define arbitrary values at compile-time using 
define-syntax, not just macros, and you can use this with the 
syntax-local-value function to access the value.

Try something like this:

  (define-syntax (mysyn stx)
(syntax-case stx ()
  [(_ els-id)
   (with-syntax ([(el ...) (syntax-local-value #'els-id)])
 #'(begin (displayln el) ...))]))
  
  (define-syntax l '(1 2 3))
  
  (mysyn l)

Notice (define-syntax l ...) and the call to syntax-local-value.

-- 
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 call a macro on each element of a list

2016-03-30 Thread Neil Van Dyke

cna...@cs.washington.edu wrote on 03/30/2016 05:11 PM:

I still need to explicitly pass all the arguments to mysyn such as:
(mysyn 1 2 3). Is there a way to pass a list l by its name and not its values.
For instance, If l is '(1 2 3)
I want to be able to call the macro as (mysyn l) and not (mysyn 1 2 3). Is this 
possible?



What do you *ultimately* want to do?  Can you give a example or more 
concrete description of that?


(I'm not sure that syntax extension is the way.  So this toy example 
might be confusing things.)


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] How to call a macro on each element of a list

2016-03-30 Thread cnandi
On Wednesday, March 30, 2016 at 2:21:52 PM UTC-7, Neil Van Dyke wrote:
> cna...@cs.washington.edu wrote on 03/30/2016 05:11 PM:
> > I still need to explicitly pass all the arguments to mysyn such as:
> > (mysyn 1 2 3). Is there a way to pass a list l by its name and not its 
> > values.
> > For instance, If l is '(1 2 3)
> > I want to be able to call the macro as (mysyn l) and not (mysyn 1 2 3). Is 
> > this possible?
> >
> 
> What do you *ultimately* want to do?  Can you give a example or more 
> concrete description of that?
> 
> (I'm not sure that syntax extension is the way.  So this toy example 
> might be confusing things.)
> 
> Neil V.

The ultimate goal  is to generate code for a function whose body is a 
conditional. So, basically, I wanted to create a macro that would take as 
argument a function name and a list of pairs. It will generate a conditional 
for each pair in the list. The first element of a pair used for checking a 
condition and the second element of the pair is the action to be taken if the 
condition is true.

-- 
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 call a macro on each element of a list

2016-03-30 Thread Neil Van Dyke

Does either the below `fun-now` or `make-fun-for-later` do what you want?

 BEGIN CODE 
#lang racket/base

(define conditional-actions
  (list (cons (lambda () (= 2 (+ 1 1)))
  (lambda () (display "first!\n")))
(cons (lambda () (= 42 (* 2 21)))
  (lambda () (display "second!\n")

(define (fun-now lst)
  (for-each (lambda (pair)
  (and ((car pair))
   ((cdr pair
lst))

(display "fun-now...\n")
(fun-now conditional-actions)

(define (make-fun-for-later lst)
  (lambda ()
(for-each (lambda (pair)
(and ((car pair))
 ((cdr pair
  lst)))

(display "make-fun-for-later...\n")
(define fun-later (make-fun-for-later conditional-actions))
(display "fun-later...\n")
(fun-later)
 END CODE 

 BEGIN OUTPUT 
fun-now...
first!
second!
make-fun-for-later...
fun-later...
first!
second!
 END OUTPUT 

I gave this kind of example of using procedures because I don't know 
whether you're already familiar with how to use procedures/closures like 
this.


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.


[racket-users] Embed Racket in C and call Racket procedure

2016-03-30 Thread Anthony Sterrett
I appear to be swimming upstream. There are all sorts of tutorials and 
references for *extending* Racket with C, but precious little about *embedding* 
it. Unfortunately, I require the latter. 

I have a file hw.rkt with the following contents:

#lang racket/base

(provide hw) 

(define (hw) 
 (displayln "Hello, world!")) 

I would like to write a C program which uses an embedded Racket runtime to load 
and call the (hw) procedure. 

Resources I've found so far:

* http://docs.racket-lang.org/inside/embedding.html#%28part._3m_.Embedding%29

I have built and run the example program successfully, and thereby learned how 
to call a procedure provided by racket/base. I assume the same pattern applies 
for any library compiled with raco ctool.  My efforts to apply this knowledge 
to hw.rkt have so far failed me, though.

* http://docs.racket-lang.org/raco/c-mods.html

This page appears to say that what I want to do is *possible*, and tells me how 
to compile hw.rkt to a C file (which I have successfully done), but not how to 
use it afterward. 

I have asked this question on Stack Overflow and on Reddit, to no avail:

http://stackoverflow.com/q/36286921/2209270

https://www.reddit.com/r/Racket/comments/4ci29u/call_userprovided_racket_procedure_from_c_xpost/

The Stack Overflow link also includes what I've tried so far, and the error 
messages I've received for my efforts. 

An ideal answer would provide an example program in C that I could copy, 
compile, and run. An acceptable answer would tell me which C functions I'm 
supposed to use, and how to invoke them. 

I will appreciate any assistance you're able to render. 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] Embed Racket in C and call Racket procedure

2016-03-30 Thread Matthew Flatt
You were close with

 ((dynamic-require 'hw 'hw))

but you're missing a quote:

 ((dynamic-require ''hw 'hw))


When you make "base.c" as

  raco ctool --c-mods base.c hw.rkt

then it's like

 (module hw racket/base
   (provide hw) 
   (define (hw) (displayln "Hello, world!")))

at a REPL, and you'd require that module with

 (require 'hw)


When using `dynamic-require`, the module name must be quoted, which
means an odd-looking extra quote in this case:

 (dynamic-require ''hw )

Along similar lines, instead of

 v = scheme_intern_symbol("hw");
 scheme_namespace_require(v);

you'd need to use

  v = scheme_make_pair(scheme_intern_symbol("quote"),
   scheme_make_pair(scheme_intern_symbol("hw"),
scheme_make_null()));
  scheme_namespace_require(v);

The enclosed "hw.c" shows how to use scheme_dynamic_require(), which is
similar and probably what you want.


The documentation for `raco ctool --c-mods` doesn't explain what it
does with a file like "hw.rkt" --- i.e., that it's like declaring a
module 'hw, and that any connection to a "hw.rkt" file is discarded ---
and I'll work on the documentation.


At Wed, 30 Mar 2016 19:02:24 -0700 (PDT), Anthony Sterrett wrote:
> I appear to be swimming upstream. There are all sorts of tutorials and 
> references for *extending* Racket with C, but precious little about 
> *embedding* it. Unfortunately, I require the latter. 
> 
> I have a file hw.rkt with the following contents:
> 
> #lang racket/base
> 
> (provide hw) 
> 
> (define (hw) 
>  (displayln "Hello, world!")) 
> 
> I would like to write a C program which uses an embedded Racket runtime to 
> load and call the (hw) procedure. 
> 
> Resources I've found so far:
> 
> * http://docs.racket-lang.org/inside/embedding.html#%28part._3m_.Embedding%29
> 
> I have built and run the example program successfully, and thereby learned 
> how 
> to call a procedure provided by racket/base. I assume the same pattern 
> applies 
> for any library compiled with raco ctool.  My efforts to apply this knowledge 
> to hw.rkt have so far failed me, though.
> 
> * http://docs.racket-lang.org/raco/c-mods.html
> 
> This page appears to say that what I want to do is *possible*, and tells me 
> how to compile hw.rkt to a C file (which I have successfully done), but not 
> how to use it afterward. 
> 
> I have asked this question on Stack Overflow and on Reddit, to no avail:
> 
> http://stackoverflow.com/q/36286921/2209270
> 
> https://www.reddit.com/r/Racket/comments/4ci29u/call_userprovided_racket_proced
> ure_from_c_xpost/
> 
> The Stack Overflow link also includes what I've tried so far, and the error 
> messages I've received for my efforts. 
> 
> An ideal answer would provide an example program in C that I could copy, 
> compile, and run. An acceptable answer would tell me which C functions I'm 
> supposed to use, and how to invoke them. 
> 
> I will appreciate any assistance you're able to render. 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.

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


hw.c
Description: Binary data


Re: [racket-users] [racket] typed racket needs editor-snip%

2016-03-30 Thread WarGrey Gyoudmon Ju
I made a pull request here: https://github.com/racket/typed-racket/pull/328

but it fails, the error report shows that failures do not caused by my
changes, I think...

On Tue, Mar 29, 2016 at 7:27 PM, Sam Tobin-Hochstadt 
wrote:

> You can use `Editor-Snip%` by requiring it from `typed/racket/gui`.
>
> Sam
>
> On Tue, Mar 29, 2016 at 4:09 AM, WarGrey Gyoudmon Ju
>  wrote:
> > Hello, I am currently building a desktop application (which is a
> component
> > of a production system for customer) in typed racket.
> >
> > I found that typed/private/gui-types.rkt does have the definition of
> > Editor-Snip% but does not provide it in typed/racket/base. I do not know
> > where is your prefer place to do this. Would you please make it
> available?
> >
> > Thanks.
> >
> >
> > BTW, Racket is also a great language to *design* GUI applications(in a
> > programmable approach). Before I get deep into this kind of tasks, I
> thought
> > that the GUI infrastructure is poor, say, lacking of lots of useful
> > controllers. Actually, lots of them can be built with editor<%> and
> > racket/snip in few lines of code since this facility has a great (basic)
> > abstraction.
> >
> > --
> > 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.