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

2020-07-13 Thread Matthew Flatt
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:
> >> >
> >> > > 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: #
> >> 

Re: [racket-users] require and syntax-case

2020-07-13 Thread Ben Greenman
On 7/13/20, Roman Klochkov  wrote:
> I tried
> ```
> (define-syntax my-file
>   (make-require-transformer
>(lambda (stx)
>  (syntax-case stx ()
>[(_ path)
> (printf "Importing: ~a~n" #'path)
> (expand-import #'(file path))]
> (require (my-file "test.rkt"))
> ```
> with the same result: no errors in require, but no imports.
>
> So, it seems, that the only solution is datum->syntax. It works fine.

There is another way: syntax-local-introduce will remove the macro scope.

```
(define-syntax (req2 stx)
  (syntax-case stx ()
[(_ (x y)) (syntax-local-introduce #'(require (x y)))]))
```

-- 
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/CAFUu9R563Pr8TZkJVBjFYZjf5LcCWfEezdJ1uKjhErp3-zpzAg%40mail.gmail.com.


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 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%2BLTMA
>> > H1mw57kJt7%3DCe6ipXmXDw%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/20200713112340.24e%40sirmail.smtp.cs.utah.edu
>> .
>>
>

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

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

2020-07-13 Thread Ryan Culpepper
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 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%2BLTMA
> > H1mw57kJt7%3DCe6ipXmXDw%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/20200713112340.24e%40sirmail.smtp.cs.utah.edu
> .
>

-- 
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/CANy33q%3DBvUOi2%2BP4L4JxrbfJQxaWgbXNnP%3DV5z2yot3xR69frw%40mail.gmail.com.


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.


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

2020-07-13 Thread Matthew Flatt
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 
> 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
> >> 
>  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 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%2BLTMA
> H1mw57kJt7%3DCe6ipXmXDw%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/20200713112340.24e%40sirmail.smtp.cs.utah.edu.


Re: [racket-users] How to extract

2020-07-13 Thread Matthew Flatt
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/20200713112050.3cf%40sirmail.smtp.cs.utah.edu.


[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] Online Lisp Meetings

2020-07-13 Thread phoe
On 13.07.2020 14:26, Bonface M. K. wrote:
> I'm sure you may find
> those interesting and worthy candidates for your stream \o\o. Wdyt?

Ye. I think that's a good and useful topic to showcase! Please send
me a mail in private or poke me on Freenode - I'll gladly host that.

~phoe


-- 
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/7dc0aeed-71ea-a762-6a34-11bdc429826d%40teknik.io.


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

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


Re: [racket-users] Creating links to Racket docs for functions in user-scope packages

2020-07-13 Thread 'Joel Dueck' via Racket Users

On Monday, July 13, 2020 at 8:37:52 AM UTC-5, Matthew Flatt wrote:
>
> It might end up being about the same implementation effort to improve the
> error message or to make the function work on user-scope packages
>

That was my sense as well...I will try taking a look at this, maybe I can 
contribute.

-- 
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/79eb227e-7fb8-40af-82ea-fee0d5bc2617o%40googlegroups.com.


[racket-users] Online Lisp Meetings

2020-07-13 Thread p...@teknik.io
Hey, everyone,

I am organizing a series of Online Lisp Meets that started after this 
year's electronic European Lisp Symposium. The mailing list is at 
https://mailman.common-lisp.net/pipermail/online-lisp-meets/ and the talk 
videos so far have been posted at 
https://www.youtube.com/channel/UCymtXMj1M7cKiV9TKLoTtEg

So far the talks have been mostly utilizing Common Lisp for the practical 
parts of their talks (I guess because I am a CL programmer and most of the 
Lisp people I know are CL people), but obviously that isn't the idea behind 
ELS, nor I want that to be the idea behind this post-ELS online series. 
I've wanted the online meetings to be a meeting grounds for people doing 
more Lisp dialects than just CL, and the people who've been joining the 
livestreams on Twitch so far share the same wishes.

I've decided to have a go at this meeting series to provide a place where 
the wider Lisp community can meet and talk and where the ideas can mix and 
breed, and so far it's been well-received on #lisp on Freenode. It's just 
that it's comfortable to post stuff there because it's my online home, much 
unlike e.g. here in the Racket world - hence someone on #racket on Freenode 
has advised me to post the announcement here.

So, since I'm already doing a wall of text - please let me know if you're 
working on something related to Lisp in any any way and you consider it 
interesting enough to record a video about it, anywhere from a few minutes 
to an hour. Please feel free to throw your ideas and videos at me, and I'll 
be happy to host them on Twitch for the broader Lisp community to see while 
Twitch chat is available for questions and comments - this form has worked 
well for this year's ELS and it has worked well for the online Lisp 
meetings which happened so far.

