Re: [racket-users] snake game

2019-01-23 Thread K H
Hello Or,

The language is not "Pretty Big".

You should be using "Beginning Student with List Abbreviations".

The DrRacket metadata lines referred to by John set the correct language.
In your case you must have changed the language somehow. Or perhaps the
file needs to be saved before the metadata is acted upon.

HTH,

Kieron.


On Wed, Jan 23, 2019 at 12:17 PM 'John Clements' via Racket Users <
racket-users@googlegroups.com> wrote:

> Interesting problem; your screenshot shows header text that should not
> appear in the window, which suggests to me that you copied and pasted the
> text from somewhere else into a buffer where the language level was already
> set. It looks to me like you should do the following:
>
> 1) Delete the first three lines of the file.
> 2) Set the language level to “beginner with list abbreviations”.
> 3) Click “run”
>
> John Clements
>
> > On Jan 23, 2019, at 10:44 AM, orenpa11  wrote:
> >
> > Hi David,
> > Thanks for your swift response ,I simply do not know how to run this
> program.
> > I thought that when I press the run button I should see the snake GUI .
> >
> > Maybe the language is not pretty big ?
> > Thanks,
> > Or
> >
> >
> > On Wednesday, January 23, 2019 at 8:25:32 PM UTC+2, David K. Storrs
> wrote:
> > What happens when you run it?  Are you getting any error messages?
> >
> > On Wed, Jan 23, 2019 at 1:01 PM orenpa11  wrote:
> > >
> > > Hi
> > > I am trying to implemet this code of "snake game "
> > > https://course.ccs.neu.edu/csu211/code/snake-full.ss
> > >
> > > in DrRacket (Pretty big)
> > >  But when I run it it is not working .
> > > any Idea ?
> > >
> > > Thanks
> > > Or
> > >
> > > --
> > > 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...@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] snake game

2019-01-23 Thread K H
It seems the metadata lines added by DrRacket (mentioned by John) are
processed when the a source file is loaded into DrRacket (via the menu
option File/Open), but are not processed if the source code is directly
copied (e.g. from a browser window) into a DrRacket window and then
executed with the 'Run' button.

The metadata includes a #reader directive, e.g.:
(#reader(lib "htdp-beginner-abbr-reader.ss" "lang")((modname snake-full)
...)

This reader directive appears to be silently ignored by DrRacket when the
source is 'Run', even though DrRacket shows "#reader" in red (as when an
error is detected). The actions taken by DrRacket when 'Run' is pressed
seem to depend on the settings in effect when the code is executed, which
could be nothing, or throwing a confusing error.

The solution for the original poster's issue is as John directs; remove the
metadata (i.e. #reader directive) and manually set the language.

However, I feel that DrRacket should recognize and act on (and perhaps also
remove/hide from view) the metadata if the metadata occurs as from a
copy/paste directly into a DrRacket window (e.g. as from a URL). The
current behaviour is, I think, a bug and a trap (perhaps showstopping) for
a new user experimenting with Racket.

Note that the Racket executable seems to process the metadata properly,
understanding the language to use, etc.. so that the code behaves as
intended.

On Wed, Jan 23, 2019 at 12:32 PM K H  wrote:

> Hello Or,
>
> The language is not "Pretty Big".
>
> You should be using "Beginning Student with List Abbreviations".
>
> The DrRacket metadata lines referred to by John set the correct language.
> In your case you must have changed the language somehow. Or perhaps the
> file needs to be saved before the metadata is acted upon.
>
> HTH,
>
> Kieron.
>
>
> On Wed, Jan 23, 2019 at 12:17 PM 'John Clements' via Racket Users <
> racket-users@googlegroups.com> wrote:
>
>> Interesting problem; your screenshot shows header text that should not
>> appear in the window, which suggests to me that you copied and pasted the
>> text from somewhere else into a buffer where the language level was already
>> set. It looks to me like you should do the following:
>>
>> 1) Delete the first three lines of the file.
>> 2) Set the language level to “beginner with list abbreviations”.
>> 3) Click “run”
>>
>> John Clements
>>
>> > On Jan 23, 2019, at 10:44 AM, orenpa11  wrote:
>> >
>> > Hi David,
>> > Thanks for your swift response ,I simply do not know how to run this
>> program.
>> > I thought that when I press the run button I should see the snake GUI .
>> >
>> > Maybe the language is not pretty big ?
>> > Thanks,
>> > Or
>> >
>> >
>> > On Wednesday, January 23, 2019 at 8:25:32 PM UTC+2, David K. Storrs
>> wrote:
>> > What happens when you run it?  Are you getting any error messages?
>> >
>> > On Wed, Jan 23, 2019 at 1:01 PM orenpa11  wrote:
>> > >
>> > > Hi
>> > > I am trying to implemet this code of "snake game "
>> > > https://course.ccs.neu.edu/csu211/code/snake-full.ss
>> > >
>> > > in DrRacket (Pretty big)
>> > >  But when I run it it is not working .
>> > > any Idea ?
>> > >
>> > > Thanks
>> > > Or
>> > >
>> > > --
>> > > 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...@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] Error loading libreadline dll when using readline package

