Re: [racket-users] Questions about multiple Racket installations...

2021-04-14 Thread 'William J. Bowman' via Racket Users
I use this: https://github.com/takikawa/racket-dev-goodies

When I need to switch, I just change PLTHOME to the right directory.

--
William J. Bowman

On Wed, Apr 14, 2021 at 11:06:15AM -0700, Don Green wrote:
>  I have several versions of Racket installed. 
> Is there a way to switch between using one version and another? Example: 
> use Racket 8
> then switch back to using Racket 7.
> 
> If there is no point in going back to a previous version, is there merit in 
> removing older versions.
> Thanks.  Don.
> 
> -- 
> 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/fcf25a75-cfe3-4ece-a65b-df55592845ean%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/YHdnLNIuNC24DLNM%40williamjbowman.com.


[racket-users] Questions about multiple Racket installations...

2021-04-14 Thread Don Green
 I have several versions of Racket installed. 
Is there a way to switch between using one version and another? Example: 
use Racket 8
then switch back to using Racket 7.

If there is no point in going back to a previous version, is there merit in 
removing older versions.
Thanks.  Don.

-- 
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/fcf25a75-cfe3-4ece-a65b-df55592845ean%40googlegroups.com.


Re: [racket-users] Questions Regarding My First Program

2021-02-23 Thread 'John Clements' via Racket Users
I *always* use DrRacket… but I admit I may not understand the indenting part of 
your question. 

In DrRacket, when you hit the “tab” key, it should move the text on the line to 
the “correct” position, according to Racket’s indentation rules. Also, whenever 
you hit return, the cursor should be automatically indented to the appropriate 
column. Finally, you can highlight a block of text and hit “tab”, and it will 
all be re-indented.

Is this different from what you’re observing, or from what you’re expecting?

John Clements

