[racket-users] Download the tsuro implementation from the paper

2020-11-24 Thread Nate Griswold
Hello. I've looked through the paper a couple of times and I don't see a
link to download the tsuro prototype. Is this code available somewhere?

Nate

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPo9OnnQKK%3D0yOZPbTuLyZjHMJp6i9TViLYgA2XtWrGejg%40mail.gmail.com.


Re: [racket-users] Messages going to spam?

2020-11-24 Thread Nate Griswold
Hm, ok. It looks like the messages still aren't going through It might be
since i unadded and readded myself at one point. I just sent another so
that might be approvable.

Nate


On Tue, Nov 24, 2020 at 9:48 AM Robby Findler 
wrote:

> I might have approved one (and when I did I also marked the email address
> is came from as always allowed to post so hopefully it won't happen again).
>
> Robby
>
>
> On Tue, Nov 24, 2020 at 9:16 AM Nate Griswold 
> wrote:
>
>> Thanks, Sam. That is what i wanted.
>>
>> Is there any way to allow all messages from that account from now on?
>>
>> Nate
>>
>>
>> On Tue, Nov 24, 2020 at 9:08 AM Sam Tobin-Hochstadt 
>> wrote:
>>
>>> Yes, those messages have been going to spam. I didn't approve them
>>> separately since I just saw the notification and you had already
>>> posted them with your gmail account.
>>>
>>> Sam
>>>
>>> On Tue, Nov 24, 2020 at 9:59 AM Nate Griswold 
>>> wrote:
>>> >
>>> > No rush but can an admin for the list check if my messages from my
>>> other email are being flagged suspicious? The other email is
>>> nate@manicmind.earth. I don't want to use my gmail account.
>>> >
>>> > Sorry if there is a better place to ask this.
>>> >
>>> > Nate
>>> >
>>> > --
>>> > 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.
>>> > To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/racket-users/CAM-xLPoQ6uv_w%3Dtsz%3DD8uXfEhysfano9ZRBFo1CxNNtHN8zTrQ%40mail.gmail.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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/CAM-xLPrBDaWoVsBU9TGELtrX0MCNYUf_ctwH1GHNEWMjE4aG-Q%40mail.gmail.com
>> <https://groups.google.com/d/msgid/racket-users/CAM-xLPrBDaWoVsBU9TGELtrX0MCNYUf_ctwH1GHNEWMjE4aG-Q%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPrszCZ2c%2BEVZrJPHdg%2BDWp4%3DkcFuh%2BoSg5a-1vm5613Ew%40mail.gmail.com.


Re: [racket-users] Messages going to spam?

2020-11-24 Thread Nate Griswold
Thanks, Sam. That is what i wanted.

Is there any way to allow all messages from that account from now on?

Nate


On Tue, Nov 24, 2020 at 9:08 AM Sam Tobin-Hochstadt 
wrote:

> Yes, those messages have been going to spam. I didn't approve them
> separately since I just saw the notification and you had already
> posted them with your gmail account.
>
> Sam
>
> On Tue, Nov 24, 2020 at 9:59 AM Nate Griswold 
> wrote:
> >
> > No rush but can an admin for the list check if my messages from my other
> email are being flagged suspicious? The other email is nate@manicmind.earth.
> I don't want to use my gmail account.
> >
> > Sorry if there is a better place to ask this.
> >
> > Nate
> >
> > --
> > 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.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAM-xLPoQ6uv_w%3Dtsz%3DD8uXfEhysfano9ZRBFo1CxNNtHN8zTrQ%40mail.gmail.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPrBDaWoVsBU9TGELtrX0MCNYUf_ctwH1GHNEWMjE4aG-Q%40mail.gmail.com.


[racket-users] Messages going to spam?

2020-11-24 Thread Nate Griswold
No rush but can an admin for the list check if my messages from my other
email are being flagged suspicious? The other email is nate@manicmind.earth.
I don't want to use my gmail account.

Sorry if there is a better place to ask this.

Nate

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPoQ6uv_w%3Dtsz%3DD8uXfEhysfano9ZRBFo1CxNNtHN8zTrQ%40mail.gmail.com.


Re: [racket-users] snappier place startup time

2020-11-24 Thread Nate Griswold
Oh, interesting. So compilation breaks the submodule out from the modules
if possible?

So anyway, it sounds like breaking my modules out into separate files will
improve performance in most cases.

Unfortunately, i need racket/place in the module that is my startup
bottleneck. If i modify the previous program to require racket/place and
compile, it takes around 180ms.

This is about what i can expect for a module that requires racket/place,
then?

Nate


On Tue, Nov 24, 2020 at 8:48 AM Matthew Flatt  wrote:

> Just to elaborate a little more:
>
> The difference is because the `test` submodule can be loaded
> independently from the compiled form. Loading the submodule from source
> requires loading the enclosing module, too (which depends on
> `racket/place` and more).
>
> At Tue, 24 Nov 2020 08:46:12 -0600, Nate Griswold wrote:
> > Awesome, thanks!
> >
> > Nate
> >
> >
> > On Tue, Nov 24, 2020 at 8:44 AM Sam Tobin-Hochstadt <
> sa...@cs.indiana.edu>
> > wrote:
> >
> > > Almost certainly the problem is expansion time. If I run that program
> > > on my machine, it takes about 200 ms. But if I compile the file to zo
> > > first with `raco make`, then it takes about 40 ms, basically identical
> > > to `racket/base`.
> > >
> > > Sam
> > >
> > > On Tue, Nov 24, 2020 at 9:39 AM Nate Griswold 
> > > wrote:
> > > >
> > > > Oops, i am having some issues with not getting to the list from my
> other
> > > email address. Here is a reply i sent for the record.
> > > >
> > > > ---
> > > >
> > > > Thank you, Matthew.
> > > >
> > > > The following code takes around 250ms on my machine. Any idea why? I
> was
> > > expecting it to be fast since the module is based on racket/base.
> > > >
> > > > #lang racket/base
> > > >
> > > > (require syntax/location)
> > > > (require racket/place)
> > > >
> > > >
> > > >
> > > > (module test racket/base
> > > >  (provide place-main)
> > > > racket
> > > >  (define (place-main pch)
> > > >   (void)))
> > > >
> > > > (time (place-wait (dynamic-place (quote-module-path test)
> 'place-main)))
> > > >
> > > > Nate
> > > >
> > > >
> > > > On Tue, Nov 24, 2020 at 8:35 AM Nathaniel W Griswold
> > >  wrote:
> > > >>
> > > >> Thank you, Matthew.
> > > >>
> > > >> The following code takes around 250ms on my machine. Any idea why? I
> > > was expecting it to be fast since the module is based on racket/base.
> > > >>
> > > >> #lang racket/base
> > > >>
> > > >> (require syntax/location)
> > > >> (require racket/place)
> > > >>
> > > >>
> > > >>
> > > >> (module test racket/base
> > > >>  (provide place-main)
> > > >> racket
> > > >>  (define (place-main pch)
> > > >>   (void)))
> > > >>
> > > >> (time (place-wait (dynamic-place (quote-module-path test)
> 'place-main)))
> > > >>
> > > >> Nate
> > > >>
> > > >> On Nov 24, 2020, at 8:16 AM, Matthew Flatt 
> wrote:
> > > >>
> > > >> The bottleneck for place startup is loading modules into the new
> place,
> > > >> including modules like `racket/base`.
> > > >>
> > > >> For example,
> > > >>
> > > >>  (place-wait (dynamic-place 'racket 'void))
> > > >>
> > > >> takes around 200ms on my machine, while
> > > >>
> > > >>  (place-wait (dynamic-place 'racket/base 'void))
> > > >>
> > > >> takes around 30ms and
> > > >>
> > > >>  (place-wait (dynamic-place 'racket/kernel 'void))
> > > >>
> > > >> takes around 10ms.
> > > >>
> > > >> It sounds like you're already aware that the complexity of the
> module
> > > >> loaded into a place matters, though. Beyond using a minimal set of
> > > >> modules, I don't have any way to make place startup faster.
> > > >>
> > > >> Matthew
> > > >>
> > > >> At Tue, 24 Nov 2020 05:04:19 -0600, Nate Griswold wrote:
> > > >>
> > > >> Is there any

Re: [racket-users] snappier place startup time

2020-11-24 Thread Nate Griswold
Awesome, thanks!

Nate


On Tue, Nov 24, 2020 at 8:44 AM Sam Tobin-Hochstadt 
wrote:

> Almost certainly the problem is expansion time. If I run that program
> on my machine, it takes about 200 ms. But if I compile the file to zo
> first with `raco make`, then it takes about 40 ms, basically identical
> to `racket/base`.
>
> Sam
>
> On Tue, Nov 24, 2020 at 9:39 AM Nate Griswold 
> wrote:
> >
> > Oops, i am having some issues with not getting to the list from my other
> email address. Here is a reply i sent for the record.
> >
> > ---
> >
> > Thank you, Matthew.
> >
> > The following code takes around 250ms on my machine. Any idea why? I was
> expecting it to be fast since the module is based on racket/base.
> >
> > #lang racket/base
> >
> > (require syntax/location)
> > (require racket/place)
> >
> >
> >
> > (module test racket/base
> >  (provide place-main)
> > racket
> >  (define (place-main pch)
> >   (void)))
> >
> > (time (place-wait (dynamic-place (quote-module-path test) 'place-main)))
> >
> > Nate
> >
> >
> > On Tue, Nov 24, 2020 at 8:35 AM Nathaniel W Griswold
>  wrote:
> >>
> >> Thank you, Matthew.
> >>
> >> The following code takes around 250ms on my machine. Any idea why? I
> was expecting it to be fast since the module is based on racket/base.
> >>
> >> #lang racket/base
> >>
> >> (require syntax/location)
> >> (require racket/place)
> >>
> >>
> >>
> >> (module test racket/base
> >>  (provide place-main)
> >> racket
> >>  (define (place-main pch)
> >>   (void)))
> >>
> >> (time (place-wait (dynamic-place (quote-module-path test) 'place-main)))
> >>
> >> Nate
> >>
> >> On Nov 24, 2020, at 8:16 AM, Matthew Flatt  wrote:
> >>
> >> The bottleneck for place startup is loading modules into the new place,
> >> including modules like `racket/base`.
> >>
> >> For example,
> >>
> >>  (place-wait (dynamic-place 'racket 'void))
> >>
> >> takes around 200ms on my machine, while
> >>
> >>  (place-wait (dynamic-place 'racket/base 'void))
> >>
> >> takes around 30ms and
> >>
> >>  (place-wait (dynamic-place 'racket/kernel 'void))
> >>
> >> takes around 10ms.
> >>
> >> It sounds like you're already aware that the complexity of the module
> >> loaded into a place matters, though. Beyond using a minimal set of
> >> modules, I don't have any way to make place startup faster.
> >>
> >> Matthew
> >>
> >> At Tue, 24 Nov 2020 05:04:19 -0600, Nate Griswold wrote:
> >>
> >> Is there any way to make places startup faster? Even if i do an explicit
> >> round trip using place-channel-put and place-channel-get on both sides,
> it
> >> takes on the order of centiseconds for near empty places to start up.
> >>
> >> My program requires the threads for a couple places to be set up before
> it
> >> can operate, so this impacts my startup time by quite a bit.
> >>
> >> I have one place that has a very simple module and one place with a more
> >> complicated module. Is there some sequence that i should do things in
> for
> >> the minimal startup time? It seems nothing i do really helps much.
> >>
> >> Nate
> >>
> >> --
> >> 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.
> >> To view this discussion on the web visit
> >>
> https://groups.google.com/d/msgid/racket-users/CAM-xLPpvfCHHDDpfNmuTWQOyfYfEJ7v
> >> m1c_dS7nj3FxaEFVm2Q%40mail.gmail.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.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAM-xLPqtJrem4j%3DUi3fbrduoahsXCNNA2JPuB0Tt9dissiu5KA%40mail.gmail.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPqVgEBvrRzjU7%3DX_h3Wy_YUH11G6CX5%2BKjSct26pi3oEA%40mail.gmail.com.


Re: [racket-users] snappier place startup time

2020-11-24 Thread Nate Griswold
Oops, i am having some issues with not getting to the list from my other
email address. Here is a reply i sent for the record.

---

Thank you, Matthew.

The following code takes around 250ms on my machine. Any idea why? I was
expecting it to be fast since the module is based on racket/base.

#lang racket/base

(require syntax/location)
(require racket/place)


(module test racket/base
 (provide place-main)
racket
 (define (place-main pch)
  (void)))

(time (place-wait (dynamic-place (quote-module-path test) 'place-main)))

Nate


On Tue, Nov 24, 2020 at 8:35 AM Nathaniel W Griswold 
wrote:

> Thank you, Matthew.
>
> The following code takes around 250ms on my machine. Any idea why? I was
> expecting it to be fast since the module is based on racket/base.
>
> #lang racket/base
>
> (require syntax/location)
> (require racket/place)
>
>
> (module test racket/base
>  (provide place-main)
> racket
>  (define (place-main pch)
>   (void)))
>
> (time (place-wait (dynamic-place (quote-module-path test) 'place-main)))
>
> Nate
>
> On Nov 24, 2020, at 8:16 AM, Matthew Flatt  wrote:
>
> The bottleneck for place startup is loading modules into the new place,
> including modules like `racket/base`.
>
> For example,
>
>  (place-wait (dynamic-place 'racket 'void))
>
> takes around 200ms on my machine, while
>
>  (place-wait (dynamic-place 'racket/base 'void))
>
> takes around 30ms and
>
>  (place-wait (dynamic-place 'racket/kernel 'void))
>
> takes around 10ms.
>
> It sounds like you're already aware that the complexity of the module
> loaded into a place matters, though. Beyond using a minimal set of
> modules, I don't have any way to make place startup faster.
>
> Matthew
>
> At Tue, 24 Nov 2020 05:04:19 -0600, Nate Griswold wrote:
>
> Is there any way to make places startup faster? Even if i do an explicit
> round trip using place-channel-put and place-channel-get on both sides, it
> takes on the order of centiseconds for near empty places to start up.
>
> My program requires the threads for a couple places to be set up before it
> can operate, so this impacts my startup time by quite a bit.
>
> I have one place that has a very simple module and one place with a more
> complicated module. Is there some sequence that i should do things in for
> the minimal startup time? It seems nothing i do really helps much.
>
> Nate
>
> --
> 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.
> To view this discussion on the web visit
>
> https://groups.google.com/d/msgid/racket-users/CAM-xLPpvfCHHDDpfNmuTWQOyfYfEJ7v
> m1c_dS7nj3FxaEFVm2Q%40mail.gmail.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPqtJrem4j%3DUi3fbrduoahsXCNNA2JPuB0Tt9dissiu5KA%40mail.gmail.com.


Re: [racket-users] Questions

2020-11-24 Thread Nate Griswold
Please ignore that last sentence.

Nate


On Tue, Nov 24, 2020 at 4:59 AM Nate Griswold 
wrote:

> Very helpful.
>
> I have modified my code to use callbacks and everything is working as
> expected. It is interesting that everything was working fine with my
> racket_apply and racket_eval hacks, as well.
>
> I have gotten my communication with racket down to one put and one get
> closure, wrapping a call to place-channel-put and place-channel-get. I
> think this is working well and the c client module is now mostly oblivious
> to racket, it just thinks it is using standard c function pointers so that
> is good. I do still have to Sactivate_thread and Sdeactivate_thread to
> construct my values and call the procs but that is ok, it is nice now.
>
> The cast works properly for me, i thought i had tried that already but it
> works fine. I didn't realize `cast` works for source values that are
> already racket values but it makes sense that it could detect racket values
> and just not call c-to-racket, i guess.
>
> Nate
>
>
> On Mon, Nov 23, 2020 at 7:01 AM Matthew Flatt  wrote:
>
>> At Mon, 23 Nov 2020 00:14:56 -0600, Nate Griswold wrote:
>> > Hello. I have a few questions:
>> >
>> > 1) Why do the docs say that racket_eval and racket_apply eval and apply
>> in
>> > the “initial” or “original” racket thread? I have verified that the
>> thread
>> > id returned from pthread_self when using racket_apply in c code called
>> from
>> > a racket place is different from the thread id of the thread i called
>> > racket_boot on.
>>
>> The `racket_apply` function was intended for use only in the OS thread
>> where Racket is booted, and only "outside" to get Racket started. It's
>> not intended for use in callbacks from Racket.
>>
>> That's generally true for functions listed in sections 4-6 of "Inside",
>> and I see that the intent is not remotely clear there. I'll improve the
>> documentation.
>>
>> To call back to Racket from C code, you should use the Racket FFI,
>> where a Racket function that's passed to C gets converted to a function
>> pointer for the C side. When you call that callback (as a regular C
>> function call), various bits of Scheme and Racket state get
>> configured/restored in a consistent way before jumping to the wrapped
>> Racket code as a callback.
>>
>> For simple things, it turns out that `Scall0`, etc. would work to
>> invoke a callback within the Racket context that had called into C, but
>> there are many pitfalls, so you shouldn't do that.
>>
>> You definitely should not use `racket_apply` or `racket_eval` from C
>> that was called from Racket. It will... well, do something. Take the
>> uncertainly of using `Scall0` and multiply by 100, since functions like
>> `racket_apply` specifically attempt to interact with the thread
>> scheduler.
>>
>> > 2) I noticed that if i racket_eval in c code called by a racket place, i
>> > can’t evaluate things that would otherwise (in racket code) be
>> available in
>> > the place’s namespace. What is the correct way to get at things in the
>> > place’s racket namespace from c code? Is my problem unique to using a
>> > place, or would i have this problem in a non-place scenario as well?
>>
>> I think it's probably not just about places, but let me answer the
>> "correct way" question with the next bullet.
>>
>> > 3) (related to 2) I want to be able to put and get from a place channel
>> > from a long-running c function. If i just pass a place channel to the
>> > function, that is wrong because if i am correct in my thinking (and in
>> what
>> > i have witnessed) there is a chance that when i go to use that channel
>> in
>> > the future, it will have been moved by the garbage collector. Is there
>> any
>> > way to prevent a specific value from being garbage collected, at least
>> for
>> > the lifetime of my place? This is related to (2) because i actually
>> don’t
>> > need this functionality if i can just racket_eval to get at the place
>> > channel from the namespace of the place’s module in the middle of a
>> > Sactivate_thread / Sdeactivate_thread session.
>>
>> The best approach here is to hand the C code a callback, which it will
>> see as plain old C functions. Maybe there's one callback to get from
>> the channel and another to put to the channel --- where the channel is
>> in the closure of the function, although the C side has no idea about
>> closures. If you go that route, 

[racket-users] Re: snappier place startup time

2020-11-24 Thread Nate Griswold
Oh, and i'm still on Racket 7.8. Don't know if 7.9 addresses anything.

Nate


On Tue, Nov 24, 2020 at 5:04 AM Nate Griswold 
wrote:

> Is there any way to make places startup faster? Even if i do an explicit
> round trip using place-channel-put and place-channel-get on both sides, it
> takes on the order of centiseconds for near empty places to start up.
>
> My program requires the threads for a couple places to be set up before it
> can operate, so this impacts my startup time by quite a bit.
>
> I have one place that has a very simple module and one place with a more
> complicated module. Is there some sequence that i should do things in for
> the minimal startup time? It seems nothing i do really helps much.
>
> Nate
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPqsKQNA8_g25wgtFmK7MzADZs%2B2wdCKt7Em%2BKteWh02-A%40mail.gmail.com.


[racket-users] snappier place startup time

2020-11-24 Thread Nate Griswold
Is there any way to make places startup faster? Even if i do an explicit
round trip using place-channel-put and place-channel-get on both sides, it
takes on the order of centiseconds for near empty places to start up.

My program requires the threads for a couple places to be set up before it
can operate, so this impacts my startup time by quite a bit.

I have one place that has a very simple module and one place with a more
complicated module. Is there some sequence that i should do things in for
the minimal startup time? It seems nothing i do really helps much.

Nate

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPpvfCHHDDpfNmuTWQOyfYfEJ7vm1c_dS7nj3FxaEFVm2Q%40mail.gmail.com.


Re: [racket-users] Questions

2020-11-24 Thread Nate Griswold
Very helpful.

I have modified my code to use callbacks and everything is working as
expected. It is interesting that everything was working fine with my
racket_apply and racket_eval hacks, as well.

I have gotten my communication with racket down to one put and one get
closure, wrapping a call to place-channel-put and place-channel-get. I
think this is working well and the c client module is now mostly oblivious
to racket, it just thinks it is using standard c function pointers so that
is good. I do still have to Sactivate_thread and Sdeactivate_thread to
construct my values and call the procs but that is ok, it is nice now.

The cast works properly for me, i thought i had tried that already but it
works fine. I didn't realize `cast` works for source values that are
already racket values but it makes sense that it could detect racket values
and just not call c-to-racket, i guess.

Nate


On Mon, Nov 23, 2020 at 7:01 AM Matthew Flatt  wrote:

> At Mon, 23 Nov 2020 00:14:56 -0600, Nate Griswold wrote:
> > Hello. I have a few questions:
> >
> > 1) Why do the docs say that racket_eval and racket_apply eval and apply
> in
> > the “initial” or “original” racket thread? I have verified that the
> thread
> > id returned from pthread_self when using racket_apply in c code called
> from
> > a racket place is different from the thread id of the thread i called
> > racket_boot on.
>
> The `racket_apply` function was intended for use only in the OS thread
> where Racket is booted, and only "outside" to get Racket started. It's
> not intended for use in callbacks from Racket.
>
> That's generally true for functions listed in sections 4-6 of "Inside",
> and I see that the intent is not remotely clear there. I'll improve the
> documentation.
>
> To call back to Racket from C code, you should use the Racket FFI,
> where a Racket function that's passed to C gets converted to a function
> pointer for the C side. When you call that callback (as a regular C
> function call), various bits of Scheme and Racket state get
> configured/restored in a consistent way before jumping to the wrapped
> Racket code as a callback.
>
> For simple things, it turns out that `Scall0`, etc. would work to
> invoke a callback within the Racket context that had called into C, but
> there are many pitfalls, so you shouldn't do that.
>
> You definitely should not use `racket_apply` or `racket_eval` from C
> that was called from Racket. It will... well, do something. Take the
> uncertainly of using `Scall0` and multiply by 100, since functions like
> `racket_apply` specifically attempt to interact with the thread
> scheduler.
>
> > 2) I noticed that if i racket_eval in c code called by a racket place, i
> > can’t evaluate things that would otherwise (in racket code) be available
> in
> > the place’s namespace. What is the correct way to get at things in the
> > place’s racket namespace from c code? Is my problem unique to using a
> > place, or would i have this problem in a non-place scenario as well?
>
> I think it's probably not just about places, but let me answer the
> "correct way" question with the next bullet.
>
> > 3) (related to 2) I want to be able to put and get from a place channel
> > from a long-running c function. If i just pass a place channel to the
> > function, that is wrong because if i am correct in my thinking (and in
> what
> > i have witnessed) there is a chance that when i go to use that channel in
> > the future, it will have been moved by the garbage collector. Is there
> any
> > way to prevent a specific value from being garbage collected, at least
> for
> > the lifetime of my place? This is related to (2) because i actually don’t
> > need this functionality if i can just racket_eval to get at the place
> > channel from the namespace of the place’s module in the middle of a
> > Sactivate_thread / Sdeactivate_thread session.
>
> The best approach here is to hand the C code a callback, which it will
> see as plain old C functions. Maybe there's one callback to get from
> the channel and another to put to the channel --- where the channel is
> in the closure of the function, although the C side has no idea about
> closures. If you go that route, then as long as you retain a reference
> to the callback closure on the Racket side, the callback function
> itself won't move.
>
> Overall, reasoning about the interaction between Racket/Scheme and C
> interaction from the C side is very difficult. The more you can arrange
> for the C code to oblivious to Racket, the easier things get, because
> the Racket-side tools for interacting with C are much better.
>
> > 3) Is there any way to pass a c callback function in

[racket-users] Questions

2020-11-22 Thread Nate Griswold
Hello. I have a few questions:

1) Why do the docs say that racket_eval and racket_apply eval and apply in
the “initial” or “original” racket thread? I have verified that the thread
id returned from pthread_self when using racket_apply in c code called from
a racket place is different from the thread id of the thread i called
racket_boot on.

2) I noticed that if i racket_eval in c code called by a racket place, i
can’t evaluate things that would otherwise (in racket code) be available in
the place’s namespace. What is the correct way to get at things in the
place’s racket namespace from c code? Is my problem unique to using a
place, or would i have this problem in a non-place scenario as well?

3) (related to 2) I want to be able to put and get from a place channel
from a long-running c function. If i just pass a place channel to the
function, that is wrong because if i am correct in my thinking (and in what
i have witnessed) there is a chance that when i go to use that channel in
the future, it will have been moved by the garbage collector. Is there any
way to prevent a specific value from being garbage collected, at least for
the lifetime of my place? This is related to (2) because i actually don’t
need this functionality if i can just racket_eval to get at the place
channel from the namespace of the place’s module in the middle of a
Sactivate_thread / Sdeactivate_thread session.

3) Is there any way to pass a c callback function into racket so that
racket can call that function? I defined a ctype for the function, but i
couldn’t think of a way to cast a pointer value passed into racket from c
to an instance of my ctype (the `cast` function takes existing ctypes and
not numeric values). Is there any way to manually make a value for my
function ctype using an existing pointer value?


Regarding 2 and 3, i was able to solve the underlying problem behind those
questions by creating a module to stash the channel in and passing its
module path into c code, then importing it. I wonder if anyone has a better
solution? Previously, i was using the `place` function for brevity.

Here is what i did:

(module myplace racket/base
 (provide place-main)
 (require syntax/location)

 (module stash racket/base
   (provide client-channel)
   (define client-channel (make-parameter #f)))

 (require 'stash)

 (define (place-main ch)
   (client-channel ch)
   (red_client_run_from_racket ch (quote-module-path stash))
   (error "Should not get here")))

(define p (dynamic-place (quote-module-path myplace) 'place-main))

and in c code:

int red_client_run_from_racket(ptr ch, ptr path) {
   ...
 racket_namespace_require(path);
   ...
}

Thank you

Nate

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPpU7sQ7PoArCf27W4BVZzM-%2BUu2v4Abp2%3DubuPiFi%3D%2Bvg%40mail.gmail.com.


[racket-users] Re: access a `#` from c code

2020-10-06 Thread Nate Griswold
I realized i already asked this question and Matthew Flatt had responded
like this, for anyone wondering:

---

I see that there's not a good way right now, but here's a workaround
that uses information about the current layout:

A cpointer value is implemented as a Chez Scheme record with either 1
field or 2 fields. There are 2 fields only when the cpointer has an
offset as a result of `ptr-add`, so you can probably ignore that.

To extract the first field, assume that a record has the same layout as
a vector, so use `Svector_ref(p, 0)` to extra the field from the
cpointer `p`.

Then you can use `Sunsigned_value()` to convert that field value to a
pointer-sized integer, then case.

I might have some part of that wrong, but it should be close... Of
course, there should be better support for record-field access and
cpointer extraction, so I'll add to the API.

---

Nate


On Mon, Oct 5, 2020 at 3:59 AM Nate Griswold  wrote:

> I have a temporary workaround where i have created an ffi function
> racket-side to call into c, so that i can automatically use the _cptr's
> racket-to-c function. I wonder if there is a way to manually extract the c
> value for the case where i want it in a return value of racket_apply.
>
> Nate
>
>
> On Mon, Oct 5, 2020 at 3:26 AM Nate Griswold 
> wrote:
>
>> Note this is from a return value of racket_apply; i called a racket
>> function from c code and want to store the cptr it has returned.
>>
>> Nate
>>
>>
>> On Mon, Oct 5, 2020 at 3:25 AM Nate Griswold 
>> wrote:
>>
>>> What is the best way to access a value that is a cpointer from c code?
>>> Should i convert it to an integer? I have been looking at this for a while,
>>> about an hour, and will continue to look but just thought the list might be
>>> able to answer faster. I know there are chez functions to convert `ptr`s to
>>> integers but those aren't working for me (not an integer error).
>>>
>>> Nate
>>>
>>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPr9dZkz3FkWs_oh-jtcR7bgsuhSgYfTvKHFrCPaqo6GLQ%40mail.gmail.com.


[racket-users] Re: access a `#` from c code

2020-10-05 Thread Nate Griswold
I have a temporary workaround where i have created an ffi function
racket-side to call into c, so that i can automatically use the _cptr's
racket-to-c function. I wonder if there is a way to manually extract the c
value for the case where i want it in a return value of racket_apply.

Nate


On Mon, Oct 5, 2020 at 3:26 AM Nate Griswold  wrote:

> Note this is from a return value of racket_apply; i called a racket
> function from c code and want to store the cptr it has returned.
>
> Nate
>
>
> On Mon, Oct 5, 2020 at 3:25 AM Nate Griswold 
> wrote:
>
>> What is the best way to access a value that is a cpointer from c code?
>> Should i convert it to an integer? I have been looking at this for a while,
>> about an hour, and will continue to look but just thought the list might be
>> able to answer faster. I know there are chez functions to convert `ptr`s to
>> integers but those aren't working for me (not an integer error).
>>
>> Nate
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPrLiyjzqZvuKd-fK57%2BE6nfJXxz8YF7vpTkZTpsa%3D80SA%40mail.gmail.com.


[racket-users] Re: access a `#` from c code

2020-10-05 Thread Nate Griswold
Note this is from a return value of racket_apply; i called a racket
function from c code and want to store the cptr it has returned.

Nate


On Mon, Oct 5, 2020 at 3:25 AM Nate Griswold  wrote:

> What is the best way to access a value that is a cpointer from c code?
> Should i convert it to an integer? I have been looking at this for a while,
> about an hour, and will continue to look but just thought the list might be
> able to answer faster. I know there are chez functions to convert `ptr`s to
> integers but those aren't working for me (not an integer error).
>
> Nate
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPpcyOPQuX-pHa-2QjDStbT3uDB73qr3-OtL7SyYT32%3DMQ%40mail.gmail.com.


[racket-users] access a `#` from c code

2020-10-05 Thread Nate Griswold
What is the best way to access a value that is a cpointer from c code?
Should i convert it to an integer? I have been looking at this for a while,
about an hour, and will continue to look but just thought the list might be
able to answer faster. I know there are chez functions to convert `ptr`s to
integers but those aren't working for me (not an integer error).

Nate

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPoxm_%2BqwFiOMRN%2Bb-ybAb97HThOoTXh7sk5kgxewiAVjg%40mail.gmail.com.


Re: [racket-users] question about places and main thread gc

2020-10-01 Thread Nate Griswold
I looked into it, it seems to be implemented in `src/cs/rumble/foreign.ss`
using chez get-thread-id, comparing it to 0 and using a stored ref to the
original async callback queue, so looks like this is not exposed to the
user. Hm.

Nate


On Thu, Oct 1, 2020 at 6:58 AM Nate Griswold  wrote:

> Thanks, Matthew. That helps. I was working on my project again and this
> came up again, but I still don't quite have my use-case figured out. I have
> two additional (in addition to main thread place) places that i wanted to
> send messages to using standard chez and racket c calls (and not relying on
> something like zeromq or file descriptors). I wanted to allow garbage
> collection and `#:in-original-place?` dependent ffi libs to work correctly.
> Then i guess I need to keep my original place in scheme code and *not*
> `Sdeactivate_thread`ed most of the time to make this work. I had the idea
> from what you said that i might Sactivate_thread a completely different
> os-level thread in order to call into scheme using say racket_apply on
> `place-channel-put`. Can i do this or no? I was thinking no because...
>
> From the docs for `#:in-original-place?`:
>
> """
> If in-original-place? is true, then when a foreign callout
> <https://docs.racket-lang.org/foreign/foreign_procedures.html#%28tech._callout%29>
> procedure with the generated type is called in any Racket place
> <https://docs.racket-lang.org/reference/places.html#%28tech._place%29>,
> the procedure is called from the original Racket place. Use this mode for a
> foreign function that is not thread-safe at the C level, which means that
> it is not place-safe at the Racket level. Callbacks
> <https://docs.racket-lang.org/foreign/foreign_procedures.html#%28tech._callback%29>
> from place-unsafe code back into Racket at a non-original place typically
> will not work, since the place of the Racket code may have a different
> allocator than the original place.
> """
>
> I guess this means os threads use completely different allocators and
> sharing data among different `Sactivate_thread`ed threads doesn't make any
> sense at all. Is there any way to do this (command my places using the
> basic chez and racket funcs like racket_eval and Scons and racket_apply) or
> should i just use messaging over zeromq or an fd to my main thread? Maybe
> if place descriptors are guaranteed shared among all os-level threads then
> i can do it. I guess if `#:in-original-place?` exists there must be some
> way to do it, but maybe it's not exposed to the user. Also, is there any
> way to get the place descriptor for the current place or the main place? I
> didn't see any in the docs. I guess i should just start reading the racket
> source at this point.
>
> Also maybe i'm missing a simpler solution. Any help would be appreciated.
> Thanks.
>
> Nate
>
>
> On Mon, Sep 14, 2020 at 6:47 AM Matthew Flatt  wrote:
>
>> At Mon, 14 Sep 2020 00:34:08 -0500, Nate Griswold wrote:
>> > If i understand correctly, in racket cs embedded if i am not currently
>> > running anything in the main racket thread then gc cannot happen. But
>> the
>> > next time i make a call into racket on that reserved racket thread
>> (which
>> > has not been shut down, and by using racket_apply or some such) then gc
>> can
>> > happen. But i do not know about the other threads that racket has
>> spawned.
>>
>> In Racket CS, you can enable GC without the main thread by deactivating
>> the thread. At the Racket level, use `#blocking? #t` for a foreign
>> function to deactivate the current thread while calling the function.
>> At the C level, you can use `Sdeactivate_thread` and
>> `Sactivate_therad` from Chez Scheme's API.
>>
>> Racket BC doesn't have a notation of deactivating a thread. Most GCs
>> with BC can run in separate places even without the main thread active,
>> but the main thread is needed when there has been enough shared-space
>> allocation that all threads must be involved.
>>
>> One caution for both CS and BC, though: Some foreign-library bindings
>> use `#:in-original-place?` to make use of the foreign library
>> single-threaded by routing all calls through the main place. That
>> requires the main thread to be active.
>>
>>
>> Matthew
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPp_vT-DadahcHh57d9EB5nw8mHNeVzK1Pp42GVLCzbySA%40mail.gmail.com.


Re: [racket-users] question about places and main thread gc

2020-10-01 Thread Nate Griswold
Thanks, Matthew. That helps. I was working on my project again and this
came up again, but I still don't quite have my use-case figured out. I have
two additional (in addition to main thread place) places that i wanted to
send messages to using standard chez and racket c calls (and not relying on
something like zeromq or file descriptors). I wanted to allow garbage
collection and `#:in-original-place?` dependent ffi libs to work correctly.
Then i guess I need to keep my original place in scheme code and *not*
`Sdeactivate_thread`ed most of the time to make this work. I had the idea
from what you said that i might Sactivate_thread a completely different
os-level thread in order to call into scheme using say racket_apply on
`place-channel-put`. Can i do this or no? I was thinking no because...

>From the docs for `#:in-original-place?`:

"""
If in-original-place? is true, then when a foreign callout
<https://docs.racket-lang.org/foreign/foreign_procedures.html#%28tech._callout%29>
procedure with the generated type is called in any Racket place
<https://docs.racket-lang.org/reference/places.html#%28tech._place%29>, the
procedure is called from the original Racket place. Use this mode for a
foreign function that is not thread-safe at the C level, which means that
it is not place-safe at the Racket level. Callbacks
<https://docs.racket-lang.org/foreign/foreign_procedures.html#%28tech._callback%29>
from place-unsafe code back into Racket at a non-original place typically
will not work, since the place of the Racket code may have a different
allocator than the original place.
"""

I guess this means os threads use completely different allocators and
sharing data among different `Sactivate_thread`ed threads doesn't make any
sense at all. Is there any way to do this (command my places using the
basic chez and racket funcs like racket_eval and Scons and racket_apply) or
should i just use messaging over zeromq or an fd to my main thread? Maybe
if place descriptors are guaranteed shared among all os-level threads then
i can do it. I guess if `#:in-original-place?` exists there must be some
way to do it, but maybe it's not exposed to the user. Also, is there any
way to get the place descriptor for the current place or the main place? I
didn't see any in the docs. I guess i should just start reading the racket
source at this point.

Also maybe i'm missing a simpler solution. Any help would be appreciated.
Thanks.

Nate


On Mon, Sep 14, 2020 at 6:47 AM Matthew Flatt  wrote:

> At Mon, 14 Sep 2020 00:34:08 -0500, Nate Griswold wrote:
> > If i understand correctly, in racket cs embedded if i am not currently
> > running anything in the main racket thread then gc cannot happen. But the
> > next time i make a call into racket on that reserved racket thread (which
> > has not been shut down, and by using racket_apply or some such) then gc
> can
> > happen. But i do not know about the other threads that racket has
> spawned.
>
> In Racket CS, you can enable GC without the main thread by deactivating
> the thread. At the Racket level, use `#blocking? #t` for a foreign
> function to deactivate the current thread while calling the function.
> At the C level, you can use `Sdeactivate_thread` and
> `Sactivate_therad` from Chez Scheme's API.
>
> Racket BC doesn't have a notation of deactivating a thread. Most GCs
> with BC can run in separate places even without the main thread active,
> but the main thread is needed when there has been enough shared-space
> allocation that all threads must be involved.
>
> One caution for both CS and BC, though: Some foreign-library bindings
> use `#:in-original-place?` to make use of the foreign library
> single-threaded by routing all calls through the main place. That
> requires the main thread to be active.
>
>
> Matthew
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPpBNgo%2B1Q_DsyoCBqqjv4im%3DW7yqAaM0yG5QQ3Qdvp7Ug%40mail.gmail.com.


Re: [racket-users] question about places and main thread gc

2020-09-13 Thread Nate Griswold
Sorry, it's all a bit simpler than i'm making it out to be.

Basically, i want to run racket from c code (embedded i guess, but i'm not
compiling any embedded c files). This is because i want to run everything
in one process. I want to have actual parallelism so that is why i'm using
places. I have one main racket thread that i currently have an infinite
loop using zeromq to listen for messages on. This is a dedicated thread.
But first on that thread i set up two other racket places to do my
concurrent work. The main racket thread then accepts messages and
dispatches to the two places depending on what the message is.

So the question is simply: do i need to have my infinite loop on my main
thread sitting there waiting for messages (and have custom communication),
or is there some better way to do it like just using the standard racket cs
calls.

If i understand correctly, in racket cs embedded if i am not currently
running anything in the main racket thread then gc cannot happen. But the
next time i make a call into racket on that reserved racket thread (which
has not been shut down, and by using racket_apply or some such) then gc can
happen. But i do not know about the other threads that racket has spawned.

Thanks

Nate


On Sun, Sep 13, 2020 at 5:40 PM George Neuner  wrote:

>
> On 9/13/2020 4:12 PM, Nate Griswold wrote:
>
> Sorry, i forgot to mention this would be interfacing on the main thread
> from c
>
> does this still hold true? Like if a c call returns does it kill the
> places?
>
> Nate
>
>
> I'm not really sure what you are asking:  it sounds like you are wanting
> to embed Racket into a C program ... if that is the case, then the primary
> thread is in the C program and any/all Racket threads will be secondary.
>
> I don't know that Racket's place API even works in an embedded scenario.
> You certainly can create multiple threads within your C program and run
> Racket in them, but it's hard to share a Racket environment, and if you
> create a separate execution environment for each thread, then their
> operations will be independent of one another.
>
> If you just call a Racket function from C, that function will be executed
> in the same thread as the caller, and it will return to the caller when it
> finishes.  Of course that function could have side effects such as
> signaling a separate Racket thread to terminate.
>
> A lot depends on what you are trying to do and how you structure your
> solution.
>
>
> George
>
>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPoKRxGcAKdq89vb%2BRwG8OmKmYxJwnt8DCG7SLPMtk7%3D0Q%40mail.gmail.com.


Re: [racket-users] question about places and main thread gc

2020-09-13 Thread Nate Griswold
The reason i'm asking is i am dedicating a thread to racket after calling
racket_boot on it.

Nate


On Sun, Sep 13, 2020 at 3:12 PM Nate Griswold 
wrote:

> Sorry, i forgot to mention this would be interfacing on the main thread
> from c
>
> does this still hold true? Like if a c call returns does it kill the
> places?
>
> Nate
>
>
> On Sun, Sep 13, 2020 at 12:17 PM George Neuner 
> wrote:
>
>>
>>
>> On 9/13/2020 3:55 AM, Nate Griswold wrote:
>>
>>
>> I am making an app that basically spawns two racket places and i want to
>> be able to communicate with them from c code.
>>
>> Will gc happen in the two racket places if i don't keep the main thread
>> (the one that spawned the places) running?
>>
>>
>> Exiting the main thread kills the process.  "dynamic"[1] places are (OS
>> level) threads within the same process and they will die with it.
>> [Technically the main thread is itself a place, but normally we don't use
>> place  terminology when talking about the main thread unless there are
>> other places involved.]
>>
>> I was thinking about whether i should keep the main thread running and
>> block on a stream read, sending it messages, or if i can only call into the
>> main thread when i need something using racket/chezscheme apis. I guess it
>> would be simpler to just talk directly to the main thread when i need to,
>> which is why i'm asking. Otherwise i'm thinking of just using zeromq on the
>> main thread.
>>
>>
>> You certainly can talk to any of the places individually ... but you do
>> need the main thread to remain running (even if just waiting on some event)
>> if you want dynamic places to continue running.
>>
>>
>> Now "distributed"[2,3] places are separate processes - you can start them
>> and they will continue running regardless of what happens to the process
>> that spawned them.
>>
>> Nate
>>
>>
>> Hope this helps,
>> George
>>
>> [1]  https://docs.racket-lang.org/reference/places.html
>> [2]  https://docs.racket-lang.org/distributed-places/index.html
>> [3]  https://pkgd.racket-lang.org/pkgn/search?q=loci
>>
>>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPoVb4jBwefUgQ5UhgGEuwvpnso%2BMHgn6fH1D714LHDeyw%40mail.gmail.com.


Re: [racket-users] question about places and main thread gc

2020-09-13 Thread Nate Griswold
Sorry, i forgot to mention this would be interfacing on the main thread
from c

does this still hold true? Like if a c call returns does it kill the places?

Nate


On Sun, Sep 13, 2020 at 12:17 PM George Neuner  wrote:

>
>
> On 9/13/2020 3:55 AM, Nate Griswold wrote:
>
>
> I am making an app that basically spawns two racket places and i want to
> be able to communicate with them from c code.
>
> Will gc happen in the two racket places if i don't keep the main thread
> (the one that spawned the places) running?
>
>
> Exiting the main thread kills the process.  "dynamic"[1] places are (OS
> level) threads within the same process and they will die with it.
> [Technically the main thread is itself a place, but normally we don't use
> place  terminology when talking about the main thread unless there are
> other places involved.]
>
> I was thinking about whether i should keep the main thread running and
> block on a stream read, sending it messages, or if i can only call into the
> main thread when i need something using racket/chezscheme apis. I guess it
> would be simpler to just talk directly to the main thread when i need to,
> which is why i'm asking. Otherwise i'm thinking of just using zeromq on the
> main thread.
>
>
> You certainly can talk to any of the places individually ... but you do
> need the main thread to remain running (even if just waiting on some event)
> if you want dynamic places to continue running.
>
>
> Now "distributed"[2,3] places are separate processes - you can start them
> and they will continue running regardless of what happens to the process
> that spawned them.
>
> Nate
>
>
> Hope this helps,
> George
>
> [1]  https://docs.racket-lang.org/reference/places.html
> [2]  https://docs.racket-lang.org/distributed-places/index.html
> [3]  https://pkgd.racket-lang.org/pkgn/search?q=loci
>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPome2k7ubSHk35tSmy-NaQwafm5AbW-h1H-pjqO963Aug%40mail.gmail.com.


[racket-users] question about places and main thread gc

2020-09-13 Thread Nate Griswold
Hi.

I am making an app that basically spawns two racket places and i want to be
able to communicate with them from c code.

Will gc happen in the two racket places if i don't keep the main thread
(the one that spawned the places) running? I was thinking about whether i
should keep the main thread running and block on a stream read, sending it
messages, or if i can only call into the main thread when i need something
using racket/chezscheme apis. I guess it would be simpler to just talk
directly to the main thread when i need to, which is why i'm asking.
Otherwise i'm thinking of just using zeromq on the main thread.

Thanks

Nate

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPqAWGLrrxY%3D9ZdAkud5mZyiWjyg3Sh%3DpwVicCw8Kn7%3DLQ%40mail.gmail.com.


Re: [racket-users] Recommended workaround still the same?

2020-08-02 Thread Nate Griswold
Thanks

Nate


On Sun, Aug 2, 2020 at 3:50 PM Sam Tobin-Hochstadt 
wrote:

> Yes, I think that's still the best approach.
>
> Sam
>
> On Sun, Aug 2, 2020 at 4:47 PM Nate Griswold 
> wrote:
> >
> > Hello. Ran into some problems with typed racket and define-cstruct when
> adding typed racket layer on top of my ffi bindings.
> >
> > Is this (https://github.com/racket/typed-racket/issues/766) still the
> recommended way of working around the issue?
> >
> > Nate
> >
> > --
> > 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.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAM-xLPoRnfw%3DEwLQjq2Qwqhc56Mx5bZ7wyeaXWD1GWeN3mwG5w%40mail.gmail.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPoW9%3Dgq%3DOtEGDe%3D_YAr%2BYq6AZ2esQKZWoQzS8dB4n5avg%40mail.gmail.com.


[racket-users] Recommended workaround still the same?

2020-08-02 Thread Nate Griswold
Hello. Ran into some problems with typed racket and define-cstruct when
adding typed racket layer on top of my ffi bindings.

Is this (https://github.com/racket/typed-racket/issues/766) still the
recommended way of working around the issue?

Nate

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPoRnfw%3DEwLQjq2Qwqhc56Mx5bZ7wyeaXWD1GWeN3mwG5w%40mail.gmail.com.


Re: [racket-users] Re: stuck on a type problem

2020-07-25 Thread Nate Griswold
Thank you for the detailed reply! Please see below...

On Sat, Jul 25, 2020 at 1:47 PM A Mauer-Oats  wrote:

> Problem 1:
>
> > But note i can't just type (λ (rng) (apply make-character rng)) into the
> REPL,
>
> If you're using Typed Racket, you probably want type signatures in your
> lambdas as well.
> In this case, you need to specify the type of `rng` (at least):
>
> ```
> (λ ([rng : (List Integer Integer)]) (apply make-character rng))
> ```
>

Thanks this makes sense.


> Problem 2:
>
> ; readline-input:8:40: Type Checker: type mismatch
> ;   expected: (-> Integer * Character)
> ;   given: (-> Integer Integer Character)
> ;   in: make-character
>
> I'm not sure about this one; it looks like you are currying _apply_...
> Don't you just want `(curry make-character)`?
> Like:
>
> ```
> (define blahh ((curry make-character) 10))
> ```
>
>
Actually, what i want is the behavior of the original blah function but
written simpler. So it's something that takes 2 ints and produces a
`Character` from the byte stream held by blah.

Problem 2b: understanding the complaint.
> The type checker is complaining that it wants something that takes in an
> arbitrary number of integers (0 or more), but you have given it something
> that takes in exactly two integers. Your inputs need to be a superset of
> the allowable inputs, not a subset.
>
> ; readline-input:8:40: Type Checker: type mismatch
> ;   expected: (-> Integer * Character)
> ;   given: (-> Integer Integer Character)
> ;   in: make-character
>
>
Well, ok. Hm. If i guess if i write this function
```
(: apply2 (All (a b) (-> (-> a a b) (List a a) b)))
(define (apply2 f arglist) (apply f arglist))
```

Then i can do what i was trying to do with:

```
(: f (-> (List Integer Integer) Character))
(define f ((curry (inst apply2 Integer Character)) make-character))
```

Which is definitely not that simple, so i still am left wondering if i can
simplify this all by putting the type system to work somehow... I was
thinking if the original function "blah" function could bend apply to its
will then i should be able to do something similar in a little different
way.

Nate


>
> Possibly helpful:
>
> > the discussion in typed racket reference "1.6 - Other Type Constructors"
> left me hanging a little bit on the function types
>
> If you haven't read the Typed Racket Guide, section 4.2 and maybe 4.3
> should be easier going than the reference.
>
> https://docs.racket-lang.org/ts-guide/types.html#%28part._.Function_.Types%29
>
>
This is ok, but there doesn't seem to be any discussion in the guide of the
different function types with stars or ellipses that I have found.


> On Saturday, July 25, 2020 at 12:52:43 PM UTC-5, Nate Griswold wrote:
>>
>> Hello. I am stuck on a probably simple type problem and was wondering if
>> someone could help:
>>
>> I'll just give the actual functions im using:
>>
>> ```
>> (struct Character ([bytes16 : Bytes]))
>> (define substr (make-bytes 128))
>> (: make-character (-> Integer Integer Character))
>> (define (make-character s e)
>>   (Character (subbytes substr (* 2 s) (* 2 e
>> ```
>>
>> What i want is a function like:
>>
>> ```
>> (: blah (-> (List Integer Integer) Character))
>> (define blah (λ (rng) (apply make-character rng)))
>> ```
>>
>> Which works.
>>
>> But note i can't just type (λ (rng) (apply make-character rng)) into the
>> REPL, because i get:
>>
>> ; readline-input:5:14: Type Checker: Bad arguments to function in `apply':
>> ; Domain: Integer Integer
>> ; Arguments:  Any
>> ;   in: (apply make-character rng)
>>
>> I think because i need the explicit (List Integer Integer) annotation to
>> unify with (Listof Integer)
>>
>> Anyway, i wanted to make my code simpler so i was wondering if i could
>> curry and partially apply. So i was digging around in the reference and
>> tried:
>>
>> ```
>> (: blah2 (-> (List Integer Integer) Character))
>> (define2 blah2 ((curry (inst apply Integer Character)) make-character)
>> ```
>>
>> But i get:
>>
>> ; readline-input:8:40: Type Checker: type mismatch
>> ;   expected: (-> Integer * Character)
>> ;   given: (-> Integer Integer Character)
>> ;   in: make-character
>>
>> Looking at the typed racket reference and the type of apply, thought the
>> star meant i could have many integers. Actually to be honest the discussion
>> in typed racket reference "1.6 - Other Type Constructors" left me hanging a
>> little bit on the function types, I am a 

[racket-users] stuck on a type problem

2020-07-25 Thread Nate Griswold
Hello. I am stuck on a probably simple type problem and was wondering if
someone could help:

I'll just give the actual functions im using:

```
(struct Character ([bytes16 : Bytes]))
(define substr (make-bytes 128))
(: make-character (-> Integer Integer Character))
(define (make-character s e)
  (Character (subbytes substr (* 2 s) (* 2 e
```

What i want is a function like:

```
(: blah (-> (List Integer Integer) Character))
(define blah (λ (rng) (apply make-character rng)))
```

Which works.

But note i can't just type (λ (rng) (apply make-character rng)) into the
REPL, because i get:

; readline-input:5:14: Type Checker: Bad arguments to function in `apply':
; Domain: Integer Integer
; Arguments:  Any
;   in: (apply make-character rng)

I think because i need the explicit (List Integer Integer) annotation to
unify with (Listof Integer)

Anyway, i wanted to make my code simpler so i was wondering if i could
curry and partially apply. So i was digging around in the reference and
tried:

```
(: blah2 (-> (List Integer Integer) Character))
(define2 blah2 ((curry (inst apply Integer Character)) make-character)
```

But i get:

; readline-input:8:40: Type Checker: type mismatch
;   expected: (-> Integer * Character)
;   given: (-> Integer Integer Character)
;   in: make-character

Looking at the typed racket reference and the type of apply, thought the
star meant i could have many integers. Actually to be honest the discussion
in typed racket reference "1.6 - Other Type Constructors" left me hanging a
little bit on the function types, I am a pretty green on working with
racket types and types in general. I thought this would unify but i guess i
am completely wrong. Does anyone know what i am doing wrong exactly or what
a very abbreviated form for what i want (behavior of blah) is?

Sorry if this is basic i am a little lost on it as you can probably tell.

Thank you

Nate

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPquALj6fqfxMhBuq402AAd4CNUCnxx2BvY0sQ2L4QOwog%40mail.gmail.com.


Re: [racket-users] catalog not working?

2020-07-24 Thread Nate Griswold
Although there was a stack trace i never investigated, it was in opening
the http connection

The only file i had modified was system etc/config, to search libraries in
my /opt/local on my mac

griswold@computer Racket % raco pkg install blah
Resolving "blah" via https://download.racket-lang.org/releases/7.7/catalog/
invalid memory reference.  Some debugging context lost
  context...:
   condition->exn
   do-raise
   dynamic-wind
   winder-dummy
   .../openssl/mzssl.rkt:1469:0: wrap-ports
   call-in-empty-metacontinuation-frame
   winder-dummy
   .../private/arrow-val-first.rkt:489:18
   .../net/http-client.rkt:67:0: http-conn-open!
   .../net/http-client.rkt:274:0: http-conn-open
   call-with-values
   .../private/arrow-val-first.rkt:555:3
   .../net/url.rkt:201:0: http://getpost-impure-port
   .../net/url.rkt:308:2: redirection-loop
   call-with-values
   .../private/arrow-val-first.rkt:555:3

Nate


On Fri, Jul 24, 2020 at 12:57 PM Nate Griswold 
wrote:

> Just FYI this was a local install/config issue
>
> Nate
>
>
> On Fri, Jul 24, 2020 at 12:14 AM Nathaniel Griswold <
> nategrisw...@gmail.com> wrote:
>
>> Oh, hm ok I was having a memory access crash in raco I assumed some
>> causation.. I’ll debug tomorrow
>>
>> On Jul 23, 2020, at 10:14 PM, Sorawee Porncharoenwase <
>> sorawee.pw...@gmail.com> wrote:
>>
>> 
>> Though, considering that there are so many people who are misled that the
>> catalog is down (my past self included), it might be better if that page
>> displays some useful information rather than a 404.
>>
>> On Thu, Jul 23, 2020 at 8:12 PM Sorawee Porncharoenwase <
>> sorawee.pw...@gmail.com> wrote:
>>
>>> The catalog is functional. That path is simply not served. See also:
>>>
>>> From: Matthew Flatt 
>>> Date: Thu, Feb 27, 2020 at 3:00 PM
>>> Subject: Re: [racket-users] download catalog down?
>>> To: Tom Gillespie 
>>> Cc: Racket Users 
>>>
>>> That path isn't served, but something like
>>>
>>>   https://download.racket-lang.org/releases/7.6/catalog/pkg/racket-lib
>>>
>>> or
>>>
>>>   https://download.racket-lang.org/releases/7.6/catalog/pkgs
>>>
>>> should work (and does work for me).
>>>
>>>
>>> On Thu, Jul 23, 2020 at 7:50 PM Nate Griswold 
>>> wrote:
>>>
>>>> My raco pkg install is crashing and manual navigation to the package
>>>> catalog looks broken
>>>>
>>>> https://download.racket-lang.org/releases/7.7/catalog/
>>>>
>>>> 
>>>>
>>>>
>>>> Nate
>>>>
>>>> --
>>>> 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.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/racket-users/CAM-xLPpZ06bnkiyUuQipqupoaA-odsmGMuakWp02WqRDbRUAbA%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/racket-users/CAM-xLPpZ06bnkiyUuQipqupoaA-odsmGMuakWp02WqRDbRUAbA%40mail.gmail.com?utm_medium=email_source=footer>
>>>> .
>>>>
>>>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPrgac_R533OzrjUSwwrTdCH0M8WOJP%3DPUgf0marRvh_ZQ%40mail.gmail.com.


Re: [racket-users] catalog not working?

2020-07-24 Thread Nate Griswold
Just FYI this was a local install/config issue

Nate


On Fri, Jul 24, 2020 at 12:14 AM Nathaniel Griswold 
wrote:

> Oh, hm ok I was having a memory access crash in raco I assumed some
> causation.. I’ll debug tomorrow
>
> On Jul 23, 2020, at 10:14 PM, Sorawee Porncharoenwase <
> sorawee.pw...@gmail.com> wrote:
>
> 
> Though, considering that there are so many people who are misled that the
> catalog is down (my past self included), it might be better if that page
> displays some useful information rather than a 404.
>
> On Thu, Jul 23, 2020 at 8:12 PM Sorawee Porncharoenwase <
> sorawee.pw...@gmail.com> wrote:
>
>> The catalog is functional. That path is simply not served. See also:
>>
>> From: Matthew Flatt 
>> Date: Thu, Feb 27, 2020 at 3:00 PM
>> Subject: Re: [racket-users] download catalog down?
>> To: Tom Gillespie 
>> Cc: Racket Users 
>>
>> That path isn't served, but something like
>>
>>   https://download.racket-lang.org/releases/7.6/catalog/pkg/racket-lib
>>
>> or
>>
>>   https://download.racket-lang.org/releases/7.6/catalog/pkgs
>>
>> should work (and does work for me).
>>
>>
>> On Thu, Jul 23, 2020 at 7:50 PM Nate Griswold 
>> wrote:
>>
>>> My raco pkg install is crashing and manual navigation to the package
>>> catalog looks broken
>>>
>>> https://download.racket-lang.org/releases/7.7/catalog/
>>>
>>> 
>>>
>>>
>>> Nate
>>>
>>> --
>>> 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.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/racket-users/CAM-xLPpZ06bnkiyUuQipqupoaA-odsmGMuakWp02WqRDbRUAbA%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/racket-users/CAM-xLPpZ06bnkiyUuQipqupoaA-odsmGMuakWp02WqRDbRUAbA%40mail.gmail.com?utm_medium=email_source=footer>
>>> .
>>>
>>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPr6bnBD%3DN%3Dd2in%3DNbawjtuy8XfLsYD0PcEuZ0wrN%2BMfAA%40mail.gmail.com.


[racket-users] catalog not working?

2020-07-23 Thread Nate Griswold
My raco pkg install is crashing and manual navigation to the package
catalog looks broken

https://download.racket-lang.org/releases/7.7/catalog/

[image: image.png]

Nate

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPpZ06bnkiyUuQipqupoaA-odsmGMuakWp02WqRDbRUAbA%40mail.gmail.com.


Re: [racket-users] Re: Combining generators and typed racket

2020-07-22 Thread Nate Griswold
Also can you think of a better way to do this than my implementation of
iterate? The use case is putting it in a for loop along with a break or a
finite list.

Nate


On Wed, Jul 22, 2020 at 2:22 PM Nate Griswold 
wrote:

> Ok, thanks for the reply.
>
> I was trying to use this function:
>
> (define (iterate f)
>   (yield (f))
>   (iterate f))
>
> But it seems the only thing i can do is have a separate (calling it
> "-untyped.rkt") module and putting anything that requires iterate in there.
>
> Are there any papers that would be helpful in trying to address this
> implementation-wise?
>
> Nate
>
>
> On Wed, Jul 22, 2020 at 1:56 PM Sam Tobin-Hochstadt 
> wrote:
>
>> Currently, neither `racket/stream` nor `racket/generator` are
>> supported by Typed Racket, unfortunately.
>>
>> Sam
>>
>> On Wed, Jul 22, 2020 at 12:15 AM Nate Griswold 
>> wrote:
>> >
>> > Actually, is there any way at all to use lazy lists of things (streams
>> or generators) in typed racket?
>> >
>> > Nate
>> >
>> >
>> > On Tue, Jul 21, 2020 at 8:45 PM Nate Griswold 
>> wrote:
>> >>
>> >> Do generators and typed racket work together well? It seems (yield)
>> doesn't have a type and i couldn't get my module to work.
>> >>
>> >> Is there a way to make some procedure untyped in the middle of a typed
>> file? Is it just best to break these things into separate files?
>> >>
>> >> Thank you
>> >>
>> >> Nate
>> >
>> > --
>> > 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.
>> > To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/CAM-xLPo_c3LzL81Qv6bA2zzJMhQftQ46JR%3DWyZdSJjPJ9rYM5Q%40mail.gmail.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPqs-dA%2Bk%3DZcWPsOACjpw_MaQyPZJz_1mrA1%2BCGLqRt28g%40mail.gmail.com.


Re: [racket-users] Re: Combining generators and typed racket

2020-07-22 Thread Nate Griswold
Ok, thanks for the reply.

I was trying to use this function:

(define (iterate f)
  (yield (f))
  (iterate f))

But it seems the only thing i can do is have a separate (calling it
"-untyped.rkt") module and putting anything that requires iterate in there.

Are there any papers that would be helpful in trying to address this
implementation-wise?

Nate


On Wed, Jul 22, 2020 at 1:56 PM Sam Tobin-Hochstadt 
wrote:

> Currently, neither `racket/stream` nor `racket/generator` are
> supported by Typed Racket, unfortunately.
>
> Sam
>
> On Wed, Jul 22, 2020 at 12:15 AM Nate Griswold 
> wrote:
> >
> > Actually, is there any way at all to use lazy lists of things (streams
> or generators) in typed racket?
> >
> > Nate
> >
> >
> > On Tue, Jul 21, 2020 at 8:45 PM Nate Griswold 
> wrote:
> >>
> >> Do generators and typed racket work together well? It seems (yield)
> doesn't have a type and i couldn't get my module to work.
> >>
> >> Is there a way to make some procedure untyped in the middle of a typed
> file? Is it just best to break these things into separate files?
> >>
> >> Thank you
> >>
> >> Nate
> >
> > --
> > 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.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAM-xLPo_c3LzL81Qv6bA2zzJMhQftQ46JR%3DWyZdSJjPJ9rYM5Q%40mail.gmail.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPrAR97XeG1rcmx5rD4mzwYCRUeZgfyY63VxMBWWfi5oQQ%40mail.gmail.com.


[racket-users] Re: Combining generators and typed racket

2020-07-21 Thread Nate Griswold
Actually, is there any way at all to use lazy lists of things (streams or
generators) in typed racket?

Nate


On Tue, Jul 21, 2020 at 8:45 PM Nate Griswold 
wrote:

> Do generators and typed racket work together well? It seems (yield)
> doesn't have a type and i couldn't get my module to work.
>
> Is there a way to make some procedure untyped in the middle of a typed
> file? Is it just best to break these things into separate files?
>
> Thank you
>
> Nate
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPo_c3LzL81Qv6bA2zzJMhQftQ46JR%3DWyZdSJjPJ9rYM5Q%40mail.gmail.com.


[racket-users] Combining generators and typed racket

2020-07-21 Thread Nate Griswold
Do generators and typed racket work together well? It seems (yield) doesn't
have a type and i couldn't get my module to work.

Is there a way to make some procedure untyped in the middle of a typed
file? Is it just best to break these things into separate files?

Thank you

Nate

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPoKYybMA755L-qcO5v4-Y4d1kOvJ1yOF28rg_tQm%3Dkhiw%40mail.gmail.com.


Re: [racket-users] Embedded racket (cs) question

2020-07-14 Thread Nate Griswold
Great, thanks for all of that digging. Ya, i think i will go the
non-declare_modules, non-ctool route for now as i think this fits my
use-case pretty well. I want to allow access to the full racket library for
racket code that changes often.

Nate


On Mon, Jul 13, 2020 at 8:32 PM Matthew Flatt  wrote:

> Thanks for the example! I did not guess correctly about your mixture of
> embedded modules and `dynamic-require`.
>
> The short answer is that you should either embed modules or reference
> them through an external paths like "/Applications/Racket
> v7.7/collects", but not both. Otherwise, the two worlds collide in
> confusing ways, in this case along the lines Sam suggested.
>
>
> Longer answer: When you embed a module, it pulls along a copy of
> anything that module depends on. Your "test.rkt" pulls along
> `racket/base`, which pulls along `racket/private/promise`, which
> defines `force` and the promise datatype. But it doesn't
> `racket/promise`, which defines `delay/sync`, and that leads to a
> mismatch.
>
>
> Very long answer: When `server` starts, there are two possible
> `racket/private/promise`s available: the emebded copy and the one in
> "/Applications/Racket v7.7/collects". As an artifact of the way that
> `racket/promise` references `racket/private/promise`, the
> `racket/promise` in "/Applications/Racket v7.7/collects" will always
> refer to the `racket/private/promise` there. And so `delay/sync` as
> used in `setup/private/dirs` will refer to the promise datatype there.
> But the `force` used in `setup/private/dirs` goes through `racket/base`
> and ends up referring the the embedded `racket/private/promise`, which
> has its own promise datatype; since `force` doesn't recognize the
> result of `delay/sync` as a promise, it doesn't force the (othe rkind
> of) promise, and it instead just returns it. Finally, `planet/config`
> is unhappy to get back a promise, because it expects a path.
>
>
> If you expect a full "collects" directory and more to be around at run
> time, then there's no reason to embed code, and just use
>
>  racket_dynamic_require(Sstring("test.rkt"), Sfalse);
>
> to load the module. But if you want to embed everything, then avoid
> `dynamic-require` or use `++lib` or `define-module-path-index` to carry
> along the dynamically required modules.
>
>
> Matthew
>
> At Mon, 13 Jul 2020 15:20:18 -0500, Nate Griswold wrote:
> > I put up a repo with the bug at https://github.com/nwg/racket-expo
> >
> > The stack trace is this:
> >
> > build-path: contract violation
> >   expected: (or/c path-string? path-for-some-system? 'up 'same)
> >   given: #
> >   context...:
> >do-raise-argument-error
> >loop
> >build
> >proc
> >call-in-empty-metacontinuation-frame
> >call-with-module-prompt
> >body of "/Applications/Racket v7.7/collects/planet/config.rkt"
> >temp35_0
> >for-loop
> >run-module-instance!
> >for-loop
> >[repeats 1 more time]
> >run-module-instance!
> >for-loop
> >[repeats 1 more time]
> >run-module-instance!
> >
> > Nate
> >
> >
> > On Mon, Jul 13, 2020 at 1:03 PM Ryan Culpepper 
> > wrote:
> >
> > > I don't know if it helps, but config:installation-name is a promise
> > > defined by setup/private/dirs.
> > >
> > > Ryan
> > >
> > >
> > > On Mon, Jul 13, 2020 at 7:23 PM Matthew Flatt 
> wrote:
> > >
> > >> I'm not sure how it could be in `dynamic-require` itself, as opposed
> to
> > >> a library that is loaded by `dynamic-require`, but it sounds like a
> bug
> > >> at some level. Can you provide a small example?
> > >>
> > >> At Mon, 13 Jul 2020 11:03:41 -0500, Nate Griswold wrote:
> > >> > Sam, thanks
> > >> >
> > >> > To be clear, this crash happened DURING a dynamic-require and
> judging by
> > >> > the stack trace looked to be part of the dynamic-require machinery
> (and
> > >> > this seems to depend on the installation name).
> > >> >
> > >> > I actually wasn't depending on anything but racket/base, so i don't
> > >> believe
> > >> > anything i was using was causing a separate dependency on promise.
> > >> >
> > >> > Nate
> > >> >
> > >> >
> > >> > On Mon, Jul 13, 2020 at 9:32 AM Sam Tobin-Hochstadt <
> > >> sa...@cs.indiana.edu>
> > >> > wrote

Re: [racket-users] Embedded racket (cs) question

2020-07-13 Thread Nate Griswold
I put up a repo with the bug at https://github.com/nwg/racket-expo

The stack trace is this:

build-path: contract violation
  expected: (or/c path-string? path-for-some-system? 'up 'same)
  given: #
  context...:
   do-raise-argument-error
   loop
   build
   proc
   call-in-empty-metacontinuation-frame
   call-with-module-prompt
   body of "/Applications/Racket v7.7/collects/planet/config.rkt"
   temp35_0
   for-loop
   run-module-instance!
   for-loop
   [repeats 1 more time]
   run-module-instance!
   for-loop
   [repeats 1 more time]
   run-module-instance!

Nate


On Mon, Jul 13, 2020 at 1:03 PM Ryan Culpepper 
wrote:

> I don't know if it helps, but config:installation-name is a promise
> defined by setup/private/dirs.
>
> Ryan
>
>
> On Mon, Jul 13, 2020 at 7:23 PM Matthew Flatt  wrote:
>
>> I'm not sure how it could be in `dynamic-require` itself, as opposed to
>> a library that is loaded by `dynamic-require`, but it sounds like a bug
>> at some level. Can you provide a small example?
>>
>> At Mon, 13 Jul 2020 11:03:41 -0500, Nate Griswold wrote:
>> > Sam, thanks
>> >
>> > To be clear, this crash happened DURING a dynamic-require and judging by
>> > the stack trace looked to be part of the dynamic-require machinery (and
>> > this seems to depend on the installation name).
>> >
>> > I actually wasn't depending on anything but racket/base, so i don't
>> believe
>> > anything i was using was causing a separate dependency on promise.
>> >
>> > Nate
>> >
>> >
>> > On Mon, Jul 13, 2020 at 9:32 AM Sam Tobin-Hochstadt <
>> sa...@cs.indiana.edu>
>> > wrote:
>> >
>> > > My guess, not having looked further than your email, is that when you
>> > > don't include racket/promise, something is supplying a promise to
>> something
>> > > else but there are two different instantiations of the promise
>> library,
>> > > causing the force call from one not to recognize the promise from the
>> > > other. Then force just becomes the identity function, and passes
>> through a
>> > > promise to somewhere that isn't expecting one.
>> > >
>> > > Is it possible that some library you're using features promises?
>> > > Alternatively, it might be that the embedding code needs an explicit
>> > > dependency on promises.
>> > >
>> > > Sam
>> > >
>> > > On Mon, Jul 13, 2020, 10:18 AM Nate Griswold 
>> > > wrote:
>> > >
>> > >> Hello.
>> > >>
>> > >> I noticed something and was wondering what the list thinks:
>> > >>
>> > >> I am using an embedded racket Ics) and i noticed that if i embed a
>> file
>> > >> and don't include any libraries (for a very bare bones c file) i have
>> > >> problems with a crash on a promise on any dynamic-require:
>> > >>
>> > >> build-path: contract violation
>> > >>   expected: (or/c path-string? path-for-some-system? 'up 'same)
>> > >>   given: #
>> > >>
>> > >> but if i do a (require racket/promise) in my rkt argument to
>> --c-mods OR
>> > >> if i do a ++lib racket/promise i get no crash.
>> > >>
>> > >> So is this expected behavior? Should racket/promise always be
>> included or
>> > >> no? And what exactly is going on under the hood here?
>> > >>
>> > >> Nate
>> > >>
>> > >> --
>> > >> 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.
>> > >> To view this discussion on the web visit
>> > >>
>> >
>> https://groups.google.com/d/msgid/racket-users/CAM-xLPpg_0Ef8ByjS01Y1pKEeeFMVkF
>> > k3dvGcdpRaYo3ZqDb9A%40mail.gmail.com
>> > >>
>> > <
>> https://groups.google.com/d/msgid/racket-users/CAM-xLPpg_0Ef8ByjS01Y1pKEeeFMVk
>> > Fk3dvGcdpRaYo3ZqDb9A%
>> 40mail.gmail.com?utm_medium=email_source=footer>
>> > >> .
>> > >>
>> > >
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups
>> > "Racket Users" group.
>> > To unsubscribe from this grou

Re: [racket-users] How to extract

2020-07-13 Thread Nate Griswold
Awesome, thanks!

I actually just implemented it with the roundabout callback system, i think
i might try out your suggestion though.

Thanks for working on racket!

Nate


On Mon, Jul 13, 2020 at 12:20 PM Matthew Flatt  wrote:

> I see that there's not a good way right now, but here's a workaround
> that uses information about the current layout:
>
> A cpointer value is implemented as a Chez Scheme record with either 1
> field or 2 fields. There are 2 fields only when the cpointer has an
> offset as a result of `ptr-add`, so you can probably ignore that.
>
> To extract the first field, assume that a record has the same layout as
> a vector, so use `Svector_ref(p, 0)` to extra the field from the
> cpointer `p`.
>
> Then you can use `Sunsigned_value()` to convert that field value to a
> pointer-sized integer, then case.
>
> I might have some part of that wrong, but it should be close... Of
> course, there should be better support for record-field access and
> cpointer extraction, so I'll add to the API.
>
>
> At Mon, 13 Jul 2020 11:43:35 -0500, Nate Griswold wrote:
> > I had a question. In embedded racket, I am passing a _cpointer value back
> > to c code by way of racket_apply's return value.
> >
> > Looking over https://docs.racket-lang.org/inside/cs-values_types.html ,
> > there appears to be a group of functions associated with extracting
> values
> > from ptrs. I do not see one for a pointer ptr there.
> >
> > Is there a way to get at a returned _cpointer value from c code?
> >
> > Thanks
> >
> > Nate
> >
> > --
> > 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.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/racket-users/CAM-xLPrKGgAgii7BjyfvCs6i0BmbMp0
> > yoo09UoUF0nqVzX_CXQ%40mail.gmail.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPrQ8Qv66eFRMuorqO%2BwqzutnPQVgZ79sPNjxKAgnij7CA%40mail.gmail.com.


[racket-users] Re: How to extract

2020-07-13 Thread Nate Griswold
A bit more context:

I am using a communications library (zeromq) and i need to share a c
context object between c and racket for in-process communication.

I can either create it in c or create it in racket. The library i'm using
happens to create it in racket.

The only way i know of solving this problem is to create an init foreign
function in racket and pass in the _cpointer data and grab the c pointer
when my c function is called.

Is there any other way to solve this problem?

Nate


On Mon, Jul 13, 2020 at 11:43 AM Nate Griswold 
wrote:

> I had a question. In embedded racket, I am passing a _cpointer value back
> to c code by way of racket_apply's return value.
>
> Looking over https://docs.racket-lang.org/inside/cs-values_types.html ,
> there appears to be a group of functions associated with extracting values
> from ptrs. I do not see one for a pointer ptr there.
>
> Is there a way to get at a returned _cpointer value from c code?
>
> Thanks
>
> Nate
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPrxgiv_s0QvgT1YkHOKWeugC-py03_gHcirxuQSmYL%3Dcw%40mail.gmail.com.


[racket-users] How to extract

2020-07-13 Thread Nate Griswold
I had a question. In embedded racket, I am passing a _cpointer value back
to c code by way of racket_apply's return value.

Looking over https://docs.racket-lang.org/inside/cs-values_types.html ,
there appears to be a group of functions associated with extracting values
from ptrs. I do not see one for a pointer ptr there.

Is there a way to get at a returned _cpointer value from c code?

Thanks

Nate

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPrKGgAgii7BjyfvCs6i0BmbMp0yoo09UoUF0nqVzX_CXQ%40mail.gmail.com.


Re: [racket-users] Embedded racket (cs) question

2020-07-13 Thread Nate Griswold
Sam, thanks

To be clear, this crash happened DURING a dynamic-require and judging by
the stack trace looked to be part of the dynamic-require machinery (and
this seems to depend on the installation name).

I actually wasn't depending on anything but racket/base, so i don't believe
anything i was using was causing a separate dependency on promise.

Nate


On Mon, Jul 13, 2020 at 9:32 AM Sam Tobin-Hochstadt 
wrote:

> My guess, not having looked further than your email, is that when you
> don't include racket/promise, something is supplying a promise to something
> else but there are two different instantiations of the promise library,
> causing the force call from one not to recognize the promise from the
> other. Then force just becomes the identity function, and passes through a
> promise to somewhere that isn't expecting one.
>
> Is it possible that some library you're using features promises?
> Alternatively, it might be that the embedding code needs an explicit
> dependency on promises.
>
> Sam
>
> On Mon, Jul 13, 2020, 10:18 AM Nate Griswold 
> wrote:
>
>> Hello.
>>
>> I noticed something and was wondering what the list thinks:
>>
>> I am using an embedded racket Ics) and i noticed that if i embed a file
>> and don't include any libraries (for a very bare bones c file) i have
>> problems with a crash on a promise on any dynamic-require:
>>
>> build-path: contract violation
>>   expected: (or/c path-string? path-for-some-system? 'up 'same)
>>   given: #
>>
>> but if i do a (require racket/promise) in my rkt argument to --c-mods OR
>> if i do a ++lib racket/promise i get no crash.
>>
>> So is this expected behavior? Should racket/promise always be included or
>> no? And what exactly is going on under the hood here?
>>
>> Nate
>>
>> --
>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/CAM-xLPpg_0Ef8ByjS01Y1pKEeeFMVkFk3dvGcdpRaYo3ZqDb9A%40mail.gmail.com
>> <https://groups.google.com/d/msgid/racket-users/CAM-xLPpg_0Ef8ByjS01Y1pKEeeFMVkFk3dvGcdpRaYo3ZqDb9A%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPpaOSxvPEDYzmkAXdFg%2BLTMAH1mw57kJt7%3DCe6ipXmXDw%40mail.gmail.com.


[racket-users] Embedded racket (cs) question

2020-07-13 Thread Nate Griswold
Hello.

I noticed something and was wondering what the list thinks:

I am using an embedded racket Ics) and i noticed that if i embed a file and
don't include any libraries (for a very bare bones c file) i have problems
with a crash on a promise on any dynamic-require:

build-path: contract violation
  expected: (or/c path-string? path-for-some-system? 'up 'same)
  given: #

but if i do a (require racket/promise) in my rkt argument to --c-mods OR if
i do a ++lib racket/promise i get no crash.

So is this expected behavior? Should racket/promise always be included or
no? And what exactly is going on under the hood here?

Nate

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPpg_0Ef8ByjS01Y1pKEeeFMVkFk3dvGcdpRaYo3ZqDb9A%40mail.gmail.com.


Re: [racket-users] Recommended CS replacement for make-sized-byte-string

2020-07-12 Thread Nate Griswold
Yes, thank you

I ended up using make-bytes with the size and then doing a memcpy. I forgot
that i could use a byte string as the memcpy destination.

Nate


On Sun, Jul 12, 2020 at 11:56 AM Sam Tobin-Hochstadt 
wrote:

> Copying is probably the best option -- this is discussed some in the
> following readme:
>
> https://www.github.com/racket/racket/tree/master/racket%2Fsrc%2Fcs%2FREADME.txt
>
> Sam
>
> On Sun, Jul 12, 2020, 12:16 PM Nate Griswold 
> wrote:
>
>> Maybe i have been up too long, but what is the best replacement for
>> make-sized-byte-string in Racket CS? I am using a library that still calls
>> it and is failing on me.
>>
>> I don't mind just copying the whole thing. I could write a function to do
>> it i was just thinking there would be something there already...
>>
>> Thanks
>>
>> Nate
>>
>> --
>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/CAM-xLPrFbKkgR4nNb3qmzFaw%2BRReNr3z%3DiROqMof--x%3DeOjODA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/racket-users/CAM-xLPrFbKkgR4nNb3qmzFaw%2BRReNr3z%3DiROqMof--x%3DeOjODA%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPqiuifpd9ou%3D3ow6sXQJH0ZasgSshqNyL1Z_1T8mNt9-A%40mail.gmail.com.


[racket-users] Recommended CS replacement for make-sized-byte-string

2020-07-12 Thread Nate Griswold
Maybe i have been up too long, but what is the best replacement for
make-sized-byte-string in Racket CS? I am using a library that still calls
it and is failing on me.

I don't mind just copying the whole thing. I could write a function to do
it i was just thinking there would be something there already...

Thanks

Nate

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPrFbKkgR4nNb3qmzFaw%2BRReNr3z%3DiROqMof--x%3DeOjODA%40mail.gmail.com.


[racket-users] Re: racket_boot out of memory

2020-07-12 Thread Nate Griswold
I figured out what the issue was in my embedded racket app on mac os x
(with the misleading out of memory error). Chez was dying in an mmap in
segment.c that was asking for PROT_EXEC memory. The solution is either to
disable the hardened runtime in Xcode or to leave it on but check "Allow
Unsigned Executable Memory"
(com.apple.security.cs.allow-unsigned-executable-memory) in Target ->
Signing and Capabilities

Nate


On Sat, Jul 11, 2020 at 3:59 PM Nate Griswold 
wrote:

> Has anyone run into an out of memory exit when calling racket_boot on mac
> os x?
>
> Mine was working fine until i turned system integrity protection back on,
> now i can't seem to get it to work.
>
> Anyway, just wanted to check here before i dig further. Please lmk if you
> have run into this...
>
> Nate
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPqDmqx6dNFcFOAAm6kDcmAzAWPX0BJ6NZ8v%3D0CwygpK3A%40mail.gmail.com.


[racket-users] racket_boot out of memory

2020-07-11 Thread Nate Griswold
Has anyone run into an out of memory exit when calling racket_boot on mac
os x?

Mine was working fine until i turned system integrity protection back on,
now i can't seem to get it to work.

Anyway, just wanted to check here before i dig further. Please lmk if you
have run into this...

Nate

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPqAObJ5NUcQgGG0hG_S9dAfigXmmkAMSOyo-iF-gGehBw%40mail.gmail.com.


Re: [racket-users] Xcode, embedding Racket.framework

2020-06-26 Thread Nate Griswold
ok, added https://github.com/racket/racket/wiki/Embedding-Racket

Nate


On Thu, Jun 25, 2020 at 4:30 AM Stephen De Gabrielle <
spdegabrie...@gmail.com> wrote:

> This world be great content for the wiki
>
> Hi Nate,
> This would be great content for the racket wiki
> https://github.com/racket/racket/wiki
>
> You can post it yourself or I am happy to do it for you.
> https://github.com/racket/racket/wiki/_new
>
> Kind regards,
> Stephen
>
> On Wed, 24 Jun 2020 at 17:54, Nate Griswold 
> wrote:
>
>> Hello
>>
>> I recently went through the process of embedding the Racket.framework in
>> Xcode, and i just wanted to share the steps in case anyone else would like
>> to do this.
>>
>> Note the documentation says (
>> https://docs.racket-lang.org/inside/cs-embedding.html)
>>
>> "On Mac OS, besides "libracketcs.a" for static linking, a dynamic
>> library is provided by the "Racket" framework, which is typically
>> installed in "lib" sub-directory of the installation. Supply -framework
>> Racket to gcc when linking, along with -F and a path to the "lib"
>> directory. At run time, either "Racket.framework" must be moved to a
>> location in the standard framework search path, or your embedding
>> executable must provide a specific path to the framework (possibly an
>> executable-relative path using the Mach-O @executable_path prefix)."
>>
>> That sets the rpath search paths but the library binary still needs to
>> reference @rpath to make use of these search paths. Below we use
>> install_name_tool to fix up the binary to reference the @rpath directly.
>>
>> Note also that Xcode is hard coded to codesign in the Versions/A
>> subdirectory and hasn't added any support for signing other major versions,
>> so i link version A in the below steps. This step is only necessary if you
>> wish to sign the framework on copy.
>>
>> Note also for a proper framework structure, the framework should have an
>> Info.plist in Resources and a Versions/Current symlink. Top-level symlinks
>> directly in Racket.framework should reference only Versions/Current and
>> both Resources and the binary library (Racket) should be referenced. (see
>> https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/FrameworkAnatomy.html
>> )
>>
>> Note also i did all of this with racket cs, you would have to modify the
>> steps if you were using normal racket.
>>
>> All that said, here are the steps:
>>
>> Drag the framework into xcode
>> select copy if needed, ok
>> Click on project, General tab, "Frameworks, Libraries, and Embeddeed
>> Content"
>> Change do not embed to either embed or embed and sign
>> cd to your copied framework in your project
>> cd Versions
>> ln -s 7.7_CS Current
>> if "embed and sign" was chosen:
>>   ln -s 7.7_CS A (xcode is hard coded to sign the major version A, see
>> https://developer.apple.com/forums/thread/65963)
>> cp /path/to/Info.plist 7.7_CS/Resources
>> cd ..
>> rm -f Racket
>> ln -s Versions/Current/Racket
>> ln -s Versions/Current/Resources
>> install_name_tool -id @rpath/Racket.framework/Versions/7.7_CS/Racket
>> ./Racket
>> otool -L Racket (to verify)
>> Switch to Xcode, build and run
>>
>> Nate
>>
>> --
>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/CAM-xLPpC3Ona-zbV6r43dD_xjSmXa_eGGRLfFERuQ_tBgG%3D4HQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/racket-users/CAM-xLPpC3Ona-zbV6r43dD_xjSmXa_eGGRLfFERuQ_tBgG%3D4HQ%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
> --
> 
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPrU2q%2BjVe91NVX3SFeX8%3DFMV16TnmDT1GRP6ZO0XnAD1g%40mail.gmail.com.


[racket-users] Xcode, embedding Racket.framework

2020-06-24 Thread Nate Griswold
Hello

I recently went through the process of embedding the Racket.framework in
Xcode, and i just wanted to share the steps in case anyone else would like
to do this.

Note the documentation says (
https://docs.racket-lang.org/inside/cs-embedding.html)

"On Mac OS, besides "libracketcs.a" for static linking, a dynamic library
is provided by the "Racket" framework, which is typically installed in "lib"
sub-directory of the installation. Supply -framework Racket to gcc when
linking, along with -F and a path to the "lib" directory. At run time,
either "Racket.framework" must be moved to a location in the standard
framework search path, or your embedding executable must provide a specific
path to the framework (possibly an executable-relative path using the
Mach-O @executable_path prefix)."

That sets the rpath search paths but the library binary still needs to
reference @rpath to make use of these search paths. Below we use
install_name_tool to fix up the binary to reference the @rpath directly.

Note also that Xcode is hard coded to codesign in the Versions/A
subdirectory and hasn't added any support for signing other major versions,
so i link version A in the below steps. This step is only necessary if you
wish to sign the framework on copy.

Note also for a proper framework structure, the framework should have an
Info.plist in Resources and a Versions/Current symlink. Top-level symlinks
directly in Racket.framework should reference only Versions/Current and
both Resources and the binary library (Racket) should be referenced. (see
https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/FrameworkAnatomy.html
)

Note also i did all of this with racket cs, you would have to modify the
steps if you were using normal racket.

All that said, here are the steps:

Drag the framework into xcode
select copy if needed, ok
Click on project, General tab, "Frameworks, Libraries, and Embeddeed
Content"
Change do not embed to either embed or embed and sign
cd to your copied framework in your project
cd Versions
ln -s 7.7_CS Current
if "embed and sign" was chosen:
  ln -s 7.7_CS A (xcode is hard coded to sign the major version A, see
https://developer.apple.com/forums/thread/65963)
cp /path/to/Info.plist 7.7_CS/Resources
cd ..
rm -f Racket
ln -s Versions/Current/Racket
ln -s Versions/Current/Resources
install_name_tool -id @rpath/Racket.framework/Versions/7.7_CS/Racket
./Racket
otool -L Racket (to verify)
Switch to Xcode, build and run

Nate

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPpC3Ona-zbV6r43dD_xjSmXa_eGGRLfFERuQ_tBgG%3D4HQ%40mail.gmail.com.


Info.plist
Description: Binary data