2020-04-09 Thread K H
Thanks for the info, Matthew,

On Thu, Apr 9, 2020 at 7:02 AM Matthew Flatt  wrote:

> I think you probably have the "readline-gpl" package installed. That's
> where the "libreadline-5.dll" comes from in "private/readline-lib.rkt":
>
>
Yes. Prior to installing readline-gpl the file not found was
"libreadline-3.dll". The error message change from "-3.dll" to "-5.dll"
surprised me, and gave me hope that I was going in the right direction ...


>  (define readline-library (ffi-lib "libreadline" '("5" "6" "4" "")))
>

I eventually found that line in ./7.6/share/readline-lib.rkt in the
directory given by (find-config-dir) and was wondering about the ordering.
Is 5,6,4 deliberate, or a typo and really should be 6,5,4?

>
> Even if "7" were added to that list, `ffi-lib` assumes a versioning
> convention that adds "-".
>

I added the "7" and of course discovered discovered the need for "-".

Would "bad things happen" if 'ffi-lib' (actually 'get-ffi-lib' in
ffi/unsafe.rkt) were changed to look for both "-" and no separator? i.e.
look for "-.dll" then ".dll"? Is there a standard for
the hyphen before the version that the cygwin package is breaking?

>
> One solution is to set the
>
>   PLT_READLINE_LIB
>
> environment variable to point to the full path of "libreadline7.dll".
> Note that it will need to be a Windows path, though, not a Cygwin path.
>

Shortly after first posting I discovered PLT_READLINE_LIB.

In a cygwin session, adding the location of "libreadline7.dll" to the path,
and then setting PLT_READLINE_LIB was necessary only once. Subsequent
sessions apparently do not necessarily need the environment variable to be
set in order to find and load the ".dll". Is there some cache that is being
used once the ".dll" has been found and loaded the first time?

>
> Or you could also try copying "libreadline7.dll" to "libreadline.dll"
> (no "7") in the Racket's "lib" directory, but that probably won't work
> if "libreadline7.dll" depends on other libraries. And there's a
> question of whether a Cygwin libreadline will work at all when loaded
> into non-Cygwin Racket. It may work better to get another version of
> the libreadline DLL from somewhere and drop it into Racket's "lib"
> directory.
>

I'm not sure what to expect in a windows (i.e. non-cygwin) session. Indeed
I seem to be experiencing weird and inconsistent behaviour, and perhaps
need to experiment with minGW.

Cheers,

Kieron.


At Thu, 9 Apr 2020 00:49:11 -0600, K H wrote:
> > I'm running on cygwin on Windows 7 and I have the following error when
> > attempting to use the readline package:
> >
> > $ racket -il readline
> > Welcome to Racket v7.6.
> > ffi-lib: couldn't open "libreadline-5.dll" (The specified module could
> not
> > be found.; errid=126)
> > > ,ex
> >
> > I get the same error either from a cygwin bash prompt or from a windows
> cmd
> > shell prompt.
> >
> > The gnu readline installed appears to be at version 7.
> >
> > $ ls -l /usr/x86_64-w64-mingw32/sys-root/mingw/bin/libread*
> > -rwxr-xr-x  /usr/x86_64-w64-mingw32/sys-root/mingw/bin/libreadline7.dll
> >
> > The source at ./share/pkgs/readline-lib/readline/rktrl.rkt seems relevant
> > but I'm not smart enough to figure out exactly what is wrong.
> >
> > Any ideas on how to continue to debug this?
> >
> > Thanks in advance,
> >
> > Kieron.
> >
> > --
> > 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/CAEEP09AXB4aJecs7eskog-RSDoyEeSW
> > z5P_%2B8f4z%2B8%3DS7jEz%3Dw%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/5e8f1cdf.1c69fb81.135cf.f180SMTPIN_ADDED_MISSING%40gmr-mx.google.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/CAEEP09ApsJnoLvh5rVG7td38yKia9faaF_85jwZ_pHpaO58iWg%40mail.gmail.com.


[racket-users] Error loading libreadline dll when using readline package

2020-04-09 Thread K H
I'm running on cygwin on Windows 7 and I have the following error when
attempting to use the readline package:

$ racket -il readline
Welcome to Racket v7.6.
ffi-lib: couldn't open "libreadline-5.dll" (The specified module could not
be found.; errid=126)
> ,ex