> On Feb 23, 2021, at 4:05 PM, Sage Gerard  wrote:
> 
> I can't speak to DrRacket since I never use it, so I'll focus more on the 
> first question.
> 
> Functional programming typically deals with these considerations (among 
> others):
> 
>   • Write functions that return values purely in terms of arguments.
>   • Defer side-effects until you can't.
> A goal to make the program produce the same output given the same input, 
> every time.
> 
> One example would be to redefine `say` such that it doesn't immediately 
> print. Maybe just return the string you want said.
> 
> (define (say str)
>   (format "Chatbot: ~a\n" str))
> 
> (I'd personally use a struct representing a message, sender, etc. but that's 
> beside the point)
> 
> This change makes the function "pure" in that the same input returns the same 
> output, and there are no side-effects in doing so. But this creates a problem 
> where you need to "rope in" that value somewhere. How that happens depends on 
> the program. A program that reports download progress will handles 
> side-effects differently than a program that prints a report before stopping.
> 
> One approach is to update program state in the same (functional) way. If we 
> assume the chat history is a list, where the first element is the most recent 
> message, then this version of `say` adds a string to the chat.
> 
> (define (say chat-history str)
>   (cons (format "Chatbot: ~a\n" str) 
> chat-history))
> 
> I'd start with this kind of thinking until you get to the point where 
> side-effects are unavoidable. Since your program appears interactive, you can 
> still print in the loop. But think about what your program would be like if 
> you print ONLY in that loop.
> 
> Others can probably say more, but hopefully this helps you start.
> 
> On 2/23/21 5:59 PM, IF Karona wrote:
>> Hi everyone,
>> 
>> I am new here, and I have a couple of questions related to the code that 
>> follows this message.
>> 
>> 1. I want to learn functional programming. When it comes to solving the 
>> problem of making a simple chatbot such as this, is there an approach that 
>> is more consistent with functional programming?
>> 2. I would prefer to not have to use multiple spaces every time I want to 
>> indent. Does Dr. Racket have anything comparable to the tab functionality of 
>> other programs?
>> 
>> Thank you for letting me join your community!
>> 
>> Karona
>> 
>> ;example.rkt
>> 
>> #lang racket
>> 
>> (require racket/match)
>> 
>> (define (say str)
>> (printf "Chatbot: ~a\n" str))
>> 
>> (define (handle-input str)
>> (cond
>>   
>> [(regexp-match #px"(?i:Hello,* world!)" str)
>> (say "I would not know about the rest of the world, but I can 
>> hear \
>> you just fine.")]
>>   
>> [(regexp-match #px"(?i:I( am|'m) learning how to program in Racket,* 
>> world!)" str)
>> (say "Racket is a great language, and it is lovely that you are \
>> learning it, but does literally everyone need to know?")]
>> 
>> [(regexp-match #px".*,+\\s*world!" str)
>> (say "Did the whole world really need to hear that?")]
>>   
>> [else (say "Did you really just say something without addressing the 
>> \
>> world? I am so proud of you! :,)")]))
>> 
>> (let loop ()
>> (display "Input: ")
>> (define str (read-line (current-input-port) 'any))
>> (handle-input str)
>> (loop))
>> -- 
>> 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/2f107ab5-2efd-4c33-83f6-eb5751664cb6n%40googlegroups.com.
> --
> ~slg
> 
> 
> -- 
> 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/d3da9796-979d-cad9-36e5-91380939630c%40sagegerard.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.

Re: [racket-users] Questions Regarding My First Program

2021-02-23 Thread Sage Gerard
I can't speak to DrRacket since I never use it, so I'll focus more on the first 
question.

Functional programming typically deals with these considerations (among others):

- Write functions that return values purely in terms of arguments.
- Defer side-effects until you can't.

A goal to make the program produce the same output given the same input, every 
time.

One example would be to redefine `say` such that it doesn't immediately print. 
Maybe just return the string you want said.

(define (say str)
(format "Chatbot: ~a\n" str))

(I'd personally use a struct representing a message, sender, etc. but that's 
beside the point)

This change makes the function "pure" in that the same input returns the same 
output, and there are no side-effects in doing so. But this creates a problem 
where you need to "rope in" that value somewhere. How that happens depends on 
the program. A program that reports download progress will handles side-effects 
differently than a program that prints a report before stopping.

One approach is to update program state in the same (functional) way. If we 
assume the chat history is a list, where the first element is the most recent 
message, then this version of `say` adds a string to the chat.

(define (say chat-history str)
(cons (format "Chatbot: ~a\n" str)
chat-history))

I'd start with this kind of thinking until you get to the point where 
side-effects are unavoidable. Since your program appears interactive, you can 
still print in the loop. But think about what your program would be like if you 
print ONLY in that loop.

Others can probably say more, but hopefully this helps you start.

On 2/23/21 5:59 PM, IF Karona wrote:

> Hi everyone,
>
> I am new here, and I have a couple of questions related to the code that 
> follows this message.
>
> 1. I want to learn functional programming. When it comes to solving the 
> problem of making a simple chatbot such as this, is there an approach that is 
> more consistent with functional programming?
> 2. I would prefer to not have to use multiple spaces every time I want to 
> indent. Does Dr. Racket have anything comparable to the tab functionality of 
> other programs?
>
> Thank you for letting me join your community!
>
> Karona
>
> ;example.rkt
>
> #lang racket
>
> (require racket/match)
>
> (define (say str)
> (printf "Chatbot: ~a\n" str))
>
> (define (handle-input str)
> (cond
>
> [(regexp-match #px"(?i:Hello,* world!)" str)
> (say "I would not know about the rest of the world, but I can hear \
> you just fine.")]
>
> [(regexp-match #px"(?i:I( am|'m) learning how to program in Racket,* world!)" 
> str)
> (say "Racket is a great language, and it is lovely that you are \
> learning it, but does literally everyone need to know?")]
>
> [(regexp-match #px".*,+\\s*world!" str)
> (say "Did the whole world really need to hear that?")]
>
> [else (say "Did you really just say something without addressing the \
> world? I am so proud of you! :,)")]))
>
> (let loop ()
> (display "Input: ")
> (define str (read-line (current-input-port) 'any))
> (handle-input str)
> (loop))
> --
> 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/2f107ab5-2efd-4c33-83f6-eb5751664cb6n%40googlegroups.com](https://groups.google.com/d/msgid/racket-users/2f107ab5-2efd-4c33-83f6-eb5751664cb6n%40googlegroups.com?utm_medium=email_source=footer).

--
~slg

-- 
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/d3da9796-979d-cad9-36e5-91380939630c%40sagegerard.com.


[racket-users] Questions Regarding My First Program

2021-02-23 Thread IF Karona
Hi everyone,

I am new here, and I have a couple of questions related to the code that 
follows this message.

1. I want to learn functional programming. When it comes to solving the 
problem of making a simple chatbot such as this, is there an approach that 
is more consistent with functional programming?
2. I would prefer to not have to use multiple spaces every time I want to 
indent. Does Dr. Racket have anything comparable to the tab functionality 
of other programs?

Thank you for letting me join your community!

Karona

;example.rkt

#lang racket

(require racket/match)

(define (say str)
(printf "Chatbot: ~a\n" str))

(define (handle-input str)
(cond
  
[(regexp-match #px"(?i:Hello,* world!)" str)
(say "I would not know about the rest of the world, but I can 
hear \
you just fine.")]
  
[(regexp-match #px"(?i:I( am|'m) learning how to program in 
Racket,* world!)" str)
(say "Racket is a great language, and it is lovely that you are 
\
learning it, but does literally everyone need to know?")]

[(regexp-match #px".*,+\\s*world!" str)
(say "Did the whole world really need to hear that?")]
  
[else (say "Did you really just say something without addressing 
the \
world? I am so proud of you! :,)")]))

(let loop ()
(display "Input: ")
(define str (read-line (current-input-port) 'any))
(handle-input str)
(loop))

-- 
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/2f107ab5-2efd-4c33-83f6-eb5751664cb6n%40googlegroups.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, 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 into racket so that
>> > racket can call that function? I defined a ctype for the function, but i
>> > 

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

Re: [racket-users] Questions

2020-11-23 Thread Matthew Flatt
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 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?

You can cast from a numeric value by casting from `_intptr` to a
pointer type. For example, this expression creates a function that
tries to jump to address 16 (and crashes, but in gdb you'd see it
crashing with the instruction pointer at address 16):

   (cast 16 _intptr (_fun -> _void))


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/20201123060111.3b5%40sirmail.smtps.cs.utah.edu.


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


Re: [racket-users] Questions about working on DrRacket and gui

2020-06-21 Thread Yuki Lee
If you wrote a note or blog while reading the code, please share it with 
me, thank you.

在 2020年5月6日星期三 UTC+8下午5:50:42,Dexter Lagan写道:
>
>   Couple years ago I developed an IDE for NewLISP called NewIDE using a 
> commercial tool called Xojo. It was supposed to become NewLISP's official 
> IDE. I had to put the project on pause because of work and family, and at 
> the same time I switched to Racket, hence my interest. It had replicated 
> most of DrRacket's basic functions apart from the debugger and profiler, 
> but was much faster (native controls + LLVM). I have plenty of time on my 
> hands lately, and I'll take a couple hours each day to analyze DrRacket and 
> see where I can reduce delays and improve responsiveness. Who knows, it 
> might pay off.
>
> After a quick first pass over each module, what DrRacket's source needs is 
> :
> 1) a detailed description of what each module does;
> 2) a description of what each function/class does, methods and properties 
> etc. I don't see a lot of comments at the moment.
>
>   I'll gladly volunteer to write those. I'll annotate the code as I go 
> through it, and I'll push it to a new github when I have enough of it 
> documented. If the DrRacket's authors are happy with the result, we'll 
> merge?
>
>   As for the delay, I'm sure there's a callback somewhere which launches 
> the context-sensitive help, or loads the docs in the background like you 
> said. There's gotta be a way to move this loading time somewhere more 
> appropriate, like say during the init splash, or at the very least display 
> a loading dialog box to inform the user.
>
> Let me know what you think,
>
> Dex
>
> On Tue, May 5, 2020 at 6:17 PM Robby Findler  > wrote:
>
>>
>>
>> On Tue, May 5, 2020 at 10:36 AM Gustavo Massaccesi > > wrote:
>>
>>> I try to encourage people to participate, but be careful because this 
>>> task is probably too big for a first contribution. GUI is difficult, 
>>> DrRacket has a lot of moving parts, and opening DrRacket inside DrRacket is 
>>> possible but weird.
>>>
>>>
>> +1
>>  
>>
>>> I think the guess of Matthew is correct, it´s a problem with the blue 
>>> arrow with the docs. There is no pause while you type numbers but when you 
>>> type a letter or +-*/... there is a pause of 1 or 2 seconds.
>>>
>>> I didn't see the code but my guess is that the docs are loaded lazily in 
>>> a thread and when DrRackets see something like an identifier it waits until 
>>> the thread is ready. It would be nice if the blue arrow is disabled until 
>>> the docs are completely loaded lazily. I think Robby can tell if I'm 
>>> correct and how hard is to fix this.
>>>
>>>
>> Definitely sounds like an extremely actionable hypothesis to investigate 
>> and, if it turns out to be correct, I guess it should be a simple matter of 
>> programming to do what you're suggesting.
>>
>> Robby
>>
>>

-- 
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/3fdb0e8b-00d4-481c-bf7d-21ff9a1ea725o%40googlegroups.com.


Re: [racket-users] Questions about working on DrRacket and gui

2020-05-06 Thread Dexter Lagan
  If you open DrRacket, a new tab opens with #lang racket.
I can type anything I want, a lot of random characters, numbers etc. As soon as 
any keyword is recognized, there’s the pause. For example:

Hejheke
Idhnehje
Osjdjvehjekd
Hdiisbsidhjd
Gueojd jdbdbskbd jdjdb defino definii define <- pause here

  It does the same on any of my systems.

Dex

> On May 6, 2020, at 3:05 PM, Gustavo Massaccesi  wrote:
> 
> 
> I´m not sure if you are writing your own list of known symbols or if you are 
> reusing a list of known symbols that DrRacket is using for something else.
> 
> Gustavo
> 
>> On Wed, May 6, 2020 at 9:25 AM Dexter Lagan  wrote:
>>   If that can help, I narrowed down the delay to new files only, after 
>> typing a known symbol only. When opening an existing file, no matter what I 
>> type in, no delay. If I start a fresh DrRacket, I can type anything in the 
>> definitions window with no delay. The delay only happens if I type a known 
>> function name, for example ‘define’. If I type ‘defind’, there’s no delay. 
>> The delay also appears in Scheme mode, and with background expansion 
>> disabled. No delay in Text mode, which makes sense.
>> 
>>  
>> 
>>   I’m currently looking at the definitions-text from unit.rkt, to see 
>> where’s the hook that detects symbols. I have the day off, and I’m enjoying 
>> this very much.
>> 
>>  
>> 
>> Cheers,
>> 
>>  
>> 
>> Dex
>> 
>>  
>> 
>> From: Robby Findler  
>> Sent: Tuesday, May 5, 2020 6:18 PM
>> To: Gustavo Massaccesi 
>> Cc: Dexter Lagan ; Matthew Flatt 
>> ; Racket Users 
>> Subject: Re: [racket-users] Questions about working on DrRacket and gui
>> 
>>  
>> 
>>  
>> 
>>  
>> 
>> On Tue, May 5, 2020 at 10:36 AM Gustavo Massaccesi  
>> wrote:
>> 
>> I try to encourage people to participate, but be careful because this task 
>> is probably too big for a first contribution. GUI is difficult, DrRacket has 
>> a lot of moving parts, and opening DrRacket inside DrRacket is possible but 
>> weird.
>> 
>>  
>> 
>>  
>> 
>> +1
>> 
>>  
>> 
>> I think the guess of Matthew is correct, it´s a problem with the blue arrow 
>> with the docs. There is no pause while you type numbers but when you type a 
>> letter or +-*/... there is a pause of 1 or 2 seconds.
>> 
>>  
>> 
>> I didn't see the code but my guess is that the docs are loaded lazily in a 
>> thread and when DrRackets see something like an identifier it waits until 
>> the thread is ready. It would be nice if the blue arrow is disabled until 
>> the docs are completely loaded lazily. I think Robby can tell if I'm correct 
>> and how hard is to fix this.
>> 
>>  
>> 
>>  
>> 
>> Definitely sounds like an extremely actionable hypothesis to investigate 
>> and, if it turns out to be correct, I guess it should be a simple matter of 
>> programming to do what you're suggesting.
>> 
>>  
>> 
>> Robby
>> 
>>  

-- 
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/4297A05D-9CB4-4629-80C2-25B7206105A6%40gmail.com.


Re: [racket-users] Questions about working on DrRacket and gui

2020-05-06 Thread Gustavo Massaccesi
I´m not sure if you are writing your own list of known symbols or if you
are reusing a list of known symbols that DrRacket is using for something
else.

Gustavo

On Wed, May 6, 2020 at 9:25 AM Dexter Lagan  wrote:

>   If that can help, I narrowed down the delay to new files only, after
> typing a known symbol only. When opening an existing file, no matter what I
> type in, no delay. If I start a fresh DrRacket, I can type anything in the
> definitions window with no delay. The delay only happens if I type a known
> function name, for example ‘define’. If I type ‘defind’, there’s no delay.
> The delay also appears in Scheme mode, and with background expansion
> disabled. No delay in Text mode, which makes sense.
>
>
>
>   I’m currently looking at the definitions-text from unit.rkt, to see
> where’s the hook that detects symbols. I have the day off, and I’m enjoying
> this very much.
>
>
>
> Cheers,
>
>
>
> Dex
>
>
>
> *From:* Robby Findler 
> *Sent:* Tuesday, May 5, 2020 6:18 PM
> *To:* Gustavo Massaccesi 
> *Cc:* Dexter Lagan ; Matthew Flatt <
> mfl...@cs.utah.edu>; Racket Users 
> *Subject:* Re: [racket-users] Questions about working on DrRacket and gui
>
>
>
>
>
>
>
> On Tue, May 5, 2020 at 10:36 AM Gustavo Massaccesi 
> wrote:
>
> I try to encourage people to participate, but be careful because this task
> is probably too big for a first contribution. GUI is difficult, DrRacket
> has a lot of moving parts, and opening DrRacket inside DrRacket is possible
> but weird.
>
>
>
>
>
> +1
>
>
>
> I think the guess of Matthew is correct, it´s a problem with the blue
> arrow with the docs. There is no pause while you type numbers but when you
> type a letter or +-*/... there is a pause of 1 or 2 seconds.
>
>
>
> I didn't see the code but my guess is that the docs are loaded lazily in a
> thread and when DrRackets see something like an identifier it waits until
> the thread is ready. It would be nice if the blue arrow is disabled until
> the docs are completely loaded lazily. I think Robby can tell if I'm
> correct and how hard is to fix this.
>
>
>
>
>
> Definitely sounds like an extremely actionable hypothesis to investigate
> and, if it turns out to be correct, I guess it should be a simple matter of
> programming to do what you're suggesting.
>
>
>
> Robby
>
>
>

-- 
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/CAPaha9PF-YBGF3zfOPiVawzN7HLRYihO3t8VL50vdog141ZfAQ%40mail.gmail.com.


RE: [racket-users] Questions about working on DrRacket and gui

2020-05-06 Thread Dexter Lagan
  If that can help, I narrowed down the delay to new files only, after typing a 
known symbol only. When opening an existing file, no matter what I type in, no 
delay. If I start a fresh DrRacket, I can type anything in the definitions 
window with no delay. The delay only happens if I type a known function name, 
for example ‘define’. If I type ‘defind’, there’s no delay. The delay also 
appears in Scheme mode, and with background expansion disabled. No delay in 
Text mode, which makes sense.

 

  I’m currently looking at the definitions-text from unit.rkt, to see where’s 
the hook that detects symbols. I have the day off, and I’m enjoying this very 
much.

 

Cheers,

 

Dex

 

From: Robby Findler  
Sent: Tuesday, May 5, 2020 6:18 PM
To: Gustavo Massaccesi 
Cc: Dexter Lagan ; Matthew Flatt ; 
Racket Users 
Subject: Re: [racket-users] Questions about working on DrRacket and gui

 

 

 

On Tue, May 5, 2020 at 10:36 AM Gustavo Massaccesi mailto:gust...@oma.org.ar> > wrote:

I try to encourage people to participate, but be careful because this task is 
probably too big for a first contribution. GUI is difficult, DrRacket has a lot 
of moving parts, and opening DrRacket inside DrRacket is possible but weird.

 

 

+1

 

I think the guess of Matthew is correct, it´s a problem with the blue arrow 
with the docs. There is no pause while you type numbers but when you type a 
letter or +-*/... there is a pause of 1 or 2 seconds.

 

I didn't see the code but my guess is that the docs are loaded lazily in a 
thread and when DrRackets see something like an identifier it waits until the 
thread is ready. It would be nice if the blue arrow is disabled until the docs 
are completely loaded lazily. I think Robby can tell if I'm correct and how 
hard is to fix this.

 

 

Definitely sounds like an extremely actionable hypothesis to investigate and, 
if it turns out to be correct, I guess it should be a simple matter of 
programming to do what you're suggesting.

 

Robby

 

-- 
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/010201d623a1%245c4e23e0%2414ea6ba0%24%40gmail.com.


Re: [racket-users] Questions about working on DrRacket and gui

2020-05-06 Thread Dexter Lagan
  To add to my previous message, I know and understand that DrRacket and
GUI are very complex. I've been going over unit.rkt. Yeah it's a lot of
code. But it's not as bad as I thought.
I'm just offering a hand in making sense of it all. With enough time and
patience I'm sure I'll get something out of it. Now, if you think my time
would be better used for something else Racket-related, do tell.

Dex

On Tue, May 5, 2020 at 6:17 PM Robby Findler 
wrote:

>
>
> On Tue, May 5, 2020 at 10:36 AM Gustavo Massaccesi 
> wrote:
>
>> I try to encourage people to participate, but be careful because this
>> task is probably too big for a first contribution. GUI is difficult,
>> DrRacket has a lot of moving parts, and opening DrRacket inside DrRacket is
>> possible but weird.
>>
>>
> +1
>
>
>> I think the guess of Matthew is correct, it´s a problem with the blue
>> arrow with the docs. There is no pause while you type numbers but when you
>> type a letter or +-*/... there is a pause of 1 or 2 seconds.
>>
>> I didn't see the code but my guess is that the docs are loaded lazily in
>> a thread and when DrRackets see something like an identifier it waits until
>> the thread is ready. It would be nice if the blue arrow is disabled until
>> the docs are completely loaded lazily. I think Robby can tell if I'm
>> correct and how hard is to fix this.
>>
>>
> Definitely sounds like an extremely actionable hypothesis to investigate
> and, if it turns out to be correct, I guess it should be a simple matter of
> programming to do what you're suggesting.
>
> Robby
>
>

-- 
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/CACUENrKfb-Av93DdPhureK6FRA9AfGBiKqWPGb%2BAFM%2Bb6QWUQw%40mail.gmail.com.


Re: [racket-users] Questions about working on DrRacket and gui

2020-05-06 Thread Dexter Lagan
  Couple years ago I developed an IDE for NewLISP called NewIDE using a
commercial tool called Xojo. It was supposed to become NewLISP's official
IDE. I had to put the project on pause because of work and family, and at
the same time I switched to Racket, hence my interest. It had replicated
most of DrRacket's basic functions apart from the debugger and profiler,
but was much faster (native controls + LLVM). I have plenty of time on my
hands lately, and I'll take a couple hours each day to analyze DrRacket and
see where I can reduce delays and improve responsiveness. Who knows, it
might pay off.

After a quick first pass over each module, what DrRacket's source needs is :
1) a detailed description of what each module does;
2) a description of what each function/class does, methods and properties
etc. I don't see a lot of comments at the moment.

  I'll gladly volunteer to write those. I'll annotate the code as I go
through it, and I'll push it to a new github when I have enough of it
documented. If the DrRacket's authors are happy with the result, we'll
merge?

  As for the delay, I'm sure there's a callback somewhere which launches
the context-sensitive help, or loads the docs in the background like you
said. There's gotta be a way to move this loading time somewhere more
appropriate, like say during the init splash, or at the very least display
a loading dialog box to inform the user.

Let me know what you think,

Dex

On Tue, May 5, 2020 at 6:17 PM Robby Findler 
wrote:

>
>
> On Tue, May 5, 2020 at 10:36 AM Gustavo Massaccesi 
> wrote:
>
>> I try to encourage people to participate, but be careful because this
>> task is probably too big for a first contribution. GUI is difficult,
>> DrRacket has a lot of moving parts, and opening DrRacket inside DrRacket is
>> possible but weird.
>>
>>
> +1
>
>
>> I think the guess of Matthew is correct, it´s a problem with the blue
>> arrow with the docs. There is no pause while you type numbers but when you
>> type a letter or +-*/... there is a pause of 1 or 2 seconds.
>>
>> I didn't see the code but my guess is that the docs are loaded lazily in
>> a thread and when DrRackets see something like an identifier it waits until
>> the thread is ready. It would be nice if the blue arrow is disabled until
>> the docs are completely loaded lazily. I think Robby can tell if I'm
>> correct and how hard is to fix this.
>>
>>
> Definitely sounds like an extremely actionable hypothesis to investigate
> and, if it turns out to be correct, I guess it should be a simple matter of
> programming to do what you're suggesting.
>
> Robby
>
>

-- 
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/CACUENr%2BDgdCBJ3JDUT8MQMCaRY03A2-y5TtFXLO8bRe%3Dyctkpg%40mail.gmail.com.


Re: [racket-users] Questions about working on DrRacket and gui

2020-05-05 Thread Robby Findler
On Tue, May 5, 2020 at 10:36 AM Gustavo Massaccesi 
wrote:

> I try to encourage people to participate, but be careful because this task
> is probably too big for a first contribution. GUI is difficult, DrRacket
> has a lot of moving parts, and opening DrRacket inside DrRacket is possible
> but weird.
>
>
+1


> I think the guess of Matthew is correct, it´s a problem with the blue
> arrow with the docs. There is no pause while you type numbers but when you
> type a letter or +-*/... there is a pause of 1 or 2 seconds.
>
> I didn't see the code but my guess is that the docs are loaded lazily in a
> thread and when DrRackets see something like an identifier it waits until
> the thread is ready. It would be nice if the blue arrow is disabled until
> the docs are completely loaded lazily. I think Robby can tell if I'm
> correct and how hard is to fix this.
>
>
Definitely sounds like an extremely actionable hypothesis to investigate
and, if it turns out to be correct, I guess it should be a simple matter of
programming to do what you're suggesting.

Robby

-- 
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/CAL3TdONb7gLOGZ4SEHApoHtfn1kkGmzW0tDQGud2-JL_P65H_Q%40mail.gmail.com.


Re: [racket-users] Questions about working on DrRacket and gui

2020-05-05 Thread Gustavo Massaccesi
I try to encourage people to participate, but be careful because this task
is probably too big for a first contribution. GUI is difficult, DrRacket
has a lot of moving parts, and opening DrRacket inside DrRacket is possible
but weird.

I think the guess of Matthew is correct, it´s a problem with the blue arrow
with the docs. There is no pause while you type numbers but when you type a
letter or +-*/... there is a pause of 1 or 2 seconds.

I didn't see the code but my guess is that the docs are loaded lazily in a
thread and when DrRackets see something like an identifier it waits until
the thread is ready. It would be nice if the blue arrow is disabled until
the docs are completely loaded lazily. I think Robby can tell if I'm
correct and how hard is to fix this.

Gustavo


On Fri, May 1, 2020 at 5:10 PM Matthew Flatt  wrote:

> At Fri, 1 May 2020 16:59:22 +0200, Dexter Lagan wrote:
> >   I'd like to download DrRacket's source and profile it, say to improve
> > scrolling performance or track this post-startup lock-up :
>
> Does the start-time delay happen if you just type a number and hit
> return, as opposed to typing an identifier? If not, the delay is
> probably in loading documentation as triggered the first time DrRacket
> sees an identifier to look up.
>
> > - Do I need to download the entire Racket tree in order to build
> DrRacket?
>
> You can start with minimal Racket and install DrRacket, as Sorawee
> said, but be aware that installing DrRacket will pull in most of a
> normal Racket distribution, anyway.
>
> > - Is the DrRacket's built-in profiler solid enough to handle profiling
> > DrRacket itself?
>
> Running DrRacket inside of DrRacket is not likely to give you useful
> information for something like scrolling, because DrRacket shares the
> GUI instance with programs that it runs.
>
> Running DrRacket with `raco profile` is more promising. It doesn't work
> as easily as it should, partly because DrRacket wants to be in control,
> and partly because `raco profile` doesn't deal with the custodian being
> changed or waiting for a GUI program to exit. But I was able to run it
> by supplying this wrapper program to `raco profile`:
>
>  #lang racket/base
>  (require racket/gui/base)
>
>  (define c (make-custodian))
>  (define done (make-semaphore))
>
>  (parameterize ([current-custodian c])
>(parameterize ([exit-handler
>(lambda (v)
>  (semaphore-post done)
>  (custodian-shutdown-all c))])
>  (define e (make-eventspace))
>  (parameterize ([current-eventspace e])
>(queue-callback (lambda ()
>  ;; here's where we finally start DrRacket
>  (dynamic-require 'drracket #f))
>
>  (sync done)
>
>
> > - Modules in DrRacket's repo don't always have very telling names. Is
> there
> > a document describing what each module does?
>
> There's nothing like that, as far as I know.
>
> > - If I make a change to a source file on my system, yet somebody else
> > modifies the same file on their local system. Say both of our changes are
> > accepted by whoever manages commits, how will accepted changes to the
> code
> > merged?
>
> We use Git, which provides good tools for merging changes.
>
> >   Also, say I have a suggestion regarding how DrRacket handles compiling
> > standalone executables, do I still need to create an issue on its Github?
> > For work I compile to standalone all day long, and I really wish DrRacket
> > didn't zip the resulting file (it would be better to have the .exe file
> in
> > an automatically created /bin or /output folder). Zipping the file takes
> > time, and I have to unzip it each time, which takes more time, this piles
> > up when done every few minutes, all day long. I could use raco exe, but
> I'd
> > rather stay in DrRacket, and I'm sure many people would rather have the
> > default behavior to not zip, just to have single responsibility on the
> > compile function.
>
> That sounds plausible for many cases. (In some cases, depending on the
> platform and the program, there are unavoidably multiple output files.)
>
> >  One last questions: I have encountered differences in the behavior of
> > macros between the REPL, a launcher and a standalone executable for
> > distribution. Is there a document outlining the deeper differences
> between
> > these three ways of executing Racket code?
>
> I think you're probably encountering differences in how the namespace
> and module registry is set up for `eval` and/or `dynamic-require`.
>
> Maybe you've already seen these, but if not, they're good starting
> points:
>
>   https://docs.racket-lang.org/guide/reflection.html
>
>   https://docs.racket-lang.org/raco/exe.html
>   (especially paragraphs 3 through 6 about modules)
>
>
> --
> 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 

Re: [racket-users] Questions about working on DrRacket and gui

2020-05-01 Thread Matthew Flatt
At Fri, 1 May 2020 16:59:22 +0200, Dexter Lagan wrote:
>   I'd like to download DrRacket's source and profile it, say to improve
> scrolling performance or track this post-startup lock-up :

Does the start-time delay happen if you just type a number and hit
return, as opposed to typing an identifier? If not, the delay is
probably in loading documentation as triggered the first time DrRacket
sees an identifier to look up.

> - Do I need to download the entire Racket tree in order to build DrRacket?

You can start with minimal Racket and install DrRacket, as Sorawee
said, but be aware that installing DrRacket will pull in most of a
normal Racket distribution, anyway.

> - Is the DrRacket's built-in profiler solid enough to handle profiling
> DrRacket itself?

Running DrRacket inside of DrRacket is not likely to give you useful
information for something like scrolling, because DrRacket shares the
GUI instance with programs that it runs.

Running DrRacket with `raco profile` is more promising. It doesn't work
as easily as it should, partly because DrRacket wants to be in control,
and partly because `raco profile` doesn't deal with the custodian being
changed or waiting for a GUI program to exit. But I was able to run it
by supplying this wrapper program to `raco profile`:

 #lang racket/base
 (require racket/gui/base)

 (define c (make-custodian))
 (define done (make-semaphore))

 (parameterize ([current-custodian c])
   (parameterize ([exit-handler
   (lambda (v)
 (semaphore-post done)
 (custodian-shutdown-all c))])
 (define e (make-eventspace))
 (parameterize ([current-eventspace e])
   (queue-callback (lambda () 
 ;; here's where we finally start DrRacket
 (dynamic-require 'drracket #f))

 (sync done)


> - Modules in DrRacket's repo don't always have very telling names. Is there
> a document describing what each module does?

There's nothing like that, as far as I know.

> - If I make a change to a source file on my system, yet somebody else
> modifies the same file on their local system. Say both of our changes are
> accepted by whoever manages commits, how will accepted changes to the code
> merged?

We use Git, which provides good tools for merging changes.

>   Also, say I have a suggestion regarding how DrRacket handles compiling
> standalone executables, do I still need to create an issue on its Github?
> For work I compile to standalone all day long, and I really wish DrRacket
> didn't zip the resulting file (it would be better to have the .exe file in
> an automatically created /bin or /output folder). Zipping the file takes
> time, and I have to unzip it each time, which takes more time, this piles
> up when done every few minutes, all day long. I could use raco exe, but I'd
> rather stay in DrRacket, and I'm sure many people would rather have the
> default behavior to not zip, just to have single responsibility on the
> compile function.

That sounds plausible for many cases. (In some cases, depending on the
platform and the program, there are unavoidably multiple output files.)

>  One last questions: I have encountered differences in the behavior of
> macros between the REPL, a launcher and a standalone executable for
> distribution. Is there a document outlining the deeper differences between
> these three ways of executing Racket code?

I think you're probably encountering differences in how the namespace
and module registry is set up for `eval` and/or `dynamic-require`.

Maybe you've already seen these, but if not, they're good starting
points:

  https://docs.racket-lang.org/guide/reflection.html

  https://docs.racket-lang.org/raco/exe.html
  (especially paragraphs 3 through 6 about modules)


-- 
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/5eac8218.1c69fb81.f0545.ba78SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


Re: [racket-users] Questions about working on DrRacket and gui

2020-05-01 Thread Dexter Lagan
  Thanks I’ll look into this.

Dex

> On May 1, 2020, at 5:03 PM, Sorawee Porncharoenwase  
> wrote:
> 
> 
> Sam just suggested me in the other email thread that a much easier way to do 
> things is to download and install Minimal Racket, then install DrRacket from 
> source.
> 
>> On Fri, May 1, 2020 at 7:59 AM Dexter Lagan  wrote:
>> Hi,
>> 
>>   I apologize in advance if my questions are naïve or have been asked 
>> previously. I read the 'Building Racket from Source' guide and couldn't find 
>> answers to some specific questions. I'm new to Git.
>> 
>>   I'd like to download DrRacket's source and profile it, say to improve 
>> scrolling performance or track this post-startup lock-up :
>> - Do I need to download the entire Racket tree in order to build DrRacket?
>> - Is the DrRacket's built-in profiler solid enough to handle profiling 
>> DrRacket itself?
>> - Modules in DrRacket's repo don't always have very telling names. Is there 
>> a document describing what each module does?
>> - If I make a change to a source file on my system, yet somebody else 
>> modifies the same file on their local system. Say both of our changes are 
>> accepted by whoever manages commits, how will accepted changes to the code 
>> merged?
>> 
>>   Also, say I have a suggestion regarding how DrRacket handles compiling 
>> standalone executables, do I still need to create an issue on its Github? 
>> For work I compile to standalone all day long, and I really wish DrRacket 
>> didn't zip the resulting file (it would be better to have the .exe file in 
>> an automatically created /bin or /output folder). Zipping the file takes 
>> time, and I have to unzip it each time, which takes more time, this piles up 
>> when done every few minutes, all day long. I could use raco exe, but I'd 
>> rather stay in DrRacket, and I'm sure many people would rather have the 
>> default behavior to not zip, just to have single responsibility on the 
>> compile function.
>> 
>>  One last questions: I have encountered differences in the behavior of 
>> macros between the REPL, a launcher and a standalone executable for 
>> distribution. Is there a document outlining the deeper differences between 
>> these three ways of executing Racket code?
>> 
>> Have a great weekend, wherever you're confined,
>> 
>> Dexter
>> -- 
>> 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/CACUENr%2B%3Drr87rehZHQyDX%2BusXBZHdCY_46-pkKTuotj6HRwffg%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/078809BB-8EA9-4C2A-B8C4-DD32FEADFF62%40gmail.com.


Re: [racket-users] Questions about working on DrRacket and gui

2020-05-01 Thread Sorawee Porncharoenwase
Sam just suggested me in the other email thread that a much easier way to
do things is to download and install Minimal Racket, then install DrRacket
from source.

On Fri, May 1, 2020 at 7:59 AM Dexter Lagan  wrote:

> Hi,
>
>   I apologize in advance if my questions are naïve or have been asked
> previously. I read the 'Building Racket from Source' guide and couldn't
> find answers to some specific questions. I'm new to Git.
>
>   I'd like to download DrRacket's source and profile it, say to improve
> scrolling performance or track this post-startup lock-up :
> - Do I need to download the entire Racket tree in order to build DrRacket?
> - Is the DrRacket's built-in profiler solid enough to handle profiling
> DrRacket itself?
> - Modules in DrRacket's repo don't always have very telling names. Is
> there a document describing what each module does?
> - If I make a change to a source file on my system, yet somebody else
> modifies the same file on their local system. Say both of our changes are
> accepted by whoever manages commits, how will accepted changes to the code
> merged?
>
>   Also, say I have a suggestion regarding how DrRacket handles compiling
> standalone executables, do I still need to create an issue on its Github?
> For work I compile to standalone all day long, and I really wish DrRacket
> didn't zip the resulting file (it would be better to have the .exe file in
> an automatically created /bin or /output folder). Zipping the file takes
> time, and I have to unzip it each time, which takes more time, this piles
> up when done every few minutes, all day long. I could use raco exe, but I'd
> rather stay in DrRacket, and I'm sure many people would rather have the
> default behavior to not zip, just to have single responsibility on the
> compile function.
>
>  One last questions: I have encountered differences in the behavior of
> macros between the REPL, a launcher and a standalone executable for
> distribution. Is there a document outlining the deeper differences between
> these three ways of executing Racket code?
>
> Have a great weekend, wherever you're confined,
>
> Dexter
>
> --
> 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/CACUENr%2B%3Drr87rehZHQyDX%2BusXBZHdCY_46-pkKTuotj6HRwffg%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/CADcuegsm%2BiZV10KtB46jG%2B2-jAj4Hktotd%3DuXT9zO9bQ_5p78A%40mail.gmail.com.


[racket-users] Questions about working on DrRacket and gui

2020-05-01 Thread Dexter Lagan
Hi,

  I apologize in advance if my questions are naïve or have been asked
previously. I read the 'Building Racket from Source' guide and couldn't
find answers to some specific questions. I'm new to Git.

  I'd like to download DrRacket's source and profile it, say to improve
scrolling performance or track this post-startup lock-up :
- Do I need to download the entire Racket tree in order to build DrRacket?
- Is the DrRacket's built-in profiler solid enough to handle profiling
DrRacket itself?
- Modules in DrRacket's repo don't always have very telling names. Is there
a document describing what each module does?
- If I make a change to a source file on my system, yet somebody else
modifies the same file on their local system. Say both of our changes are
accepted by whoever manages commits, how will accepted changes to the code
merged?

  Also, say I have a suggestion regarding how DrRacket handles compiling
standalone executables, do I still need to create an issue on its Github?
For work I compile to standalone all day long, and I really wish DrRacket
didn't zip the resulting file (it would be better to have the .exe file in
an automatically created /bin or /output folder). Zipping the file takes
time, and I have to unzip it each time, which takes more time, this piles
up when done every few minutes, all day long. I could use raco exe, but I'd
rather stay in DrRacket, and I'm sure many people would rather have the
default behavior to not zip, just to have single responsibility on the
compile function.

 One last questions: I have encountered differences in the behavior of
macros between the REPL, a launcher and a standalone executable for
distribution. Is there a document outlining the deeper differences between
these three ways of executing Racket code?

Have a great weekend, wherever you're confined,

Dexter

-- 
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/CACUENr%2B%3Drr87rehZHQyDX%2BusXBZHdCY_46-pkKTuotj6HRwffg%40mail.gmail.com.


Re: [racket-users] questions about top-level-bind-scope in root-expand-context

2020-03-31 Thread Yongming Shen
I have done some further digging. Looks like it is non-trivial to remove 
the top-level-bind-scope and still preserve the current behaviors of 
top-level `define-values` and `define-syntaxes`. In particular, through 
`as-expand-time-top-level-bindings` in "expander/expand/bind-top.rkt", both 
top-level `define-values` and `define-syntaxes` use 
`select-defined-syms-and-bind!/ctx` from "expander/expand/def-id.rkt", 
which selects variable-symbols and binds them at the same time. So after a 
variable symbol is selected, a binding must be created for it. For 
top-level `define-values` and `define-syntaxes`, using the 
top-level-bind-scope for that mandatory binding is necessary to achieve the 
current top-level behaviors. On the other hand, uses of the 
top-level-bind-scope that are related to `#%top` (such as in 
"expander/expand/expr.rkt" and "expander/expand/main.rkt") appear to be 
non-essential, but may offer minor performance advantages (really not sure).

On Tuesday, March 24, 2020 at 2:15:32 AM UTC-4, Yongming Shen wrote:
>
> Hi Matthew,
>
> Thanks for the explanations. But I'm still not convinced that the 
> top-level-bind-scope is needed. This is my current understanding. The 
> purpose of the  top-level-bind-scope is to support recursion better at the 
> top level. But for the case of `(define-values (x) ...)`, if `x` is not 
> defined yet, then implicit #%top in `...` will let `...` refer to `x`. If 
> `x` is defined, then the old definition will be used by `...`. Either way, 
> the top-level-bind-scope is not needed. For the case of `(define-syntaxes 
> (x) ...)`. As you explained, a macro can naturally recursively refer to 
> itself, simply because of how macro expansion works, so the 
> top-level-bind-scope is again not needed for recursion. Is my understanding 
> correct?
>
>
> On Monday, March 23, 2020 at 10:05:12 AM UTC-4, Matthew Flatt wrote:
>>
>> At Mon, 23 Mar 2020 01:45:40 -0700 (PDT), Yongming Shen wrote: 
>> > I tried the example you gave for my first question and it resulted in 
>> an 
>> > error. 
>>
>> Oops --- you're right. I lost track of what we try to make work at the 
>> top level. 
>>
>> > I think this is because `(define-values (x) ...)` expands `...` without 
>> the 
>> > top-level-bind-scope, even when expand-context-to-parsed? is #t 
>> (according 
>> > to expander/expand/top.rkt). Is this a bug? 
>>
>> Since the behavior goes far back, I think this is the behavior that we 
>> decided to settle for. 
>>
>> > Related to your answer to my second question, `define-syntaxes` 
>> similarly 
>> > does not add the top-level-bind-scope when expanding `...`. Does this 
>> mean 
>> > that even for `define-syntaxes`, `...` won't use the 
>> top-level-bind-scope 
>> > binding(s) after all? 
>>
>> The way that evaluation, binding, and expansion are interleaved means 
>> that a `define-syntaxes` macro can refer to itself in expansions. The 
>> binding of an identifier in a macro template is resolved after the 
>> macro is applied. 
>>
>> The difference with `define` is that the right-hand side is 
>> expanded/compiled before `define` binds. 
>>
>> > A little bit off-topic, in the definition of define-values (in 
>> > expander/expand/top.rkt), there is `(define-match m s ...)`, but for 
>> > define-syntaxes it is `(define-match m disarmed-s ...)`. Is this 
>> difference 
>> > significant? Or does define-match not care whether `s` or `disarmed-s` 
>> is 
>> > used? 
>>
>> Using `disarmed-s` in the definition of `define-values` is probably 
>> a better idea, and I'll look into that more. 
>>
>> It think it turns out not to matter, normally, because `define-values` 
>> is transparent to syntax arming via `syntax-arm` with a #t second 
>> argument (which is what the expander does). But it would be better to 
>> not rely on that. 
>>
>>

-- 
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/09bf14a5-1c1c-4718-80d7-c4414bf98d52%40googlegroups.com.


Re: [racket-users] questions about top-level-bind-scope in root-expand-context

2020-03-24 Thread Yongming Shen
Hi Matthew,

Thanks for the explanations. But I'm still not convinced that the 
top-level-bind-scope is needed. This is my current understanding. The 
purpose of the  top-level-bind-scope is to support recursion better at the 
top level. But for the case of `(define-values (x) ...)`, if `x` is not 
defined yet, then implicit #%top in `...` will let `...` refer to `x`. If 
`x` is defined, then the old definition will be used by `...`. Either way, 
the top-level-bind-scope is not needed. For the case of `(define-syntaxes 
(x) ...)`. As you explained, a macro can naturally recursively refer to 
itself, simply because of how macro expansion works, so the 
top-level-bind-scope is again not needed for recursion. Is my understanding 
correct?


On Monday, March 23, 2020 at 10:05:12 AM UTC-4, Matthew Flatt wrote:
>
> At Mon, 23 Mar 2020 01:45:40 -0700 (PDT), Yongming Shen wrote: 
> > I tried the example you gave for my first question and it resulted in an 
> > error. 
>
> Oops --- you're right. I lost track of what we try to make work at the 
> top level. 
>
> > I think this is because `(define-values (x) ...)` expands `...` without 
> the 
> > top-level-bind-scope, even when expand-context-to-parsed? is #t 
> (according 
> > to expander/expand/top.rkt). Is this a bug? 
>
> Since the behavior goes far back, I think this is the behavior that we 
> decided to settle for. 
>
> > Related to your answer to my second question, `define-syntaxes` 
> similarly 
> > does not add the top-level-bind-scope when expanding `...`. Does this 
> mean 
> > that even for `define-syntaxes`, `...` won't use the 
> top-level-bind-scope 
> > binding(s) after all? 
>
> The way that evaluation, binding, and expansion are interleaved means 
> that a `define-syntaxes` macro can refer to itself in expansions. The 
> binding of an identifier in a macro template is resolved after the 
> macro is applied. 
>
> The difference with `define` is that the right-hand side is 
> expanded/compiled before `define` binds. 
>
> > A little bit off-topic, in the definition of define-values (in 
> > expander/expand/top.rkt), there is `(define-match m s ...)`, but for 
> > define-syntaxes it is `(define-match m disarmed-s ...)`. Is this 
> difference 
> > significant? Or does define-match not care whether `s` or `disarmed-s` 
> is 
> > used? 
>
> Using `disarmed-s` in the definition of `define-values` is probably 
> a better idea, and I'll look into that more. 
>
> It think it turns out not to matter, normally, because `define-values` 
> is transparent to syntax arming via `syntax-arm` with a #t second 
> argument (which is what the expander does). But it would be better to 
> not rely on that. 
>
>

-- 
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/97759d2c-4d94-422e-b984-5ec9001b0fca%40googlegroups.com.


Re: [racket-users] questions about top-level-bind-scope in root-expand-context

2020-03-23 Thread Alexis King
> On Mar 23, 2020, at 13:46, George Neuner  wrote:
> 
> I've run into this problem before ... I don't recall the official
> explanation, but my takeaway was that Racket does not permit you to
> directly *export* a value - you have to export a function or macro
> that produces the value.
> 
> E.g., 
>  #lang racket
>  (provide fib)
>  (define (fib) "fib")

I’m not sure what issue you may have run into in the past, but Racket certainly 
has no issue with exporting a value. (After all, functions are values.) The 
issue described in this thread is (a) entirely syntactic (it’s an issue of 
binding/scoping, not runtime behavior), and (b) only occurs at the top-level 
(i.e. in the REPL, outside of a module). Matthew has already provided a 
detailed explanation of why the issue occurs.

It’s true that you cannot set! imported bindings, but that’s quite separate 
from the problem discussed in this thread (which appears to be resolved).

-- 
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/DB94641E-A018-4A1D-BEE3-47DD183D7B54%40gmail.com.


Re: [racket-users] questions about top-level-bind-scope in root-expand-context

2020-03-23 Thread Matthew Flatt
At Mon, 23 Mar 2020 01:45:40 -0700 (PDT), Yongming Shen wrote:
> I tried the example you gave for my first question and it resulted in an 
> error.

Oops --- you're right. I lost track of what we try to make work at the
top level.

> I think this is because `(define-values (x) ...)` expands `...` without the 
> top-level-bind-scope, even when expand-context-to-parsed? is #t (according 
> to expander/expand/top.rkt). Is this a bug?

Since the behavior goes far back, I think this is the behavior that we
decided to settle for.

> Related to your answer to my second question, `define-syntaxes` similarly 
> does not add the top-level-bind-scope when expanding `...`. Does this mean 
> that even for `define-syntaxes`, `...` won't use the top-level-bind-scope 
> binding(s) after all?

The way that evaluation, binding, and expansion are interleaved means
that a `define-syntaxes` macro can refer to itself in expansions. The
binding of an identifier in a macro template is resolved after the
macro is applied.

The difference with `define` is that the right-hand side is
expanded/compiled before `define` binds.

> A little bit off-topic, in the definition of define-values (in 
> expander/expand/top.rkt), there is `(define-match m s ...)`, but for 
> define-syntaxes it is `(define-match m disarmed-s ...)`. Is this difference 
> significant? Or does define-match not care whether `s` or `disarmed-s` is 
> used?

Using `disarmed-s` in the definition of `define-values` is probably
a better idea, and I'll look into that more.

It think it turns out not to matter, normally, because `define-values`
is transparent to syntax arming via `syntax-arm` with a #t second
argument (which is what the expander does). But it would be better to
not rely on that.

-- 
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/5e78c215.1c69fb81.5b855.0569SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


Re: [racket-users] questions about top-level-bind-scope in root-expand-context

2020-03-23 Thread Yongming Shen
Hi Matthew,

Thank you for the quick reply!

I tried the example you gave for my first question and it resulted in an 
error.
I have the following as `module-that-defines-fib`:

  #lang racket
  (provide fib)
  (define fib "fib")

And this is the error that I got (using Racket 7.6):

  ; application: not a procedure;
  ;  expected a procedure that can be applied to arguments
  ;   given: "fib"
  ; [,bt for context]

I think this is because `(define-values (x) ...)` expands `...` without the 
top-level-bind-scope, even when expand-context-to-parsed? is #t (according 
to expander/expand/top.rkt). Is this a bug?
Related to your answer to my second question, `define-syntaxes` similarly 
does not add the top-level-bind-scope when expanding `...`. Does this mean 
that even for `define-syntaxes`, `...` won't use the top-level-bind-scope 
binding(s) after all?

A little bit off-topic, in the definition of define-values (in 
expander/expand/top.rkt), there is `(define-match m s ...)`, but for 
define-syntaxes it is `(define-match m disarmed-s ...)`. Is this difference 
significant? Or does define-match not care whether `s` or `disarmed-s` is 
used?

Thanks,
Yongming


On Saturday, March 21, 2020 at 9:25:01 AM UTC-4, Matthew Flatt wrote:
>
> At Sat, 21 Mar 2020 00:00:07 -0700 (PDT), Yongming Shen wrote: 
> > First, in the source file expander/expand/bind-top.rkt, there is a 
> comment 
> > that says "When compiling `(define-values (x) ...)` at the top level, 
> > we'd like to bind `x` so that a reference in the "..." will point back 
> to 
> > the definition, as opposed to being whatever `x` was before." Isn't this 
> > the exact opposite of what (define-values (x) ...) should do? 
>
> Here's an example scenario that the current rule is meant to cover: 
>
>  > (require module-that-defines-fib) 
>
>  > fib ; refers to binding from `module-that-defines-fib` 
>
>  > (define (fib n) 
>  (if (< n 2) 
>  1 
>  (+ (fib (- n 1)) (fib (- n 2) ; refers to this definition 
>
>  > (fib 27) ; => 514229 
>
> If a programmer usually expects the `fib`s in the definition's `...` 
> region here to refer to the new definition, not to the imported 
> binding, then the implemented rule is the right one. If programmers 
> expect that `fib`s in the `...` to refer to the imported binding, then 
> I'd agree with you. But I think the former is more often the case. 
>
> Neither rule is obviously right, and if we make the example more 
> complicated with more macros involved, I'm pretty sure there's no way 
> to implement either rule consistently: the top level is hopeless. The 
> case of a single recursive function seems common enough that we've 
> picked a rule and implementation to make it work. 
>
> > Second, ignoring the comment mentioned above, but still consider 
> > `(define-values (x) ...)`. It appears that the binding of `x` to `...` 
> with 
> > the top-level-bind-scope is only used by `(#%top . x)` (either explicit 
> or 
> > implicit). The only exception seems to be in contexts where neither `x` 
> nor 
> > #%top are binded, in which case `x`, not wrapped by #%top, also uses 
> that 
> > binding. The case of `(#%top . x)` is confusing because even without the 
> > top-level-bind-scope binding of `x`, `(#%top . x)` can still locate 
> > `(define-values (x) ...)`, otherwise mutually recursive functions won't 
> > work at the top level. As for the exception case, it seems rare enough 
> that 
> > it can be ignored. So my question is, what's benefit does the 
> > top-level-bind-scope bring? 
>
> Just to restate (to make sure I understand), you're pointing out that 
> an unbound identifier is treated the same as a binding using the 
> top-level scope (i.e., both refer to a top-level variable) --- so why 
> bother with the top-level scope? 
>
> Although the result is the same for variable references, it's not the 
> same for macro bindings or for imported bindings. And, then, there's no 
> way to predict in advance that an identifier will be used as a variable 
> and omit the top-level scope in that case. 
>
> Stepping back a little, it may not be the right design choice to treat 
> an unbound identifier as a reference to a top-level variable. But some 
> sort of default is necessary to support the traditional top level. And 
> treating unbound identifiers this was avoids a[nother] special 
> treatment of top-level scopes, where an unbound variable could be 
> treated as a variable reference only if it has a top-level scope. 
>
> Really, the only consistent approach that I know is to not have an 
> interactive top level, but that's not an attractive option. 
>
>
> 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 

Re: [racket-users] questions about top-level-bind-scope in root-expand-context

2020-03-21 Thread Matthew Flatt
At Sat, 21 Mar 2020 00:00:07 -0700 (PDT), Yongming Shen wrote:
> First, in the source file expander/expand/bind-top.rkt, there is a comment 
> that says "When compiling `(define-values (x) ...)` at the top level, 
> we'd like to bind `x` so that a reference in the "..." will point back to 
> the definition, as opposed to being whatever `x` was before." Isn't this 
> the exact opposite of what (define-values (x) ...) should do?

Here's an example scenario that the current rule is meant to cover:

 > (require module-that-defines-fib)

 > fib ; refers to binding from `module-that-defines-fib`

 > (define (fib n)
 (if (< n 2)
 1 
 (+ (fib (- n 1)) (fib (- n 2) ; refers to this definition

 > (fib 27) ; => 514229

If a programmer usually expects the `fib`s in the definition's `...`
region here to refer to the new definition, not to the imported
binding, then the implemented rule is the right one. If programmers
expect that `fib`s in the `...` to refer to the imported binding, then
I'd agree with you. But I think the former is more often the case.

Neither rule is obviously right, and if we make the example more
complicated with more macros involved, I'm pretty sure there's no way
to implement either rule consistently: the top level is hopeless. The
case of a single recursive function seems common enough that we've
picked a rule and implementation to make it work.

> Second, ignoring the comment mentioned above, but still consider 
> `(define-values (x) ...)`. It appears that the binding of `x` to `...` with 
> the top-level-bind-scope is only used by `(#%top . x)` (either explicit or 
> implicit). The only exception seems to be in contexts where neither `x` nor 
> #%top are binded, in which case `x`, not wrapped by #%top, also uses that 
> binding. The case of `(#%top . x)` is confusing because even without the 
> top-level-bind-scope binding of `x`, `(#%top . x)` can still locate 
> `(define-values (x) ...)`, otherwise mutually recursive functions won't 
> work at the top level. As for the exception case, it seems rare enough that 
> it can be ignored. So my question is, what's benefit does the 
> top-level-bind-scope bring?

Just to restate (to make sure I understand), you're pointing out that
an unbound identifier is treated the same as a binding using the
top-level scope (i.e., both refer to a top-level variable) --- so why
bother with the top-level scope?

Although the result is the same for variable references, it's not the
same for macro bindings or for imported bindings. And, then, there's no
way to predict in advance that an identifier will be used as a variable
and omit the top-level scope in that case.

Stepping back a little, it may not be the right design choice to treat
an unbound identifier as a reference to a top-level variable. But some
sort of default is necessary to support the traditional top level. And
treating unbound identifiers this was avoids a[nother] special
treatment of top-level scopes, where an unbound variable could be
treated as a variable reference only if it has a top-level scope.

Really, the only consistent approach that I know is to not have an
interactive top level, but that's not an attractive option.


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/5e7615aa.1c69fb81.fec6a.0fe0SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


[racket-users] questions about top-level-bind-scope in root-expand-context

2020-03-21 Thread Yongming Shen
Hi,

I noticed that top level (define-values ...) forms create bindings that 
include the top-level-bind-scope (of the namespace's root-expand-context), 
and have two questions related to this.

First, in the source file expander/expand/bind-top.rkt, there is a comment 
that says "When compiling `(define-values (x) ...)` at the top level, 
we'd like to bind `x` so that a reference in the "..." will point back to 
the definition, as opposed to being whatever `x` was before." Isn't this 
the exact opposite of what (define-values (x) ...) should do?

Second, ignoring the comment mentioned above, but still consider 
`(define-values (x) ...)`. It appears that the binding of `x` to `...` with 
the top-level-bind-scope is only used by `(#%top . x)` (either explicit or 
implicit). The only exception seems to be in contexts where neither `x` nor 
#%top are binded, in which case `x`, not wrapped by #%top, also uses that 
binding. The case of `(#%top . x)` is confusing because even without the 
top-level-bind-scope binding of `x`, `(#%top . x)` can still locate 
`(define-values (x) ...)`, otherwise mutually recursive functions won't 
work at the top level. As for the exception case, it seems rare enough that 
it can be ignored. So my question is, what's benefit does the 
top-level-bind-scope bring?

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/3a1ee8c8-a990-4337-840a-5458d2ee36c7%40googlegroups.com.


Re: [racket-users] Questions on a very simple class

2020-02-15 Thread Alain De Vos
When i try typed/racket :
#lang typed/racket
(define (integerclass x)
  (define (getx) x)
  (define (setx! [x_new : Integer]) (set! x x_new))
  (define (add [y : integerclass]) : integerclass (integerclass (+ 1 (y 
'getx
  (lambda (message . args)
(case message
((getx)  (apply getxargs))
((setx!) (apply setx!   args))
((add)   (apply add args))
  (else (error "POINT: Unknown message ->" message)

(define (myprint x) (print x)(newline))
(define p1 (integerclass 1))
(myprint (p1 'getx))
(define p2 (integerclass 2))
(myprint (p2 'getx))
(define p3 (p1 'add p2))
(myprint (p3 'getx))

I receive the errors,
On the line:
(define (add [y : integerclass]) : integerclass (integerclass (+ x (y 
'getx
4 errors :
Type Checker: parse error in type; type name `integerclass' is unbound in: 
integerclass
Type Checker: parse error in type; type name `integerclass' is unbound in: 
integerclass
Type Checker: missing type for identifier;consider adding a type annotation 
with `:' identifier: integerclass in: integerclass
Type Checker: type mismatch expected: Number given: Any in: x

On the line : 
((getx)  (apply getxargs))
Error :Type Checker: Bad arguments to function in `apply': Domain:  
Arguments:  (Listof Any)
Other apply lines produce same errors.

On Sunday, February 16, 2020 at 12:25:41 AM UTC+1, Sage Gerard wrote:
>
> 1. If the intention is to create a class, then I'd use the class form.
>
>
> https://docs.racket-lang.org/reference/createclass.html#%28form._%28%28lib._racket%2Fprivate%2Fclass-internal..rkt%29._class%2A%29%29
>
> Not that there's anything overtly wrong with using a closure, but common 
> validation tasks re: inheritance, overriding, etc. all have to be done by 
> hand here.
>
> 2. What specific error message did you get?
>
> *~slg*
>
>
> ‐‐‐ Original Message ‐‐‐
> On Saturday, February 15, 2020 6:18 PM, Alain De Vos  > wrote:
>
>
> Following code makes an "integerclass" with an "add" method :
>
> #lang racket
> (define (integerclass x)
>   (define (getx)  x)
>   (define (setx! x_new) (set! x x_new))
>   (define (add y)(integerclass (+ x (y 'getx
>   (lambda (message . args)
> (case message
> ((getx)  (apply getxargs))
> ((setx!) (apply setx!   args))
> ((add)   (apply add args))
>   (else (error "POINT: Unknown message ->" message)
>
> (define (myprint x) (print x)(newline))
> (define p1 (integerclass 1))
> (myprint (p1 'getx))
> (define p2 (integerclass 2))
> (myprint (p2 'getx))
> (define p3 (p1 'add p2))
> (myprint (p3 'getx))
>
> Question 1 : can this code be inproved, are there "better patterns" one 
> can you.
> Question 2 : can i modify this code to use typed/racket. I tried but 
> failed on the "apply" method in the code.
>
>
> --
> 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/c28892b8-e49b-4257-9ebe-4560943e87a7%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/644612e1-ee15-4acb-b2b9-ed8c94f85f86%40googlegroups.com.


Re: [racket-users] Questions on a very simple class

2020-02-15 Thread Sage Gerard
1. If the intention is to create a class, then I'd use the class form.

https://docs.racket-lang.org/reference/createclass.html#%28form._%28%28lib._racket%2Fprivate%2Fclass-internal..rkt%29._class%2A%29%29

Not that there's anything overtly wrong with using a closure, but common 
validation tasks re: inheritance, overriding, etc. all have to be done by hand 
here.

2. What specific error message did you get?

~slg

‐‐‐ Original Message ‐‐‐
On Saturday, February 15, 2020 6:18 PM, Alain De Vos  
wrote:

> Following code makes an "integerclass" with an "add" method :
>
> #lang racket
> (define (integerclass x)
>   (define (getx)  x)
>   (define (setx! x_new) (set! x x_new))
>   (define (add y)(integerclass (+ x (y 'getx
>   (lambda (message . args)
> (case message
> ((getx)  (apply getxargs))
> ((setx!) (apply setx!   args))
> ((add)   (apply add args))
>   (else (error "POINT: Unknown message ->" message)
>
> (define (myprint x) (print x)(newline))
> (define p1 (integerclass 1))
> (myprint (p1 'getx))
> (define p2 (integerclass 2))
> (myprint (p2 'getx))
> (define p3 (p1 'add p2))
> (myprint (p3 'getx))
>
> Question 1 : can this code be inproved, are there "better patterns" one can 
> you.
> Question 2 : can i modify this code to use typed/racket. I tried but failed 
> on the "apply" method in the code.
>
> --
> 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/c28892b8-e49b-4257-9ebe-4560943e87a7%40googlegroups.com](https://groups.google.com/d/msgid/racket-users/c28892b8-e49b-4257-9ebe-4560943e87a7%40googlegroups.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/gUC9HzrnJWNGbe-kgcoyov8KOUFY7sKw4KNu2CfqFABrsW0dsGpLsPfuKAHmcoXMBFECT4Bln1wQMYhpOFhL_y4WjYY-RWnveapTNESXHoc%3D%40sagegerard.com.


[racket-users] Questions on a very simple class

2020-02-15 Thread Alain De Vos

Following code makes an "integerclass" with an "add" method :

#lang racket
(define (integerclass x)
  (define (getx)  x)
  (define (setx! x_new) (set! x x_new))
  (define (add y)(integerclass (+ x (y 'getx
  (lambda (message . args)
(case message
((getx)  (apply getxargs))
((setx!) (apply setx!   args))
((add)   (apply add args))
  (else (error "POINT: Unknown message ->" message)

(define (myprint x) (print x)(newline))
(define p1 (integerclass 1))
(myprint (p1 'getx))
(define p2 (integerclass 2))
(myprint (p2 'getx))
(define p3 (p1 'add p2))
(myprint (p3 'getx))

Question 1 : can this code be inproved, are there "better patterns" one can 
you.
Question 2 : can i modify this code to use typed/racket. I tried but failed 
on the "apply" method in the code.

-- 
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/c28892b8-e49b-4257-9ebe-4560943e87a7%40googlegroups.com.


Re: pkgs still has no docs? (was: Re: [racket-users] Questions about Scribble docs)

2019-02-19 Thread David Storrs
Speaking of things with no docs, the abnf package seems intriguing. Does
anyone have a short summary or example?

On Tue, Feb 19, 2019, 5:14 PM John Clements 
wrote:

> Looks like… this is still the case? Specifically, reloading
> pkgs.racket-lang.org still shows that all packages are missing
> documentation. I thought I’d seen a message suggesting that this was
> resolved, but it appears I was mistaken.
>
> John
>
>
> > On Feb 16, 2019, at 8:08 PM, David Storrs 
> wrote:
> >
> > On Sat, Feb 16, 2019 at 9:18 PM Greg Hendershott
> >  wrote:
> >>
> >> The package web site seems to think no packages have been built: The
> >> "Most recent build results" item is blank for every of the dozen
> >> packages I just checked.
> >
> > Ah, that would do it.  Thanks.
> >
> >>
> >> So I think that's one problem.
> >>
> >>
> >> When that's working normally, as it usually does, there are two levels
> >> of refresh:
> >>
> >> 1. The package catalog server points to e.g. your most recent commit
> >> on Git{Hub Lab}.com. You push a new commit. The package catalog might
> >> take an hour before it notices. This is the thing you can "kick" by
> >> logging in and choosing "Rescan my packges".
> >>
> >> 2. The build server runs daily. This is what builds your docs as part
> >> of building your package. So, even if it were working, now, it might
> >> take 24 hours. There's no way to nudge this AFAIK.
> >>
> >>
> >> On Sat, Feb 16, 2019 at 8:21 PM David Storrs 
> wrote:
> >>>
> >>> Do I need to do something particular to make the package server notice
> >>> my documentation?  I've got a scribblings/struct-plus-plus.scrbl file
> >>> but the package server is still listing it as "needs documentation".
> >>>
> >>> Separate but related, when I install a module and it builds the
> >>> documentation, is there a way to make it integrate with the built-in
> >>> docs so that I can load it in the browser and search?
> >>>
> >>> --
> >>> You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> >>> To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> >>> For more options, visit https://groups.google.com/d/optout.
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> >> For more options, visit https://groups.google.com/d/optout.
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


pkgs still has no docs? (was: Re: [racket-users] Questions about Scribble docs)

2019-02-19 Thread 'John Clements' via Racket Users
Looks like… this is still the case? Specifically, reloading 
pkgs.racket-lang.org still shows that all packages are missing documentation. I 
thought I’d seen a message suggesting that this was resolved, but it appears I 
was mistaken.

John


> On Feb 16, 2019, at 8:08 PM, David Storrs  wrote:
> 
> On Sat, Feb 16, 2019 at 9:18 PM Greg Hendershott
>  wrote:
>> 
>> The package web site seems to think no packages have been built: The
>> "Most recent build results" item is blank for every of the dozen
>> packages I just checked.
> 
> Ah, that would do it.  Thanks.
> 
>> 
>> So I think that's one problem.
>> 
>> 
>> When that's working normally, as it usually does, there are two levels
>> of refresh:
>> 
>> 1. The package catalog server points to e.g. your most recent commit
>> on Git{Hub Lab}.com. You push a new commit. The package catalog might
>> take an hour before it notices. This is the thing you can "kick" by
>> logging in and choosing "Rescan my packges".
>> 
>> 2. The build server runs daily. This is what builds your docs as part
>> of building your package. So, even if it were working, now, it might
>> take 24 hours. There's no way to nudge this AFAIK.
>> 
>> 
>> On Sat, Feb 16, 2019 at 8:21 PM David Storrs  wrote:
>>> 
>>> Do I need to do something particular to make the package server notice
>>> my documentation?  I've got a scribblings/struct-plus-plus.scrbl file
>>> but the package server is still listing it as "needs documentation".
>>> 
>>> Separate but related, when I install a module and it builds the
>>> documentation, is there a way to make it integrate with the built-in
>>> docs so that I can load it in the browser and search?
>>> 
>>> --
>>> You received this message because you are subscribed to the Google Groups 
>>> "Racket Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to racket-users+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>> 
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Questions about Scribble docs

2019-02-16 Thread David Storrs
On Sat, Feb 16, 2019 at 9:18 PM Greg Hendershott
 wrote:
>
> The package web site seems to think no packages have been built: The
> "Most recent build results" item is blank for every of the dozen
> packages I just checked.

Ah, that would do it.  Thanks.

>
> So I think that's one problem.
>
>
> When that's working normally, as it usually does, there are two levels
> of refresh:
>
> 1. The package catalog server points to e.g. your most recent commit
> on Git{Hub Lab}.com. You push a new commit. The package catalog might
> take an hour before it notices. This is the thing you can "kick" by
> logging in and choosing "Rescan my packges".
>
> 2. The build server runs daily. This is what builds your docs as part
> of building your package. So, even if it were working, now, it might
> take 24 hours. There's no way to nudge this AFAIK.
>
>
> On Sat, Feb 16, 2019 at 8:21 PM David Storrs  wrote:
> >
> > Do I need to do something particular to make the package server notice
> > my documentation?  I've got a scribblings/struct-plus-plus.scrbl file
> > but the package server is still listing it as "needs documentation".
> >
> > Separate but related, when I install a module and it builds the
> > documentation, is there a way to make it integrate with the built-in
> > docs so that I can load it in the browser and search?
> >
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an 
> > email to racket-users+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Questions about Scribble docs

2019-02-16 Thread Greg Hendershott
p.s. As another example of the current breakage: All my own packages
that do have documentation, have yellow "This package needs
documentation" demerit badges, at the moment.

On Sat, Feb 16, 2019 at 9:17 PM Greg Hendershott
 wrote:
>
> The package web site seems to think no packages have been built: The
> "Most recent build results" item is blank for every of the dozen
> packages I just checked.
>
> So I think that's one problem.
>
>
> When that's working normally, as it usually does, there are two levels
> of refresh:
>
> 1. The package catalog server points to e.g. your most recent commit
> on Git{Hub Lab}.com. You push a new commit. The package catalog might
> take an hour before it notices. This is the thing you can "kick" by
> logging in and choosing "Rescan my packges".
>
> 2. The build server runs daily. This is what builds your docs as part
> of building your package. So, even if it were working, now, it might
> take 24 hours. There's no way to nudge this AFAIK.
>
>
> On Sat, Feb 16, 2019 at 8:21 PM David Storrs  wrote:
> >
> > Do I need to do something particular to make the package server notice
> > my documentation?  I've got a scribblings/struct-plus-plus.scrbl file
> > but the package server is still listing it as "needs documentation".
> >
> > Separate but related, when I install a module and it builds the
> > documentation, is there a way to make it integrate with the built-in
> > docs so that I can load it in the browser and search?
> >
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an 
> > email to racket-users+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Questions about Scribble docs

2019-02-16 Thread Greg Hendershott
The package web site seems to think no packages have been built: The
"Most recent build results" item is blank for every of the dozen
packages I just checked.

So I think that's one problem.


When that's working normally, as it usually does, there are two levels
of refresh:

1. The package catalog server points to e.g. your most recent commit
on Git{Hub Lab}.com. You push a new commit. The package catalog might
take an hour before it notices. This is the thing you can "kick" by
logging in and choosing "Rescan my packges".

2. The build server runs daily. This is what builds your docs as part
of building your package. So, even if it were working, now, it might
take 24 hours. There's no way to nudge this AFAIK.


On Sat, Feb 16, 2019 at 8:21 PM David Storrs  wrote:
>
> Do I need to do something particular to make the package server notice
> my documentation?  I've got a scribblings/struct-plus-plus.scrbl file
> but the package server is still listing it as "needs documentation".
>
> Separate but related, when I install a module and it builds the
> documentation, is there a way to make it integrate with the built-in
> docs so that I can load it in the browser and search?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Questions about Scribble docs

2019-02-16 Thread David Storrs
Do I need to do something particular to make the package server notice
my documentation?  I've got a scribblings/struct-plus-plus.scrbl file
but the package server is still listing it as "needs documentation".

Separate but related, when I install a module and it builds the
documentation, is there a way to make it integrate with the built-in
docs so that I can load it in the browser and search?

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Questions about plot

2018-12-05 Thread Matt Jadud
Hi Doug,

I suspect (in this case), I'd like to build on/leverage plot, because I'd
like things to place nice in DrRacket's REPL (for example), and be able to
play with the plot ecosystem. To save you any work, I'll circle around
later if future me thinks current me was wrong.

This is crossing with Alex's message; based on his message/example, I think
I've read down too far, and need to spend more time looking at the tools
provided. For example, I somehow missed that (x-axis ...) could have its
origin moved. Instead, I was down into the points, line, and other
renderers, and therefore trying to implement my own renderer... when, in
truth, it is likely that everything I need at the moment is exposed "in
userland," if you will.

Thank you both,
M

On Wed, Dec 5, 2018 at 6:45 PM Doug Williams 
wrote:

> I have done many extensions to plots for a variety of reasons. Most of my
> extensions are a third option: Build on dc%. I typically make a new widget,
> say based on a horizontal or vertical panel with one or more embedded
> canvases. Then I use plot/dc to render directly on those canvases. I can
> easily aligned multiple plots, add additional elements outside the plots
> (in other embedded canvases), or overwrite the plot as I want. This works
> great for plots that are embedded in graphical programs - I do a lot of
> analysis work that way. I assume you could use plot/pict in a similar
> manner, but I never have.
>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Questions about plot

2018-12-05 Thread Doug Williams
Matt,

I have done many extensions to plots for a variety of reasons. Most of my
extensions are a third option: Build on dc%. I typically make a new widget,
say based on a horizontal or vertical panel with one or more embedded
canvases. Then I use plot/dc to render directly on those canvases. I can
easily aligned multiple plots, add additional elements outside the plots
(in other embedded canvases), or overwrite the plot as I want. This works
great for plots that are embedded in graphical programs - I do a lot of
analysis work that way. I assume you could use plot/pict in a similar
manner, but I never have.

I'm not sure that helps your particular scenario. I would be glad to point
you to code snippets.

Doug

On Wed, Dec 5, 2018 at 4:22 PM Matt Jadud  wrote:

> Hi all,
>
> If I want to develop a new plot type, would I do best to:
>
> 1. Build on plot, or
> 2. Build on pict?
>
> I suspect #1.
>
> If I want to (say) have a number line, I would like to have an x-axis,
> centered in my plot area (vertically), and no y-axis. I've been reading the
> plot code for scatter plots, and I'm not clear where/how, if I were to
> implement in a similar way, where I would override/parameterize for
> changing the axes. (There's near and far axes (bottom and top) in 2D
> renderers, but I don't seem to get to decide where they go vertically in
> the plot space.)
>
> Then, would I be drawing to it using the utilities built into plot, or do
> I convert to a dc% in some way, and leverage pict, or... ?
>
> In short, I feel like I should be building on plot/extending plot, I don't
> want to reinvent wheels that are already invented, but I'm not yet sure
> where the best starting point is. Do I develop a new plot type, dig deeper
> into how axes are drawn, or do I do everything with overlays, or ...?
>
> Many thanks,
> Matt
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Questions about plot

2018-12-05 Thread Matt Jadud
Hi all,

If I want to develop a new plot type, would I do best to:

1. Build on plot, or
2. Build on pict?

I suspect #1.

If I want to (say) have a number line, I would like to have an x-axis,
centered in my plot area (vertically), and no y-axis. I've been reading the
plot code for scatter plots, and I'm not clear where/how, if I were to
implement in a similar way, where I would override/parameterize for
changing the axes. (There's near and far axes (bottom and top) in 2D
renderers, but I don't seem to get to decide where they go vertically in
the plot space.)

Then, would I be drawing to it using the utilities built into plot, or do I
convert to a dc% in some way, and leverage pict, or... ?

In short, I feel like I should be building on plot/extending plot, I don't
want to reinvent wheels that are already invented, but I'm not yet sure
where the best starting point is. Do I develop a new plot type, dig deeper
into how axes are drawn, or do I do everything with overlays, or ...?

Many thanks,
Matt

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Questions about module encapsulation guarantees

2018-09-12 Thread Matthew Flatt
At Sun, 9 Sep 2018 18:52:57 -0700 (PDT), Jack Firth wrote:
> If I make a symbol with `gensym` (or do anything else that creates a new 
> value that's not `eq?` to any other value) in some module, what are the 
> absolute upper limits on my ability to use that symbol within the module 
> without allowing any other modules to get ahold of the symbol? What do code 
> inspectors, namespaces, sandboxes, eval, `unsafe` APIs, the FFI, etc. make 
> possible for malicious code in external modules?

If you don't change the code inspector, than a third party can get into
the module body's namespace. So, if you bind the gensym with a
definition, that will be easy to see.

If you retain the symbol only through a closure, as cwebber shows, then
getting to the gensym is trickier, but it's still possible via unsafe
APIs. Setting the code inspector should prevent access to unsafe APIs
or anything else that can inspect arbitrary data --- modulo bugs in the
runtime system, of course, but also any bugs in a module that might
make use of unsafe features and get loaded before the code inspector is
changed.

> Context: I'm exploring a "contract witness" idea whose implementation 
> currently relies on the eq?-ness of opaque struct instances for security. 
> But I vaguely recall hearing once that the The Only Way To Be Sure when it 
> comes to struct encapsulation is to put the definition of a struct inside a 
> lambda, otherwise some sort of nebulous "bad things" are possible in 
> external code that wants to break the invariants of  a struct type.

The only difference between being under a `lambda` and not should be
whether the relevant module or top-level namespace is accessible to the
code that you don't trust. Changing the code inspector disables
`module->namespace`.

Meanwhile, access to the struct content otherwise would need a more
powerful inspector (i.e., you don't have to change the inspector, but
merely refrain from changing it to an ancestor of the one used to
create the structure type).

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Sealers/unsealers in Racket (Re: [racket-users] Questions about module encapsulation guarantees)

2018-09-10 Thread Christopher Lemmer Webber
Good call, I'll be careful about that in future examples.

David Storrs writes:

> This is a very cool thing, but may I suggest choosing a different name than
> 'can'?  '(can-unseal lunch)' reads less like a verb and more like a
> predicate where someone forgot the '?' -- "Are you able to unseal lunch?"
> as opposed to "Unseal my lunch now".
>
> On Mon, Sep 10, 2018 at 11:09 AM, Christopher Lemmer Webber <
> cweb...@dustycloud.org> wrote:
>
>> Jack Firth writes:
>>
>> > If I make a symbol with `gensym` (or do anything else that creates a new
>> > value that's not `eq?` to any other value) in some module, what are the
>> > absolute upper limits on my ability to use that symbol within the module
>> > without allowing any other modules to get ahold of the symbol? What do
>> code
>> > inspectors, namespaces, sandboxes, eval, `unsafe` APIs, the FFI, etc.
>> make
>> > possible for malicious code in external modules?
>> >
>> > Context: I'm exploring a "contract witness" idea whose implementation
>> > currently relies on the eq?-ness of opaque struct instances for security.
>> > But I vaguely recall hearing once that the The Only Way To Be Sure when
>> it
>> > comes to struct encapsulation is to put the definition of a struct
>> inside a
>> > lambda, otherwise some sort of nebulous "bad things" are possible in
>> > external code that wants to break the invariants of  a struct type.
>>
>> Struct inside a function is certainly a way to do it.  You may be
>> interested in the idea of sealer/unsealer pairs from the object
>> capability world.  I borrowed the implementation of this from Jonathan
>> Rees' W7 code.  Consider this waived into the public domain, under CC0,
>> but also with any potential patents waived under the same terms.
>>
>> Imagine the ability to make a magical canning kit and a can opener,
>> where the cans produced can only be opened by the respective can opener.
>>
>>   ; Create a new sealer / unsealer pair and sealed? predicate
>>   ; sealer-name is optional and just for debugging help
>>   (define (new-seal [sealer-name #f])
>> (define struct-name
>>   (if sealer-name
>>   (string->symbol (string-append "sealed-by-" (symbol->string
>> sealer-name)))
>>   'sealed))
>> (define-values (struct:seal seal sealed? seal-ref seal-set!)
>>   (make-struct-type struct-name #f 1 0))
>> (define unseal
>>   (make-struct-field-accessor seal-ref 0))
>> (values seal unseal sealed?))
>>
>> Now let's try using it:
>>
>>   (define-values (can-sealer can-unseal can-seal?)
>> (new-seal 'canning-factory))
>>
>> The traditional ocap example is to seal tuna, but I'm vegetarian.
>>
>>   (define lunch (seal "chickpea salad"))
>>
>>   lunch ; #
>>
>> I'm in control of the sealer from my little canning factory, I don't
>> give it to anyone else.  Only someone with the matching unsealer can
>> open this can.  I can safely put it in the fridge.
>>
>> I can make sure this can is my lunch, in case I forgot:
>>
>>   (can-sealed? lunch) ; #t
>>
>> And I can get to its contents:
>>
>>   (can-unseal lunch) ; "chickpea salad"
>>
>> Not that this looks a lot like decryption, but with lexical scope only.
>> It's possible I am okay with someone else opening my objects, in which
>> case I might give them the can-sealed? predicate and the can-unseal
>> procedure... then they can open it, but be sure it's from me.  And
>> with that you can more or less implement signatures.
>>
>> BTW, you can do powerful stuff with this... here's an example where
>> you implement digital money:
>>
>>   http://erights.org/elib/capability/ode/ode-capabilities.html
>>
>> Here's the same example from that article, written in Racket code:
>>
>>   (define (make-mint name)
>> (define-values (sealer unsealer sealed?)
>>   (new-seal name))
>> (define/contract mint%
>>   (class/c [make-purse (->m nonnegative-integer? any/c)])
>>   (class* object% (writable<%>)
>> (super-new)
>> (define/public (custom-display p)
>>   (display (format "#<~a mint>" name) p))
>> (define/public (custom-write p)
>>   (custom-display p))
>>
>> (define this-mint this)
>> (define/public (make-purse balance)
>>   (define/contract (decr amount)
>> (-> (and/c (>=/c 0)
>>(lambda (amt)
>>  (<= amt balance)))
>> void?)
>> (set! balance (- balance amount)))
>>   (define/contract purse%
>> (class/c [get-balance (->m integer?)]
>>  [deposit (->m integer? any/c void?)])
>> (class* object% (writable<%>)
>>   (super-new)
>>
>>   (define/public (custom-display p)
>> (display (format "#" balance name) p))
>>   (define/public (custom-write p)
>> (custom-display p))
>>
>>   (define/public (get-balance)
>> balance)
>>   (define/public 

Re: Sealers/unsealers in Racket (Re: [racket-users] Questions about module encapsulation guarantees)

2018-09-10 Thread Christopher Lemmer Webber
Matthias Felleisen writes:

>> On Sep 10, 2018, at 10:09 AM, Christopher Lemmer Webber 
>>  wrote:
>>
>> Jack Firth writes:
>>
>>> If I make a symbol with `gensym` (or do anything else that creates a new
>>> value that's not `eq?` to any other value) in some module, what are the
>>> absolute upper limits on my ability to use that symbol within the module
>>> without allowing any other modules to get ahold of the symbol? What do code
>>> inspectors, namespaces, sandboxes, eval, `unsafe` APIs, the FFI, etc. make
>>> possible for malicious code in external modules?
>>>
>>> Context: I'm exploring a "contract witness" idea whose implementation
>>> currently relies on the eq?-ness of opaque struct instances for security.
>>> But I vaguely recall hearing once that the The Only Way To Be Sure when it
>>> comes to struct encapsulation is to put the definition of a struct inside a
>>> lambda, otherwise some sort of nebulous "bad things" are possible in
>>> external code that wants to break the invariants of  a struct type.
>>
>> Struct inside a function is certainly a way to do it.  You may be
>> interested in the idea of sealer/unsealer pairs from the object
>> capability world.  I borrowed the implementation of this from Jonathan
>> Rees' W7 code.  Consider this waived into the public domain, under CC0,
>> but also with any potential patents waived under the same terms.
>
> Does this really differ from Jim Morris’s sealing?

Not only does it not differ, it's cited on the page... this is just
an implementation :)

>From http://erights.org/elib/capability/ode/ode-capabilities.html :

> Two common forms of rights amplification are sibling communication
> [Hardy, Gosling96, Shalit96] and sealer/unsealer pairs [Morris73,
> Miller87, Tribble95 Appendix D, Rees96]. E primitively provides
> sealer/unsealer pairs. The money example below builds sibling
> communication from sealer/unsealer pairs.

which links to:

  http://www.erights.org/history/morris73.pdf

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Sealers/unsealers in Racket (Re: [racket-users] Questions about module encapsulation guarantees)

2018-09-10 Thread David Storrs
This is a very cool thing, but may I suggest choosing a different name than
'can'?  '(can-unseal lunch)' reads less like a verb and more like a
predicate where someone forgot the '?' -- "Are you able to unseal lunch?"
as opposed to "Unseal my lunch now".

On Mon, Sep 10, 2018 at 11:09 AM, Christopher Lemmer Webber <
cweb...@dustycloud.org> wrote:

> Jack Firth writes:
>
> > If I make a symbol with `gensym` (or do anything else that creates a new
> > value that's not `eq?` to any other value) in some module, what are the
> > absolute upper limits on my ability to use that symbol within the module
> > without allowing any other modules to get ahold of the symbol? What do
> code
> > inspectors, namespaces, sandboxes, eval, `unsafe` APIs, the FFI, etc.
> make
> > possible for malicious code in external modules?
> >
> > Context: I'm exploring a "contract witness" idea whose implementation
> > currently relies on the eq?-ness of opaque struct instances for security.
> > But I vaguely recall hearing once that the The Only Way To Be Sure when
> it
> > comes to struct encapsulation is to put the definition of a struct
> inside a
> > lambda, otherwise some sort of nebulous "bad things" are possible in
> > external code that wants to break the invariants of  a struct type.
>
> Struct inside a function is certainly a way to do it.  You may be
> interested in the idea of sealer/unsealer pairs from the object
> capability world.  I borrowed the implementation of this from Jonathan
> Rees' W7 code.  Consider this waived into the public domain, under CC0,
> but also with any potential patents waived under the same terms.
>
> Imagine the ability to make a magical canning kit and a can opener,
> where the cans produced can only be opened by the respective can opener.
>
>   ; Create a new sealer / unsealer pair and sealed? predicate
>   ; sealer-name is optional and just for debugging help
>   (define (new-seal [sealer-name #f])
> (define struct-name
>   (if sealer-name
>   (string->symbol (string-append "sealed-by-" (symbol->string
> sealer-name)))
>   'sealed))
> (define-values (struct:seal seal sealed? seal-ref seal-set!)
>   (make-struct-type struct-name #f 1 0))
> (define unseal
>   (make-struct-field-accessor seal-ref 0))
> (values seal unseal sealed?))
>
> Now let's try using it:
>
>   (define-values (can-sealer can-unseal can-seal?)
> (new-seal 'canning-factory))
>
> The traditional ocap example is to seal tuna, but I'm vegetarian.
>
>   (define lunch (seal "chickpea salad"))
>
>   lunch ; #
>
> I'm in control of the sealer from my little canning factory, I don't
> give it to anyone else.  Only someone with the matching unsealer can
> open this can.  I can safely put it in the fridge.
>
> I can make sure this can is my lunch, in case I forgot:
>
>   (can-sealed? lunch) ; #t
>
> And I can get to its contents:
>
>   (can-unseal lunch) ; "chickpea salad"
>
> Not that this looks a lot like decryption, but with lexical scope only.
> It's possible I am okay with someone else opening my objects, in which
> case I might give them the can-sealed? predicate and the can-unseal
> procedure... then they can open it, but be sure it's from me.  And
> with that you can more or less implement signatures.
>
> BTW, you can do powerful stuff with this... here's an example where
> you implement digital money:
>
>   http://erights.org/elib/capability/ode/ode-capabilities.html
>
> Here's the same example from that article, written in Racket code:
>
>   (define (make-mint name)
> (define-values (sealer unsealer sealed?)
>   (new-seal name))
> (define/contract mint%
>   (class/c [make-purse (->m nonnegative-integer? any/c)])
>   (class* object% (writable<%>)
> (super-new)
> (define/public (custom-display p)
>   (display (format "#<~a mint>" name) p))
> (define/public (custom-write p)
>   (custom-display p))
>
> (define this-mint this)
> (define/public (make-purse balance)
>   (define/contract (decr amount)
> (-> (and/c (>=/c 0)
>(lambda (amt)
>  (<= amt balance)))
> void?)
> (set! balance (- balance amount)))
>   (define/contract purse%
> (class/c [get-balance (->m integer?)]
>  [deposit (->m integer? any/c void?)])
> (class* object% (writable<%>)
>   (super-new)
>
>   (define/public (custom-display p)
> (display (format "#" balance name) p))
>   (define/public (custom-write p)
> (custom-display p))
>
>   (define/public (get-balance)
> balance)
>   (define/public (sprout)
> (send this-mint make-purse 0))
>   (define/public (get-decr)
> (sealer decr))
>
>   (define/public (deposit amount src)
> 

Re: Sealers/unsealers in Racket (Re: [racket-users] Questions about module encapsulation guarantees)

2018-09-10 Thread Matthias Felleisen





> On Sep 10, 2018, at 10:09 AM, Christopher Lemmer Webber 
>  wrote:
> 
> Jack Firth writes:
> 
>> If I make a symbol with `gensym` (or do anything else that creates a new
>> value that's not `eq?` to any other value) in some module, what are the
>> absolute upper limits on my ability to use that symbol within the module
>> without allowing any other modules to get ahold of the symbol? What do code
>> inspectors, namespaces, sandboxes, eval, `unsafe` APIs, the FFI, etc. make
>> possible for malicious code in external modules?
>> 
>> Context: I'm exploring a "contract witness" idea whose implementation
>> currently relies on the eq?-ness of opaque struct instances for security.
>> But I vaguely recall hearing once that the The Only Way To Be Sure when it
>> comes to struct encapsulation is to put the definition of a struct inside a
>> lambda, otherwise some sort of nebulous "bad things" are possible in
>> external code that wants to break the invariants of  a struct type.
> 
> Struct inside a function is certainly a way to do it.  You may be
> interested in the idea of sealer/unsealer pairs from the object
> capability world.  I borrowed the implementation of this from Jonathan
> Rees' W7 code.  Consider this waived into the public domain, under CC0,
> but also with any potential patents waived under the same terms.
> 

Does this really differ from Jim Morris’s sealing? 

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Sealers/unsealers in Racket (Re: [racket-users] Questions about module encapsulation guarantees)

2018-09-10 Thread Christopher Lemmer Webber
Jack Firth writes:

> If I make a symbol with `gensym` (or do anything else that creates a new
> value that's not `eq?` to any other value) in some module, what are the
> absolute upper limits on my ability to use that symbol within the module
> without allowing any other modules to get ahold of the symbol? What do code
> inspectors, namespaces, sandboxes, eval, `unsafe` APIs, the FFI, etc. make
> possible for malicious code in external modules?
>
> Context: I'm exploring a "contract witness" idea whose implementation
> currently relies on the eq?-ness of opaque struct instances for security.
> But I vaguely recall hearing once that the The Only Way To Be Sure when it
> comes to struct encapsulation is to put the definition of a struct inside a
> lambda, otherwise some sort of nebulous "bad things" are possible in
> external code that wants to break the invariants of  a struct type.

Struct inside a function is certainly a way to do it.  You may be
interested in the idea of sealer/unsealer pairs from the object
capability world.  I borrowed the implementation of this from Jonathan
Rees' W7 code.  Consider this waived into the public domain, under CC0,
but also with any potential patents waived under the same terms.

Imagine the ability to make a magical canning kit and a can opener,
where the cans produced can only be opened by the respective can opener.

  ; Create a new sealer / unsealer pair and sealed? predicate
  ; sealer-name is optional and just for debugging help
  (define (new-seal [sealer-name #f])
(define struct-name
  (if sealer-name
  (string->symbol (string-append "sealed-by-" (symbol->string 
sealer-name)))
  'sealed))
(define-values (struct:seal seal sealed? seal-ref seal-set!)
  (make-struct-type struct-name #f 1 0))
(define unseal
  (make-struct-field-accessor seal-ref 0))
(values seal unseal sealed?))

Now let's try using it:

  (define-values (can-sealer can-unseal can-seal?)
(new-seal 'canning-factory))

The traditional ocap example is to seal tuna, but I'm vegetarian.

  (define lunch (seal "chickpea salad"))

  lunch ; #

I'm in control of the sealer from my little canning factory, I don't
give it to anyone else.  Only someone with the matching unsealer can
open this can.  I can safely put it in the fridge.

I can make sure this can is my lunch, in case I forgot:

  (can-sealed? lunch) ; #t

And I can get to its contents:

  (can-unseal lunch) ; "chickpea salad"

Not that this looks a lot like decryption, but with lexical scope only.
It's possible I am okay with someone else opening my objects, in which
case I might give them the can-sealed? predicate and the can-unseal
procedure... then they can open it, but be sure it's from me.  And
with that you can more or less implement signatures.

BTW, you can do powerful stuff with this... here's an example where
you implement digital money:

  http://erights.org/elib/capability/ode/ode-capabilities.html

Here's the same example from that article, written in Racket code:

  (define (make-mint name)
(define-values (sealer unsealer sealed?)
  (new-seal name))
(define/contract mint%
  (class/c [make-purse (->m nonnegative-integer? any/c)])
  (class* object% (writable<%>)
(super-new)
(define/public (custom-display p)
  (display (format "#<~a mint>" name) p))
(define/public (custom-write p)
  (custom-display p))

(define this-mint this)
(define/public (make-purse balance)
  (define/contract (decr amount)
(-> (and/c (>=/c 0)
   (lambda (amt)
 (<= amt balance)))
void?)
(set! balance (- balance amount)))
  (define/contract purse%
(class/c [get-balance (->m integer?)]
 [deposit (->m integer? any/c void?)])
(class* object% (writable<%>)
  (super-new)
  
  (define/public (custom-display p)
(display (format "#" balance name) p))
  (define/public (custom-write p)
(custom-display p))

  (define/public (get-balance)
balance)
  (define/public (sprout)
(send this-mint make-purse 0))
  (define/public (get-decr)
(sealer decr))

  (define/public (deposit amount src)
((unsealer (send src get-decr)) amount)
(set! balance (+ balance amount))
(void
  (new purse%
(new mint%))

  (module+ test
(define carol-mint
  (make-mint 'Carol))
(define alice-main-purse
  (send carol-mint make-purse 1000))

(define bob
  (new
   (class object%
 (super-new)
 (define bob-main-purse
   (send carol-mint make-purse 0))
 (define/public (go-on-ride payment)
   (send bob-main-purse deposit 10 payment)
   (displayln 

[racket-users] Questions about module encapsulation guarantees

2018-09-09 Thread Jack Firth
If I make a symbol with `gensym` (or do anything else that creates a new 
value that's not `eq?` to any other value) in some module, what are the 
absolute upper limits on my ability to use that symbol within the module 
without allowing any other modules to get ahold of the symbol? What do code 
inspectors, namespaces, sandboxes, eval, `unsafe` APIs, the FFI, etc. make 
possible for malicious code in external modules?

Context: I'm exploring a "contract witness" idea whose implementation 
currently relies on the eq?-ness of opaque struct instances for security. 
But I vaguely recall hearing once that the The Only Way To Be Sure when it 
comes to struct encapsulation is to put the definition of a struct inside a 
lambda, otherwise some sort of nebulous "bad things" are possible in 
external code that wants to break the invariants of  a struct type.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Questions on functional-setter generator macro

2018-05-28 Thread Greg Hendershott
On Mon, May 28, 2018 at 9:58 AM, David Storrs  wrote:
> O *course* there is.  Lord know, why should I have an original idea
> now?  :P

The Racket package ecosystem is growing to where we need some
volunteers to form a mathic order of Lorites (like in Neal
Stephenson's novel, Anathem).

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Questions on functional-setter generator macro

2018-05-28 Thread David Storrs
On Sat, May 26, 2018 at 3:11 PM, Alexis King  wrote:

> This isn’t a direct answer to your question, but as Matthias notes, my
> struct-update package already implements a macro that generates
> functional setters from structure definitions. Here’s a link to the
> documentation:
>

O *course* there is.  Lord know, why should I have an original idea
now?  :P



> http://docs.racket-lang.org/struct-update/index.html
>
> Of course, that isn’t especially helpful if your goal is to get better
> at authoring macros, not just generate functional setters. For that, you
> might find the (short) source code of struct-update helpful, located
> here:
>
> https://github.com/lexi-lambda/struct-update/blob/
> 8ce456cde8764ae27c348123ec9e01e76826d536/struct-update-lib/
> struct-update/main.rkt


Yes, thank you, this helps.  I hadn't thought about superclass fields.


> Admittedly, your make-functional-setter function does a bit more than
> define-struct-updaters, since it allows for a wrapper function. So I’ll
> also give some brief answers to a few of your unrelated questions.
>

I think we take a different approach -- struct-updaters always specifies a
contract of (-> struct-id? any/c struct-id) whereas make-functional-setters
offers the option to not have a contract or to specify whatever contract
you want.  I'm a firm believer in the idea that you should be allowed to
shoot yourself in the foot if you want the ability to do so.


> > On May 26, 2018, at 10:46, David Storrs 
> > wrote:
> >
> > A) Is there a way to test if a syntax class has a particular attribute
> > before trying to use it?
>
> Yes, use the attribute form. If x is an optional attribute, (attribute
> x) will be #f if the attribute was not bound and the value of the
> attribute if it was bound. If you want, you can change the default value
> to something else other than #f by providing the #:defaults option to
> ~optional.
>

Handy, thanks.


> > B) Alternatively, is there a way to create a null syntax object that
> > expands to nothing?  Not (void), not "", literally nothing.   Then I
> > could have each pattern bind all the attributes via #:with and just
> > have some of them be blank.
>
> Not in an arbitrary context. In a definition context, (begin)
> effectively expands into nothing, since begins are spliced into the
> enclosing context, but in an expression context, you can’t have
> something that expands into nothing.
>
> That said, it sounds like what you might actually want is the template
> and ?? forms from syntax/parse/experimental/template. This allows you
> to write something like this:
>
> (template (foo (?? x)))
>
> The above will be like #'(foo x) if (attribute x) is non-#f, but if it
> is #f, it will be like #'(foo). In Racket 6.12 and earlier, you must use
> the template form for ?? to work, but in Racket 7 and later, ?? will
> also work with the ordinary syntax (aka #') form, so if the word
> “experimental” spooks you, don’t worry about it too much.
>
> Alexis
>
>
This is really helpful, thank you.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Questions on functional-setter generator macro

2018-05-26 Thread Alexis King
This isn’t a direct answer to your question, but as Matthias notes, my
struct-update package already implements a macro that generates
functional setters from structure definitions. Here’s a link to the
documentation:

http://docs.racket-lang.org/struct-update/index.html

Of course, that isn’t especially helpful if your goal is to get better
at authoring macros, not just generate functional setters. For that, you
might find the (short) source code of struct-update helpful, located
here:


https://github.com/lexi-lambda/struct-update/blob/8ce456cde8764ae27c348123ec9e01e76826d536/struct-update-lib/struct-update/main.rkt

Admittedly, your make-functional-setter function does a bit more than
define-struct-updaters, since it allows for a wrapper function. So I’ll
also give some brief answers to a few of your unrelated questions.

> On May 26, 2018, at 10:46, David Storrs 
> wrote:
> 
> A) Is there a way to test if a syntax class has a particular attribute
> before trying to use it?

Yes, use the attribute form. If x is an optional attribute, (attribute
x) will be #f if the attribute was not bound and the value of the
attribute if it was bound. If you want, you can change the default value
to something else other than #f by providing the #:defaults option to
~optional.

> B) Alternatively, is there a way to create a null syntax object that
> expands to nothing?  Not (void), not "", literally nothing.   Then I
> could have each pattern bind all the attributes via #:with and just
> have some of them be blank.

Not in an arbitrary context. In a definition context, (begin)
effectively expands into nothing, since begins are spliced into the
enclosing context, but in an expression context, you can’t have
something that expands into nothing.

That said, it sounds like what you might actually want is the template
and ?? forms from syntax/parse/experimental/template. This allows you
to write something like this:

(template (foo (?? x)))

The above will be like #'(foo x) if (attribute x) is non-#f, but if it
is #f, it will be like #'(foo). In Racket 6.12 and earlier, you must use
the template form for ?? to work, but in Racket 7 and later, ?? will
also work with the ordinary syntax (aka #') form, so if the word
“experimental” spooks you, don’t worry about it too much.

Alexis

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Questions on functional-setter generator macro

2018-05-26 Thread Matthias Felleisen

You may wish to study Alexis’s struct updater package: 
https://github.com/lexi-lambda/struct-update 
 


> On May 26, 2018, at 11:46 AM, David Storrs  wrote:
> 
> Hi folks,
> 
> I am becoming more converted to the way of structs vs hashes as time goes on 
> and so I sat down to write a macro that would generate functional setters as 
> a convenience.  Code is at bottom of email; I'd appreciate suggestions on how 
> to improve it, in particular better ways of handling macros that have 
> multiple optional parts, e.g.:
>
>(struct foo (bar baz jaz))
>(make-functional-setter foo bar)
>(make-functional-setter foo baz string?)
>(make-functional-setter foo jaz path-string? path-string->string)
> 
> I've seen this handled in two ways:
> 
> 1) define-syntax-class with multiple (pattern ...) clauses, which renders the 
> parsing cleaner and easier to understand.  Handling missing parts is still an 
> issue, since using an attribute that wasn't matched is a syntax error, so my 
> questions:
> 
> A) Is there a way to test if a syntax class has a particular attribute before 
> trying to use it?
> 
> B) Alternatively, is there a way to create a null syntax object that expands 
> to nothing?  Not (void), not "", literally nothing.   Then I could have each 
> pattern bind all the attributes via #:with and just have some of them be 
> blank.
> 
> 
> 2) Alternatively, macros with optional parts can be handled by a series of 
> test cases in a syntax-parse, one for each option.  That ends up with a lot 
> of copy/pasted code between the segments.  I'm getting around this via 
> re-parsing but that feels clumsy.  What is the better way?
> 
> 
> 3) There's something I'm not understanding about providing this thing.  I 
> have it in a file called make_functional_setter.rkt:
> 
> #lang racket
> (require (for-syntax racket/syntax syntax/parse))
> (provide make-functional-setter)
> ; code and comments for make-functional-setter, see bottom of email
> 
> When I (require "../make_functional_setter.rkt") on the CLI racket shell, 
> everything works great.  As soon as I try to require it into a file, it fails:
> 
> Contents of file test.rkt:
> 
> #lang racket
> (struct bar (a b))
> (require "../make_functional_setter.rkt") 
> (make-functional-setter bar a)
> (make-functional-setter bar b path-string? ~a)
> 
> When I do "racket test.rkt" on the command line, I get the following 
> exception:
> 
> bar?: unbound identifier in module
>   context...:
>#(2082 module test 0) #(3901 module) #(3902 module struct 0) #(25633 macro)
>#(25639 use-site) #(25818 local) #(25820 intdef)
>   other binding...:
>#f
>#(2081 module) #(2082 module test 0)
>   in: bar?
>   context...:
>standard-module-name-resolver
> 
> I've been through this in the DrRacket macro stepper but that hasn't helped 
> me any.  (It rarely does.)
> 
> I'm assuming it's a phase issue, so I've played around with for-syntax, 
> for-template, and for-meta but apparently I do not understand phases well 
> enough.
> 
> What could be causing this?
> 
> 
> 
> I've been going through all the macro- and syntax-related docs that I can 
> find, but there's a lot of them and they take a few re-reads to sink in, so 
> there's probably something exactly for this that I haven't seen.
> 
> Code is below and at 
> https://gist.github.com/dstorrs/a53ec8736551eb5745d1d5fd265b5062 
>  in case 
> Gmail mangled the formatting.
> 
> 
> ;; make-functional-setter: macro for generating non-mutating field
> ;; setter functions for a struct
> ;;
> ;; Define a struct:  (struct book (title current-page filepath) #:transparent)
> ;;
> ;; Generate 'set-book-title', 'set-book-current-page', and 
> 'set-book-filepath'.
> ;; All of these take two to four arguments: the 'book' struct to update, the 
> ;; new value, an optional contract, and an optional wrapper function.
> ;;
> ;;(make-functional-setter book title)
> ;;(make-functional-setter book current-page  exact-positive-integer?)
> ;;(make-functional-setter book filepath  path-string?
> path-string->string)
> ;;
> ;; Details:
> ;;set-book-title   accepts any value, regardless of sensibility
> ;;set-book-current-pageaccepts only exact-positive-integer?s, else 
> contract violation
> ;;set-book-filepathaccepts only path-string?s, converts to string 
> before storing
> ;;
> ;; Examples:
> ;;(define b (book "Foundation" 297 (build-path "/foo/bar")))
> ;;b; (book "Foundation" 
> 297 "/foo/bar")
> ;;(set-book-title b (hash)); (book (hash) 297 
> "/foo/bar")
> ;;(set-book-current-page b 99) ; (book "Foundation" 
> 99 "/foo/bar")
> ;;(set-book-current-page b 'x) ; ERROR!  Contract 
> violation
> ;; 

[racket-users] Questions on functional-setter generator macro

2018-05-26 Thread David Storrs
Hi folks,

I am becoming more converted to the way of structs vs hashes as time goes
on and so I sat down to write a macro that would generate functional
setters as a convenience.  Code is at bottom of email; I'd appreciate
suggestions on how to improve it, in particular better ways of handling
macros that have multiple optional parts, e.g.:

   (struct foo (bar baz jaz))
   (make-functional-setter foo bar)
   (make-functional-setter foo baz string?)
   (make-functional-setter foo jaz path-string? path-string->string)

I've seen this handled in two ways:

1) define-syntax-class with multiple (pattern ...) clauses, which renders
the parsing cleaner and easier to understand.  Handling missing parts is
still an issue, since using an attribute that wasn't matched is a syntax
error, so my questions:

A) Is there a way to test if a syntax class has a particular attribute
before trying to use it?

B) Alternatively, is there a way to create a null syntax object that
expands to nothing?  Not (void), not "", literally nothing.   Then I could
have each pattern bind all the attributes via #:with and just have some of
them be blank.


2) Alternatively, macros with optional parts can be handled by a series of
test cases in a syntax-parse, one for each option.  That ends up with a lot
of copy/pasted code between the segments.  I'm getting around this via
re-parsing but that feels clumsy.  What is the better way?


3) There's something I'm not understanding about providing this thing.  I
have it in a file called make_functional_setter.rkt:

#lang racket
(require (for-syntax racket/syntax syntax/parse))
(provide make-functional-setter)
; code and comments for make-functional-setter, see bottom of email

When I (require "../make_functional_setter.rkt") on the CLI racket shell,
everything works great.  As soon as I try to require it into a file, it
fails:

Contents of file test.rkt:

#lang racket
(struct bar (a b))
(require "../make_functional_setter.rkt")
(make-functional-setter bar a)
(make-functional-setter bar b path-string? ~a)

When I do "racket test.rkt" on the command line, I get the following
exception:

bar?: unbound identifier in module
  context...:
   #(2082 module test 0) #(3901 module) #(3902 module struct 0) #(25633
macro)
   #(25639 use-site) #(25818 local) #(25820 intdef)
  other binding...:
   #f
   #(2081 module) #(2082 module test 0)
  in: bar?
  context...:
   standard-module-name-resolver

I've been through this in the DrRacket macro stepper but that hasn't helped
me any.  (It rarely does.)

I'm assuming it's a phase issue, so I've played around with for-syntax,
for-template, and for-meta but apparently I do not understand phases well
enough.

What could be causing this?



I've been going through all the macro- and syntax-related docs that I can
find, but there's a lot of them and they take a few re-reads to sink in, so
there's probably something exactly for this that I haven't seen.

Code is below and at
https://gist.github.com/dstorrs/a53ec8736551eb5745d1d5fd265b5062 in case
Gmail mangled the formatting.


;; make-functional-setter: macro for generating non-mutating field
;; setter functions for a struct
;;
;; Define a struct:  (struct book (title current-page filepath)
#:transparent)
;;
;; Generate 'set-book-title', 'set-book-current-page', and
'set-book-filepath'.
;; All of these take two to four arguments: the 'book' struct to update,
the
;; new value, an optional contract, and an optional wrapper function.
;;
;;(make-functional-setter book title)
;;(make-functional-setter book current-page  exact-positive-integer?)
;;(make-functional-setter book filepath  path-string?
 path-string->string)
;;
;; Details:
;;set-book-title   accepts any value, regardless of sensibility
;;set-book-current-pageaccepts only exact-positive-integer?s, else
contract violation
;;set-book-filepathaccepts only path-string?s, converts to
string before storing
;;
;; Examples:
;;(define b (book "Foundation" 297 (build-path "/foo/bar")))
;;b; (book "Foundation"
297 "/foo/bar")
;;(set-book-title b (hash)); (book (hash) 297
"/foo/bar")
;;(set-book-current-page b 99) ; (book "Foundation"
99 "/foo/bar")
;;(set-book-current-page b 'x) ; ERROR!  Contract
violation
;;(set-book-filepath b (build-path "/foo")); (book "Foundation"
297 "/foo")
;;
(define-syntax (make-functional-setter stx)
  (syntax-parse stx
; First, grab the name of the struct and the field we're making
; this for.  We'll build some stuff here then re-parse instead of
; copy/pasting for every pattern match
[(_ type-name field-name ignored ...)
 (with-syntax* ([func-name   (format-id #'type-name "set-~a-~a"
#'type-name #'field-name)]
[func-header #'(func-name the-struct val)]
[definer #'define]

Re: [racket-users] Questions on HtDP 2e, Ex. 356

2017-07-19 Thread Matthias Felleisen

Hi Ben, 

as Jens has pointed out, it pays off to read the context of an exercise (like 
in the real world). The second exercise states 

> If the terminology poses any difficulties, do re-read BSL Grammar.

where “BSL Grammar” is a link that explains BSL via a data definition (that’s 
what a grammar is) and explains the terminology of 

— function application 
— function definition 

which are TWO distinct concepts. Sadly, math teachers gloss over this 
distinctions in school (if they know it) and other teachers do not know it. In 
computing, especially programming, precise terminology is critical so that you 
can efficiently communicate with others. After all, programming is a people 
discipline not a cubicle sport (even if you do sit in a cubicle in many shops; 
but that’s because of many other problems). 

So for your sake, I urge you to catch up on Intermezzo I so that you understand 
these distinctions. 

Having said that, I will move this sentence (hint) to the preceding exercise so 
that others don’t get hung up on this terminology issue. 

— Matthias


p.s. This explanation does probably not apply to people who just wish to learn 
to code and remain cheap rent-a-coders. But that’s a path they should choose 
after experiencing this fate for a couple of years in a company. 







> On Jul 12, 2017, at 10:58 PM, Ben Morin  wrote:
> 
> Hi Jens
> 
> Thanks for the reply.
> 
> I was working through it with some free time today, and I think my data 
> definition works. The other big problem I was having was the body for the 
> user-defined function. As you said, ex 356 isn't concerned about that aspect. 
> This is what was/is throwing me off. My assumption is now that I would define 
> the body of an arbitrary function in the arguments of eval-definition1.
> 
> For instance:
> 
> (eval-definition1 '(by-five (make-add 1 1)) 'by-five 'p (make-mul 5 'p))
> 
> The first arg being the expression to evaluate.
> Second is the function name being evaluated for.
> Third being 'by-five's parameter.
> Fourth being the actual body of 'by-five.
> 
> The result of eval-definition1 then being 10.
> 
> I hope this is heading in the right direction.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Questions on HtDP 2e, Ex. 356

2017-07-13 Thread Jens Axel Søgaard
> I hope this is heading in the right direction.

Looks fine to me.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Questions on HtDP 2e, Ex. 356

2017-07-12 Thread Ben Morin
Hi Jens

Thanks for the reply.

I was working through it with some free time today, and I think my data 
definition works. The other big problem I was having was the body for the 
user-defined function. As you said, ex 356 isn't concerned about that aspect. 
This is what was/is throwing me off. My assumption is now that I would define 
the body of an arbitrary function in the arguments of eval-definition1.

For instance:

(eval-definition1 '(by-five (make-add 1 1)) 'by-five 'p (make-mul 5 'p))

The first arg being the expression to evaluate.
Second is the function name being evaluated for.
Third being 'by-five's parameter.
Fourth being the actual body of 'by-five.

The result of eval-definition1 then being 10.

I hope this is heading in the right direction.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Questions on HtDP 2e, Ex. 356

2017-07-12 Thread Jens Axel Søgaard
Hi Ben,

Adding syntax for both applications, user defined functions and adding
evaluation of these in the same execise, is a bit much.
It is therefore split up into exercise 356, 357, 358 and 359.

Exercise 356 is only about extending the data definition such that
applications can be represented.
In excercise 357 eval-definition1 receives as one of its argument the
function (including the body) of the user defined function.

/Jens Axel


2017-07-12 15:41 GMT+02:00 Ben Morin :

> I've been working my way through HtDP on and off over the past several
> months. I've generally been able to figure it out on my own (even if it
> takes awhile). However, Intertwined Data has given me a couple problems
> that I just can't seem to wrap my head around.
>
> The major one is 21.3 "Interpreting Functions."
> http://www.ccs.neu.edu/home/matthias/HtDP2e/Draft/part_
> four.html#%28counter._%28exercise._ex~3absl-one-def%29%29
>
> Exercise 356 asks to extend the data definition of
>
> ; A BSL-var-expr is one of:
> ; – Number
> ; – Symbol
> ; – (make-add BSL-var-expr BSL-var-expr)
> ; – (make-mul BSL-var-expr BSL-var-expr)
>
> to "include application of a programmer-defined function," which is a
> function name and expression, My first thought was something in line with
> the rest of the chapter:
>
> (make-func [name expr])
>
> But looking at examples like (k (+ 1 1)) makes it seem like the data
> definition should just incorporate a name and an argument. Where does the
> function's body come into play?
>
> Exercise 357 then asks to create a function with the following parameters:
> - a BSL-Func-Expr, would this be just (k (+ 1 1))?
> - the function name, k?
> - the function parameters, (+ 1 1) is the argument?
> - the function body, ... (+ 1 1)?
>
> How can a user-defined function like "k" be evaluated if only its argument
> is known?
>
> I feel like I read this, understand the words, but can't comprehend the
> sentences.
>
>
> Thanks in advance
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-- 
Jens Axel Søgaard

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Questions on HtDP 2e, Ex. 356

2017-07-12 Thread Ben Morin
I've been working my way through HtDP on and off over the past several months. 
I've generally been able to figure it out on my own (even if it takes awhile). 
However, Intertwined Data has given me a couple problems that I just can't seem 
to wrap my head around.

The major one is 21.3 "Interpreting Functions."
http://www.ccs.neu.edu/home/matthias/HtDP2e/Draft/part_four.html#%28counter._%28exercise._ex~3absl-one-def%29%29

Exercise 356 asks to extend the data definition of

; A BSL-var-expr is one of: 
; – Number
; – Symbol 
; – (make-add BSL-var-expr BSL-var-expr)
; – (make-mul BSL-var-expr BSL-var-expr)

to "include application of a programmer-defined function," which is a function 
name and expression, My first thought was something in line with the rest of 
the chapter:

(make-func [name expr])

But looking at examples like (k (+ 1 1)) makes it seem like the data definition 
should just incorporate a name and an argument. Where does the function's body 
come into play?

Exercise 357 then asks to create a function with the following parameters: 
- a BSL-Func-Expr, would this be just (k (+ 1 1))?
- the function name, k?
- the function parameters, (+ 1 1) is the argument?
- the function body, ... (+ 1 1)?

How can a user-defined function like "k" be evaluated if only its argument is 
known?

I feel like I read this, understand the words, but can't comprehend the 
sentences.


Thanks in advance

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Questions about quad

2016-05-19 Thread Daniel Prager
Hi Matthew

I'm having a play with your quad type-setting library, which looks very
promising as a way to generate typeset pdfs from Racket without invoking
LaTeX.

It looks really promising.

Quick questions (which may also prompt a light update to the docs):

   - How do I require modules? @(require ...) gives an error
   - How do I include graphics (e.g. diagrams) generated from 2htdp/image
   or pict?
   - How do I change the margins?
   - How do I programatically generate a pdf (rather than pressing one of
   the buttons)
   - How do I set the number of columns?


Cheers

Dan

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Questions about implementing a Lisp-2

2016-04-12 Thread Hendrik Boom
On Tue, Apr 12, 2016 at 08:23:52PM -0700, Josh Tilles wrote:
> On Monday, April 11, 2016 at 8:41:54 PM UTC-4, Neil Van Dyke wrote:
> > I would first decide whether and how I want functions and variables 
> > provided by modules in this language, to be usable from modules in other 
> > `#lang`s.  That narrows down the options of how to do it.
> Very good point. To be honest, usability from other `#lang`s wasn't a 
> priority for me—at least not in the first iteration of this little project of 
> mine.
> 
> > If you're writing an Emacs Lisp implementation,
> I'm not writing an Emacs Lisp implementation; I'm writing an 
> implementation of KLambda, a tiny (the "K" stands for "Kernel") and 
> rather idiosyncratic Lisp.

Good!

> 
> > I would look at what Guile has done.  And also consider whether the
> > dynamically-scoped and buffer-local variables affect how you solve
> > your Lisp-2 namespaces problem.

Emacs Lisp got lexical scoping wrong -- they forgot about it 
completely.  There seems to be a project to get elisp to do lexical 
scoping, but given the amount of code that is written in elisp, 
someone I spoke to thinks it may take another ten years or so to 
accomplis it.

Don't make the same mistake!

-- hendrik

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Questions about implementing a Lisp-2

2016-04-12 Thread Neil Van Dyke

Josh Tilles wrote on 04/12/2016 11:23 PM:
I'm writing an implementation of KLambda, a tiny (the "K" stands for 
"Kernel") and rather idiosyncratic Lisp. 


This is the best URL I found for what I think is KLambda: 
http://shenlanguage.org/Documentation/shendoc.htm#Kl



I had expected there to be a way to use Racket's existing features to implement 
KLambda.


I'm sure there's more than one way, and some ways I haven't thought of.

For the first shot, I suggest prefixing for one of the namespaces, like 
Matthew Butterick suggested.  Perhaps slightly better, prefix for both 
namespaces, and I think you might catch errors in your early 
implementation sooner (i.e., if your implementation ever sees an 
unprefixed identifier where you shouldn't, you know it's an error, not 
just that it's an identifier from the namespace that didn't get 
prefixed.  Later, if you start importing from other `#lang`s, absence of 
prefixing could be a cue for a different calling convention you need to 
use.  (Though, if you ever provide from `#lang klambda` to other langs, 
you might end up preferring that function namespace be unprefixed, since 
that's the more common thing to provide.  And then maybe it's easier for 
providing to other `#lang klambda` modules, as well, if you only prefix 
the *non*-function namespace.)  This prefixing is a quick and easy 
method, but it might work sufficiently well.


If you don't leverage the Racket binding model by using prefixing or 
similar identifier kludge, then I think you have to start maintaining 
the model yourself.  I wouldn't do that without a good reason (like, if 
KLambda's model differed significantly from Racket in ways other than 
just being a Lisp-2).


Good luck,

Neil V.

--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Questions about implementing a Lisp-2

2016-04-12 Thread Josh Tilles
On Monday, April 11, 2016 at 8:41:54 PM UTC-4, Neil Van Dyke wrote:
> I would first decide whether and how I want functions and variables 
> provided by modules in this language, to be usable from modules in other 
> `#lang`s.  That narrows down the options of how to do it.
Very good point. To be honest, usability from other `#lang`s wasn't a priority 
for me—at least not in the first iteration of this little project of mine.

> If you're writing an Emacs Lisp implementation,
I'm not writing an Emacs Lisp implementation; I'm writing an implementation of 
KLambda, a tiny (the "K" stands for "Kernel") and rather idiosyncratic Lisp.

> I would look at what Guile has done.  And also consider whether the
> dynamically-scoped and buffer-local variables affect how you solve
> your Lisp-2 namespaces problem.
The Guile-ELisp connection is an interesting one which I had already been 
interested in eventually learning more about, but I had expected there to be a 
way to use Racket's existing features to implement KLambda.


Thanks Neil!
-Josh

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Questions about implementing a Lisp-2

2016-04-11 Thread Matthew Butterick
Messing with `current-namespace` seems like overkill, though maybe this 
approach is too naive for your needs, which just involves hiding the `defun` 
identifiers in the current namespace with a `defun:` prefix, then using `#%app` 
to pull them out again.


#lang racket
(require rackunit (for-syntax racket/syntax) (prefix-in rb: (only-in 
racket/base #%app)))

(define-syntax (defun stx)
  (syntax-case stx ()
[(_ name (arg ...) body0 body ...)
 (with-syntax ([defun:name (format-id stx "defun:~a" #'name)])
   #'(define (defun:name arg ...)
   body0
   body ...))]))

(define-syntax-rule (defvar name value)
  (define name value))

(define-syntax (#%app stx)
  (syntax-case stx ()
[(_ proc-name args ...)
 (with-syntax ([defun:proc-name (format-id stx "defun:~a" #'proc-name)])
   (if (identifier-binding #'defun:proc-name)
   #'(rb:#%app defun:proc-name args ...)
   #'(rb:#%app proc-name args ...)))]))


;; Let's see whether these work.
(defvar example 'an-arbitrary-symbol)
(defun example (sym) (symbol->string sym))
(check-equal? (example example) "an-arbitrary-symbol")
(check-equal? (symbol->string example) "an-arbitrary-symbol")





On Apr 11, 2016, at 4:51 PM, Josh Tilles  wrote:

> Hello Racketeers,
> 
> I come seeking advice. I'm trying to implement a Lisp-2 in Racket, but I've 
> been unsuccessful in my initial attempts.
> 
> My goal is to be able to do something like the following:
> 
> ```
> (defun example (sym)
>  (symbol->string sym))
> 
> (defvar example 'an-arbitrary-symbol)
> 
> (example example)
> ;=> "an-arbitrary-symbol"
> ```
> 
> And my here was my first stab at a solution:
> 
> ```
> #lang racket
> 
> (define-for-syntax functions-ns (make-empty-namespace))
> (define-for-syntax values-ns (make-empty-namespace))
> 
> (define-syntax (defun stx)
>  (syntax-case stx ()
>[(_ name (arg ...) body0 body ...)
> (parameterize ([current-namespace functions-ns])
>   #'(define (name arg ...)
>   body0
>   body ...))]))
> 
> (define-syntax (defvar stx)
>  (syntax-case stx ()
>[(_ name value)
> (parameterize ([current-namespace values-ns])
>   #'(define name value))]))
> 
> ;; Let's see whether these work.
> (defvar example 'an-arbitrary-symbol)
> (defun example (sym) (symbol->string sym))
> (example example)
> ;;=> symbol->string: contract violation
> ;;=>   expected: symbol?
> ;;=>   given: #
> ;;=>   context...:
> ;;=>/opt/homebrew-cask/Caskroom/racket/6.4/Racket 
> v6.4/collects/racket/private/misc.rkt:87:7
> ```
> 
> I'll be deeply grateful for help you can provide.
> 
> Cheers,
> Josh
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Questions about implementing a Lisp-2

2016-04-11 Thread Neil Van Dyke

Josh Tilles wrote on 04/11/2016 07:51 PM:

I'm trying to implement a Lisp-2 in Racket,


I would first decide whether and how I want functions and variables 
provided by modules in this language, to be usable from modules in other 
`#lang`s.  That narrows down the options of how to do it.


If you're writing an Emacs Lisp implementation, I would look at what 
Guile has done.  And also consider whether the dynamically-scoped and 
buffer-local variables affect how you solve your Lisp-2 namespaces problem.


Neil V.

--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Questions about implementing a Lisp-2

2016-04-11 Thread Josh Tilles
Hello Racketeers,

I come seeking advice. I'm trying to implement a Lisp-2 in Racket, but I've 
been unsuccessful in my initial attempts.

My goal is to be able to do something like the following:

```
(defun example (sym)
  (symbol->string sym))

(defvar example 'an-arbitrary-symbol)

(example example)
;=> "an-arbitrary-symbol"
```

And my here was my first stab at a solution:

```
#lang racket

(define-for-syntax functions-ns (make-empty-namespace))
(define-for-syntax values-ns (make-empty-namespace))

(define-syntax (defun stx)
  (syntax-case stx ()
[(_ name (arg ...) body0 body ...)
 (parameterize ([current-namespace functions-ns])
   #'(define (name arg ...)
   body0
   body ...))]))

(define-syntax (defvar stx)
  (syntax-case stx ()
[(_ name value)
 (parameterize ([current-namespace values-ns])
   #'(define name value))]))

;; Let's see whether these work.
(defvar example 'an-arbitrary-symbol)
(defun example (sym) (symbol->string sym))
(example example)
;;=> symbol->string: contract violation
;;=>   expected: symbol?
;;=>   given: #
;;=>   context...:
;;=>/opt/homebrew-cask/Caskroom/racket/6.4/Racket 
v6.4/collects/racket/private/misc.rkt:87:7
```

I'll be deeply grateful for help you can provide.

Cheers,
Josh

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] questions about racket [new user]

2015-07-03 Thread marcio esper
Hello,

I am new here. using racket a very short time.

I install racket on linux mint 17 64bit, I was using it on windows 7 The deb 
package work fine, more fast than in windows. very good version.

When I create a executable on linux, it create a tgz archive with the bin and 
libs inside.

In windows, its ok, it create a exe with the dll, to use is like any win 
program.
My question is regarding a linux use of the programs.
The package, for spread it with others users, how will be the procedure to user 
of archive in a machine with linux without racket? just unpack the archive in 
home ?

It will work in androide too?

Question 2.

You have plans to port racket to AmigaOS 4.x too?
Thank you for attention.

Best Regards,

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: [racket-users] Questions: free-identifier=?; literal-id in syntax-case

2015-04-05 Thread Jos Koot
Hi Alexander D. Knauth
 
Thanks, for your very clear answers.
(require (rename-in racket (+ plus))) works too.
A silly mistake of mine to think define would do the same. It does not, of
course.
 
Your argument that a literal-id may occur more than once in a pattern makes
sense.
I'll play with syntax-parse and (_ (~and + (~literal +)) (~literal +)).
May be I am able to make a syntax transformer, say my-syntax-case,
available in expansion-phase,
that does what you have suggested.
 
Thanks again,
Jos Koot
 

  _  

From: racket-users@googlegroups.com [mailto:racket-users@googlegroups.com]
On Behalf Of Alexander D. Knauth
Sent: sábado, 04 de abril de 2015 19:35
To: Jos Koot
Cc: racket-users@googlegroups.com
Subject: Re: [racket-users] Questions: free-identifier=?; literal-id in
syntax-case



On Apr 4, 2015, at 11:22 AM, Jos Koot jos.k...@gmail.com wrote:


The following puzzles me:
 
#lang racket
(define plus +)
(free-identifier=? #'+ #'plus) ; - #f
 
#lang racket
(define-syntax (a stx)
 (syntax-case stx ()
  ((_) (datum-syntax stx (free-identifier=? #'+ #'plus)
(define plus +)
(a) ; - #f
 
#lang racket
(define plus +)
(define-syntax (a stx)
 (syntax-case stx (+)
  ((_ +) #'#t)
  ((_ x) #'#f)))
(a plus) ; - #f
 
I am confused, because I expect #t to be produced in the three above cases.
Obviously I don't understand free-identifier=? well.
Can you help me with that?


Maybe you’re thinking of what happens when you use
(define-syntax plus (make-rename-transformer #’+))
Instead of
(define plus +)


As another question: the docs on syntax-case state:
 
An id that has the same binding as a literal-id matches a syntax object
that is an identifier with the same binding in the sense of
free-identifier=?
file:///C:/Program%20Files/Racket/doc/reference/stxcmp.html?q=syntax-case#%
28def._%28%28quote._~23~25kernel%29._free-identifier~3d~3f%29%29 .
The match does not introduce any
file:///C:/Program%20Files/Racket/doc/reference/stx-patterns.html?q=syntax-
case#%28tech._pattern._variable%29 pattern variables.
 
Why isn't or cant't the match introduce a pattern variable?
Without binding the literal-id as a pattern variable,
location information is lost, for example:
 
#lang racket
(error-print-source-location #t)
(begin-for-syntax (error-print-source-location #t))
(define-syntax (a stx)
 (syntax-case stx (+)
  ((_ +) (raise-syntax-error 'a msg stx #'+ ; ---
(a +)
 
raises a syntax-error as expected, but it highlights + in the line marked
---,
not in the last line.
I would prefer the + in the last line to be highlighted.


I mostly agree with that idea, but there is a reason why it doesn’t do that.
If it did that, then I don’t think you could do things like put multiple of
these in a single pattern, so for instance:
(define-syntax (a stx)
  (syntax-case stx (+)
[(_ + +) (raise-syntax-error ‘a “msg” stx #’+)]))
(a +)
It wouldn’t know which + to bind.

The way I do this which feels a bit clunky like there should be a better
solution:
(define-syntax (a stx)
  (syntax-parse stx
[(_ (~and + (~literal +)) (~literal +)) (raise-syntax-error ‘a “msg” stx
#’+)]))
To tell it specifically to bind it.

To make it a little less verbose, you could define a pattern-expander that
expanded to (~and + (~literal +)), but I’m not sure how to do better than
that.



-- 
You received this message because you are subscribed to the Google Groups
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an
email to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: [racket-users] Questions: free-identifier=?; literal-id in syntax-case

2015-04-05 Thread Jos Koot
I never used syntax-parse before. I have to look into it.
Many thanks, of course,
Jos Koot

  _  

From: racket-users@googlegroups.com [mailto:racket-users@googlegroups.com]
On Behalf Of Alexander D. Knauth
Sent: domingo, 05 de abril de 2015 15:08
To: Jos Koot
Cc: racket-users@googlegroups.com
Subject: Re: [racket-users] Questions: free-identifier=?; literal-id in
syntax-case



On Apr 5, 2015, at 4:07 AM, Jos Koot jos.k...@gmail.com wrote:


Your argument that a literal-id may occur more than once in a pattern makes
sense.
I'll play with syntax-parse and (_ (~and + (~literal +)) (~literal +)).
May be I am able to make a syntax transformer, say my-syntax-case,
available in expansion-phase,
that does what you have suggested.
 
Thanks again,
Jos Koot


You could also use this, from Ryan Culpepper's reply on another thread:
#lang racket
(require (for-syntax syntax/parse))
(define-syntax (a stx)
 (syntax-parse stx #:literals (+)
  [(_ op:+) (raise-syntax-error 'a msg stx #'op)]))
(a +)



  _  

On Apr 4, 2015, at 11:22 AM, Jos Koot jos.k...@gmail.com wrote:


As another question: the docs on syntax-case state:

 
An id that has the same binding as a literal-id matches a syntax object
that is an identifier with the same binding in the sense of
free-identifier=?
file:///C:/Program%20Files/Racket/doc/reference/stxcmp.html?q=syntax-case#%
28def._%28%28quote._~23~25kernel%29._free-identifier~3d~3f%29%29 .
The match does not introduce any
file:///C:/Program%20Files/Racket/doc/reference/stx-patterns.html?q=syntax-
case#%28tech._pattern._variable%29 pattern variables.
 
Why isn't or cant't the match introduce a pattern variable?
Without binding the literal-id as a pattern variable,
location information is lost, for example:
 
#lang racket
(error-print-source-location #t)
(begin-for-syntax (error-print-source-location #t))
(define-syntax (a stx)
 (syntax-case stx (+)
  ((_ +) (raise-syntax-error 'a msg stx #'+ ; ---
(a +)
 
raises a syntax-error as expected, but it highlights + in the line marked
---,
not in the last line.
I would prefer the + in the last line to be highlighted.


I mostly agree with that idea, but there is a reason why it doesn't do that.
If it did that, then I don't think you could do things like put multiple of
these in a single pattern, so for instance:
(define-syntax (a stx)
  (syntax-case stx (+)
[(_ + +) (raise-syntax-error 'a msg stx #'+)]))
(a +)
It wouldn't know which + to bind.

The way I do this which feels a bit clunky like there should be a better
solution:
(define-syntax (a stx)
  (syntax-parse stx
[(_ (~and + (~literal +)) (~literal +)) (raise-syntax-error 'a msg stx
#'+)]))
To tell it specifically to bind it.

To make it a little less verbose, you could define a pattern-expander that
expanded to (~and + (~literal +)), but I'm not sure how to do better than
that.


-- 
You received this message because you are subscribed to the Google Groups
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an
email to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Questions: free-identifier=?; literal-id in syntax-case

2015-04-04 Thread Jos Koot
The following puzzles me:
 
#lang racket
(define plus +)
(free-identifier=? #'+ #'plus) ; - #f
 
#lang racket
(define-syntax (a stx)
 (syntax-case stx ()
  ((_) (datum-syntax stx (free-identifier=? #'+ #'plus)
(define plus +)
(a) ; - #f
 
#lang racket
(define plus +)
(define-syntax (a stx)
 (syntax-case stx (+)
  ((_ +) #'#t)
  ((_ x) #'#f)))
(a plus) ; - #f
 
I am confused, because I expect #t to be produced in the three above cases.
Obviously I don't understand free-identifier=? well.
Can you help me with that?
 
As another question: the docs on syntax-case state:
 
An id that has the same binding as a literal-id matches a syntax object
that is an identifier with the same binding in the sense of
free-identifier=?
file:///C:/Program%20Files/Racket/doc/reference/stxcmp.html?q=syntax-case#%
28def._%28%28quote._~23~25kernel%29._free-identifier~3d~3f%29%29 .
The match does not introduce any
file:///C:/Program%20Files/Racket/doc/reference/stx-patterns.html?q=syntax-
case#%28tech._pattern._variable%29 pattern variables.
 
Why isn't or cant't the match introduce a pattern variable?
Without binding the literal-id as a pattern variable,
location information is lost, for example:
 
#lang racket
(error-print-source-location #t)
(begin-for-syntax (error-print-source-location #t))
(define-syntax (a stx)
 (syntax-case stx (+)
  ((_ +) (raise-syntax-error 'a msg stx #'+ ; ---
(a +)
 
raises a syntax-error as expected, but it highlights + in the line marked
---,
not in the last line.
I would prefer the + in the last line to be highlighted.
 
(I am running DrRacket, version 6.1.1 [3m])
 
Help very much appreciated.
 
Wish all of you a fine easter,
Jos Koot
 

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Questions: free-identifier=?; literal-id in syntax-case

2015-04-04 Thread Alexander D. Knauth

On Apr 4, 2015, at 11:22 AM, Jos Koot jos.k...@gmail.com wrote:

 The following puzzles me:
  
 #lang racket
 (define plus +)
 (free-identifier=? #'+ #'plus) ; - #f
  
 #lang racket
 (define-syntax (a stx)
  (syntax-case stx ()
   ((_) (datum-syntax stx (free-identifier=? #'+ #'plus)
 (define plus +)
 (a) ; - #f
  
 #lang racket
 (define plus +)
 (define-syntax (a stx)
  (syntax-case stx (+)
   ((_ +) #'#t)
   ((_ x) #'#f)))
 (a plus) ; - #f
  
 I am confused, because I expect #t to be produced in the three above cases.
 Obviously I don't understand free-identifier=? well.
 Can you help me with that?

Maybe you’re thinking of what happens when you use
(define-syntax plus (make-rename-transformer #’+))
Instead of
(define plus +)

 As another question: the docs on syntax-case state:
  
 An id that has the same binding as a literal-id matches a syntax object
 that is an identifier with the same binding in the sense of free-identifier=?.
 The match does not introduce any pattern variables.
  
 Why isn't or cant't the match introduce a pattern variable?
 Without binding the literal-id as a pattern variable,
 location information is lost, for example:
  
 #lang racket
 (error-print-source-location #t)
 (begin-for-syntax (error-print-source-location #t))
 (define-syntax (a stx)
  (syntax-case stx (+)
   ((_ +) (raise-syntax-error 'a msg stx #'+ ; ---
 (a +)
  
 raises a syntax-error as expected, but it highlights + in the line marked 
 ---,
 not in the last line.
 I would prefer the + in the last line to be highlighted.

I mostly agree with that idea, but there is a reason why it doesn’t do that.
If it did that, then I don’t think you could do things like put multiple of 
these in a single pattern, so for instance:
(define-syntax (a stx)
  (syntax-case stx (+)
[(_ + +) (raise-syntax-error ‘a “msg” stx #’+)]))
(a +)
It wouldn’t know which + to bind.

The way I do this which feels a bit clunky like there should be a better 
solution:
(define-syntax (a stx)
  (syntax-parse stx
[(_ (~and + (~literal +)) (~literal +)) (raise-syntax-error ‘a “msg” stx 
#’+)]))
To tell it specifically to bind it.

To make it a little less verbose, you could define a pattern-expander that 
expanded to (~and + (~literal +)), but I’m not sure how to do better than that.


-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.