Thanks a lot,
Michał "phoe" Herda

-- 
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/5c36d5df-4cd8-42a3-862b-1db710157db0o%40googlegroups.com.


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

2020-07-13 Thread Sam Tobin-Hochstadt
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
> 
> .
>

-- 
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/CAK%3DHD%2Bb2oNwt5NmekZwJdSyENH0AczxAr%3DCUz8hYBjqykBtxmw%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] Creating links to Racket docs for functions in user-scope packages

2020-07-13 Thread Matthew Flatt
It's currently not intended to work for packages installed in user
scope --- only for packages in the main installation --- although
probably it shouldn't report a path error for a user-scope package.

I'm not sure how difficult it would be to make redirection work on a
user-scope package's documentation. The function doesn't "just work"
for user-scope, because the location where documentation is rendered is
different for user-scope packages and installation-scope packages. It
might end up being about the same implementation effort to improve the
error message or to make the function work on user-scope packages,
though.

At Sun, 12 Jul 2020 15:16:37 -0700 (PDT), "'Joel Dueck' via Racket Users" wrote:
> Trying to generate URLs for linking into the Racket docs. I get the error 
> below, but only when the package/identifier combo in question are installed 
> in user scope, and only when using the `#:external-root-url` keyword 
> argument:
> 
> > (define x (xref-binding->definition-tag (load-collections-xref) 
> '(deta/query lookup) 0))
> > x
> '(def ((lib "deta/query.rkt") lookup))
> 
> ;; works good:
> > (xref-tag->path+anchor (load-collections-xref) x)
> #
> "(def._((lib._deta/query..rkt)._lookup))"
> 
> > (xref-tag->path+anchor (load-collections-xref) x #:external-root-url 
> "http://docs.racket-lang.org/;)
> . . ../../../../../../Applications/Racket 
> v7.7/collects/racket/private/kw.rkt:1393:47: path-element->string: contract 
> violation
> expected: path?
> given: 'up
> 
> Is this a bug? Or is there a way to make this work for user-scope packages 
> as well?

-- 
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/20200713073746.2ce%40sirmail.smtp.cs.utah.edu.


Re: [racket-users] Online Lisp Meetings

2020-07-13 Thread Bonface M. K.
"p...@teknik.io"  writes:

> Hey, everyone,
>
> I am organizing a series of Online Lisp Meets that started after this year's 
> electronic European Lisp Symposium. The mailing
> list is at https://mailman.common-lisp.net/pipermail/online-lisp-meets/ and 
> the talk videos so far have been posted at 
> https://www.youtube.com/channel/UCymtXMj1M7cKiV9TKLoTtEg
>
> So far the talks have been mostly utilizing Common Lisp for the practical 
> parts of their talks (I guess because I am a CL
> programmer and most of the Lisp people I know are CL people), but obviously 
> that isn't the idea behind ELS, nor I want that to
> be the idea behind this post-ELS online series. I've wanted the online 
> meetings to be a meeting grounds for people doing more
> Lisp dialects than just CL, and the people who've been joining the 
> livestreams on Twitch so far share the same wishes.
>
> I've decided to have a go at this meeting series to provide a place where the 
> wider Lisp community can meet and talk and where
> the ideas can mix and breed, and so far it's been well-received on #lisp on 
> Freenode. It's just that it's comfortable to post
> stuff there because it's my online home, much unlike e.g. here in the Racket 
> world - hence someone on #racket on Freenode has
> advised me to post the announcement here.
>
> So, since I'm already doing a wall of text - please let me know if you're 
> working on something related to Lisp in any any way
> and you consider it interesting enough to record a video about it, anywhere 
> from a few minutes to an hour. Please feel free to
> throw your ideas and videos at me, and I'll be happy to host them on Twitch 
> for the broader Lisp community to see while Twitch
> chat is available for questions and comments - this form has worked well for 
> this year's ELS and it has worked well for the
> online Lisp meetings which happened so far.
>

Thanks for sharing! I've been working on
https://github.com/BonfaceKilz/feedanalyser/ which is a feed aggregator
with the end goal of it being plugged in as part of a website or other
form of feed. There's also: https://gitlab.inria.fr/guix-hpc/guix-past
which is a drive by Ludo(the creator of Guix) and a bunch of people in
that eco-system to make available old no-longer-maintained packages.
This gives scientists the ability to re-use old packages when they want
to reproduce papers whose code no longer uses the latest libs of
packages. It's in GUILE which is a scheme dialect. I'm sure you may find
those interesting and worthy candidates for your stream \o\o. Wdyt?

Other than that, it'd be great to have meets that go beyond CL. I got
my start in Guile (because of GUIX), and eventually got my feet wet in
Racket :)


> Thanks a lot,
> Michał "phoe" Herda
>
> --
> 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/5c36d5df-4cd8-42a3-862b-1db710157db0o%40googlegroups.com.

-- 
Bonface M. K. (https://www.bonfacemunyoki.com)
One Divine Emacs To Rule Them All
GPG key = D4F09EB110177E03C28E2FE1F5BBAE1E0392253F

-- 
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/86r1tfha8i.fsf%40gmail.com.


Re: [racket-users] require and syntax-case

2020-07-13 Thread Roman Klochkov
I tried
```
(define-syntax my-file
  (make-require-transformer
   (lambda (stx)
 (syntax-case stx ()
   [(_ path)
(printf "Importing: ~a~n" #'path)
(expand-import #'(file path))]
(require (my-file "test.rkt"))
```
with the same result: no errors in require, but no imports.

So, it seems, that the only solution is datum->syntax. It works fine.

понедельник, 13 июля 2020 г., 10:17:26 UTC+5 пользователь Michael MacLeod 
написал:
>
> The issue isn't actually with the `(_ (x y))` pattern---it's with the 
> `#'(require (x y))` template.
>
> When `require` is passed a module path like `(file "test1.rkt")`, it 
> introduces any identifiers [just `ok` in this case] with the same lexical 
> context of the module path itself[1].
>
> The issue is that the expansion of `req2` adds a macro introduction scope 
> to the `(file "test1.rkt")` syntax object. Since the module path has an 
> additional scope, `ok` will have an additional scope; it won't bind the 
> `ok` from test2.rkt, and we get an unbound identifier error.
>
> With `req1`, the parentheses around (file "test1.rkt") in the expanded 
> code come from the use site of the macro, so the `ok` identifier will have 
> the expected lexical context.
>
> With `req2`, the parentheses around (file "test1.rkt") in the expanded 
> code come from the macro itself, not from the use site of the macro. Notice 
> the difference: in `(require x)` the parentheses are "in the x", but in 
> #'(require (x y)) the parentheses are from the (#') template.
>
> You may be able to achieve your end goal using 
> make-require-transformer[2], which would probably end up being much nicer 
> than what I'm about to go into.
>
> Alternatively you could resort to using the unhygenic `datum->syntax` to 
> ensure that the resulting syntax object doesn't have the extra macro 
> introduction scope. I've added some checks before the template to ensure 
> that the forms passed to the macro are of the proper shape.
>
> ```
> (define-syntax (req2 stx)
>   (syntax-case stx ()
> [(_ (x y))
>  ; throw a "bad syntax" error if the
>  ; arguments are incorrect
>  (and (free-identifier=? #'x #'file)
> (string? (syntax-e #'y)))
>  #`(require
>  #,(datum->syntax
> ; create the syntax object (x y)
> ; using the lexical context of y
> #'y 
> (list #'x #'y)))]))
> ```
>
> You may want to use `syntax-parse` instead, which makes these sorts of 
> checks much simpler to write, and usually gives better error messages than 
> "bad syntax".
>
> ```
> (require (for-syntax racket/base syntax-parse))
> (define-syntax (req2 stx)
>   (syntax-parse stx
> [(_ ((~literal file) y:str))
>  #`(require #,(datum->syntax #'y (list #'file #'y)))]))
> ```
>
> ---
> [1] `module-path` part under the `require` section from 
> https://docs.racket-lang.org/reference/require.html?q=require#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29
> [2] 
> https://docs.racket-lang.org/reference/stxtrans.html?q=require%20transfo#%28def._%28%28lib._racket%2Frequire-transform..rkt%29._make-require-transformer%29%29
>
>
>
> On Sun, Jul 12, 2020 at 8:18 PM Roman Klochkov  > wrote:
>
>> I try to make a macro, that expands to the require form.
>>
>> I put in test1.rkt
>> ```
>> #lang racket/base
>> (provide ok)
>> (define ok 1)
>> ```
>>
>> I put in test.rkt
>> ```
>> #lang racket
>> (define-syntax (req1 stx)
>>   (syntax-case stx ()
>> [(_ x) #'(require x)]))
>>
>> (define-syntax (req2 stx)
>>   (syntax-case stx ()
>> [(_ (x y)) #'(require (x y))]))
>>
>> (req2 (file "test1.rkt"))
>> ok
>> ```
>>
>> When I run it, I have the error: ok: unbound identifier
>>
>> If I change `req2` to `require` or to `req1`, then it returns 1 as should.
>>
>> What's wrong with (_ (x y)) pattern ?
>>
>> -- 
>> 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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/af6dcad0-69ff-406f-8183-dc691d302a5eo%40googlegroups.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/e59254cd-7044-4bb1-a0de-75957c1558fao%40googlegroups.com.