I get the same error either from a cygwin bash prompt or from a windows cmd
shell prompt.

The gnu readline installed appears to be at version 7.

$ ls -l /usr/x86_64-w64-mingw32/sys-root/mingw/bin/libread*
-rwxr-xr-x  /usr/x86_64-w64-mingw32/sys-root/mingw/bin/libreadline7.dll

The source at ./share/pkgs/readline-lib/readline/rktrl.rkt seems relevant
but I'm not smart enough to figure out exactly what is wrong.

Any ideas on how to continue to debug this?

Thanks in advance,

Kieron.

-- 
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/CAEEP09AXB4aJecs7eskog-RSDoyEeSWz5P_%2B8f4z%2B8%3DS7jEz%3Dw%40mail.gmail.com.


[racket-users] Debugging "stuck-ghost-mouse-button" problems

2020-04-17 Thread K H
Hi all,

I'm trying to debug my (Windows7, 2-button trackpad) system, specifically,
weird behaviour with the mouse.

To help determine what the actual problem is, I wrote a small Racket GUI
progam, that surprised me with the following output:

object:object:my-frame% type:enter pos:(338,32) buttons:(#f #t #f) mods:(#f
#f #f) keys:()
object:object:list-box% type:enter pos:(337,32) buttons:(#f #f #f) mods:(#f
#f #f) keys:()

The code (given below) has a simple list-box% inside of a frame% and the
frame% overrides on-subwindow-event to receive mouse 'enter and 'leave
events, printing to stdout some information from the mouse event.

The output shows that the mouse was moved into the list-box%, triggering
the two 'enter events, (one for entering the frame%, one for entering the
list-box%) but notice that the mouse-buttons held down and
keyboard-modifiers pressed are different, despite them being part of the
same motion, with no actual mouse buttons pressed and both the shift and
control keys continuously pressed.

The larger problem I'm chasing is under some circumstances the non-existent
middle mouse button gets "stuck" down. This of course gives erratic
behaviour in various programs e.g. left-click on a tab in the tab-bar in
Chrome causes the tab to close rather than give it focus, no  window reacts
as the mouse cursor is moved over their minimize/maximize/close buttons,
nor are those buttons clickable.

A temporary solution I have found that appears to clear the "stuck button"
is to e.g.randomly click on some icons in the windows task bar, until the
minimize/maximize/close buttons of some window again react when the mouse
cursor is moved over them. A more permanent solution is a reboot, which
delays the onset until some as yet unknown trigger. Either way the
"stuck-ghost-mouse-button" situation eventually returns.

Is there a problem in my test code? Any ideas as to the cause of the
weirdness shown in the code output? Why does the second mouse event not
show the same button state and the  and  as pressed?

And any ideas as to the cause of the larger "stuck-ghost-mouse-button" or
how to further determine its cause (my current thinking is that it is
something to do with Chrome, but dunno really).

Thanks in advance,

Cheers,

Kieron.



#lang racket

(require racket/gui)

(define (queued-printf . msg)
  (let {[print-msg msg]}
(queue-callback
  (lambda ()
(apply printf print-msg)
)
  #t)))

(define (output-event-state t e o)
(queued-printf
   (format "object:~a type:~a pos:(~a,~a) buttons:(~a ~a ~a)
mods:(~a ~a ~a) keys:(~a)~n"
   o t
   (send e get-x) (send e get-y)
   (send e get-left-down)
   (send e get-middle-down)
   (send e get-right-down)
   (send e get-mod3-down)
   (send e get-mod4-down)
   (send e get-mod5-down)
   (string-append
 (if (send e get-shift-down) "" "")
 (if (send e get-control-down) "" "")
 (if (send e get-alt-down) "" "")
 (if (send e get-meta-down) "" "")
 (if (send e get-caps-down) "" "")
 

(define my-frame%
  (class frame%
(super-new)
(define/override (on-subwindow-event r e)
  (let ([event-type (send e get-event-type)]
[object-name (object-name r)])
(when (member event-type (list 'enter 'leave))
  (output-event-state event-type e object-name)))
  #f)
))

(define f (new my-frame%
   [label "test list-box"]
   [width 400]
   [height 200]))

(define l (new list-box%
   [parent f]
   [label "options"]
   [choices (list "apple" "pear" "cherry")]
   [stretchable-width #t]
   [stretchable-height #t]))

(send f show #t)

-- 
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/CAEEP09AGHXawE1bQYYmRhP%3D%2Bjp9LTufCP%3DqM-Pmr7hTW77PheA%40mail.gmail.com.


Re: [racket-users] typing variable length argument lists

2020-04-13 Thread K H
 If I understand correctly, the difference to getting the code to type
check was:
> (apply fprintf (cons anomaly (cons message messageargs)))

becomes:
>(apply fprintf anomaly message messageargs)

Since the documentation explains that the arguments to fprintf are
effectively gathered in a list*, could someone explain why the change makes
a difference? Would it the answer depend on whether messagesargs was a
list?.

Also, the first version with the cons's looks strange to me. Is there a
reason why the statement was originally coded that way? Is it perhaps an
artifact from attempting to force the result of list* to produce a list?
regardless of what is the type of of the value passed in messageargs?

Thanks in advance,

Kieron


On Sat, Apr 11, 2020 at 7:43 AM Hendrik Boom  wrote:

> On Fri, Apr 10, 2020 at 08:18:38PM -0400, Jon Zeppieri wrote:
> > (define (unique [list : (Listof Any)] [message : String] .
> > [messageargs : Any *])
> >   ; return the only element of the list, or '() if there is none.
> >   ; Produce message if not just one.
> >   (if (equal? 1 (length list)) (car list)
> >  (begin
> >(apply fprintf anomaly message messageargs)
> >(if (null? list) list (car list)
>
> Thank you.  That worked.
> The change to the apply syntax surprised me.
>
> -- hendrik
>
> >
> > On Fri, Apr 10, 2020 at 7:49 PM Hendrik Boom 
> wrote:
> > >
> > > Trying to convert the following to typed Racket:
> > >
> > > (define (unique list message . messageargs)
> > >   ; return the only element of the list, or '() if there is none.
> > >   ; Produce message if not just one.
> > >   (if (equal? 1 (length list)) (car list)
> > >  (begin
> > >(apply fprintf (cons anomaly (cons message messageargs)))
> > >(if (null? list) list (car list))
> > >)
> > >  )
> > > )
> > >
> > > It's an error message function tat accepts a list to test.
> > > If the test fails it uses fprintf to print a message with the
> > > arguments for the ~s items.
> > >
> > > I got so far, but I don't know what to do with the . messageargs :
> > >
> > > (define (unique [list (Listof Any)] [message : String] . messageargs)
> > >   ; return the only element of the list, or '() if there is none.
> > >   ; Produce message if not just one.
> > >   (if (equal? 1 (length list)) (car list)
> > >  (begin
> > >(apply fprintf (cons anomaly (cons message messageargs)))
> > >(if (null? list) list (car list))
> > >)
> > >  )
> > > )
>
> --
> 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/20200411134316.yff5tg7kwtglcs62%40topoi.pooq.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/CAEEP09AhmxLHeRdOpzpuG7qC9jOuPTrpog92G_3b6nJWwZDzbw%40mail.gmail.com.


Re: [racket-users] typing variable length argument lists

2020-04-13 Thread K H
Thanks Sam, for the explanation.

I was thinking that some information was lacking to the type inference
system, and it helps to see the annotation incantations necessary to fill
in the gap.

Cheers,

Kieron.

On Mon, Apr 13, 2020 at 1:32 PM Sam Tobin-Hochstadt 
wrote:

> The change makes a difference because Typed Racket's type inference
> for `cons` is producing a less-accurate answer than it could. When it
> sees arguments of type `String` and `(Listof Any)`, it decides that
> the result is a `(Listof Any)` instead of a `(Pairof String (Listof
> Any))`.
>
> If you add (excessive) annotation like this:
>
>(apply fprintf (ann (cons (current-output-port) (ann (cons
> message messageargs) (Pairof String (Listof Any
>(Pairof Output-Port (Pairof String (Listof
> Any)
>
> then the expression typechecks as written.
>
> However, I think the use of `apply` without the extra `cons` calls is
> clearer anyway, in addition to being easier for the type checker.
>
> Sam
>
> On Mon, Apr 13, 2020 at 3:22 PM K H  wrote:
> >
> > If I understand correctly, the difference to getting the code to type
> check was:
> > > (apply fprintf (cons anomaly (cons message messageargs)))
> >
> > becomes:
> > >(apply fprintf anomaly message messageargs)
> >
> > Since the documentation explains that the arguments to fprintf are
> effectively gathered in a list*, could someone explain why the change makes
> a difference? Would it the answer depend on whether messagesargs was a
> list?.
> >
> > Also, the first version with the cons's looks strange to me. Is there a
> reason why the statement was originally coded that way? Is it perhaps an
> artifact from attempting to force the result of list* to produce a list?
> regardless of what is the type of of the value passed in messageargs?
> >
> > Thanks in advance,
> >
> > Kieron
> >
> >
> > On Sat, Apr 11, 2020 at 7:43 AM Hendrik Boom 
> wrote:
> >>
> >> On Fri, Apr 10, 2020 at 08:18:38PM -0400, Jon Zeppieri wrote:
> >> > (define (unique [list : (Listof Any)] [message : String] .
> >> > [messageargs : Any *])
> >> >   ; return the only element of the list, or '() if there is none.
> >> >   ; Produce message if not just one.
> >> >   (if (equal? 1 (length list)) (car list)
> >> >  (begin
> >> >(apply fprintf anomaly message messageargs)
> >> >(if (null? list) list (car list)
> >>
> >> Thank you.  That worked.
> >> The change to the apply syntax surprised me.
> >>
> >> -- hendrik
> >>
> >> >
> >> > On Fri, Apr 10, 2020 at 7:49 PM Hendrik Boom 
> wrote:
> >> > >
> >> > > Trying to convert the following to typed Racket:
> >> > >
> >> > > (define (unique list message . messageargs)
> >> > >   ; return the only element of the list, or '() if there is none.
> >> > >   ; Produce message if not just one.
> >> > >   (if (equal? 1 (length list)) (car list)
> >> > >  (begin
> >> > >(apply fprintf (cons anomaly (cons message messageargs)))
> >> > >(if (null? list) list (car list))
> >> > >)
> >> > >  )
> >> > > )
> >> > >
> >> > > It's an error message function tat accepts a list to test.
> >> > > If the test fails it uses fprintf to print a message with the
> >> > > arguments for the ~s items.
> >> > >
> >> > > I got so far, but I don't know what to do with the . messageargs :
> >> > >
> >> > > (define (unique [list (Listof Any)] [message : String] .
> messageargs)
> >> > >   ; return the only element of the list, or '() if there is none.
> >> > >   ; Produce message if not just one.
> >> > >   (if (equal? 1 (length list)) (car list)
> >> > >  (begin
> >> > >(apply fprintf (cons anomaly (cons message messageargs)))
> >> > >(if (null? list) list (car list))
> >> > >)
> >> > >  )
> >> > > )
> >>
> >> --
> >> 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 t