Jos Koot | 1 Jan 2011 11:58
Favicon

problem with choose language and submit bug report

Because DrRacket help/submit bug report does not function, I use this list for the following report.
 
Welcome to DrRacket, version 5.0.99.5--2010-12-31(b2a297a/a) [3m].
Windows 7
 
'Choose language' and 'submit bug report' and some other menu selections of DrRacket result in:
 
HTHEME->C: expected argument of type <non-null `HTHEME' pointer>; given #f
 
 === context ===
C:\Program Files\Racket-Full-5.0.99.5\collects\ffi\unsafe.rkt:1034:12
C:\Program Files\Racket-Full-5.0.99.5\collects\ffi\unsafe\alloc.rkt:24:9
C:\Program Files\Racket-Full-5.0.99.5\collects\mred\private\wx\win32\canvas.rkt:76:3
C:\Program Files\Racket-Full-5.0.99.5\collects\racket\private\class-internal.rkt:3529:0: continue-make-super
C:\Program Files\Racket-Full-5.0.99.5\collects\mred\private\wx\common\canvas-mixin.rkt:115:2
C:\Program Files\Racket-Full-5.0.99.5\collects\racket\private\class-internal.rkt:3529:0: continue-make-super
C:\Program Files\Racket-Full-5.0.99.5\collects\racket\private\class-internal.rkt:3529:0: continue-make-super
C:\Program Files\Racket-Full-5.0.99.5\collects\mred\private\wxwindow.rkt:15:6
C:\Program Files\Racket-Full-5.0.99.5\collects\racket\private\class-internal.rkt:3529:0: continue-make-super
C:\Program Files\Racket-Full-5.0.99.5\collects\mred\private\wxitem.rkt:35:6
C:\Program Files\Racket-Full-5.0.99.5\collects\racket\private\class-internal.rkt:3529:0: continue-make-super
C:\Program Files\Racket-Full-5.0.99.5\collects\mred\private\wxitem.rkt:203:4
C:\Program Files\Racket-Full-5.0.99.5\collects\racket\private\class-internal.rkt:3529:0: continue-make-super
C:\Program Files\Racket-Full-5.0.99.5\collects\mred\private\wxcanvas.rkt:91:4
C:\Program Files\Racket-Full-5.0.99.5\collects\racket\private\class-internal.rkt:3529:0: continue-make-super
C:\Program Files\Racket-Full-5.0.99.5\collects\racket\private\class-internal.rkt:3529:0: continue-make-super
 
Happy new year to all.
Jos
<div>
<div><span class="838304610-01012011">Because DrRacket 
help/submit bug report does not function, I use this list for the following 
report.</span></div>
<div>
<span class="838304610-01012011"></span>&nbsp;</div>
<div><span class="838304610-01012011">Welcome to DrRacket, 
version 5.0.99.5--2010-12-31(b2a297a/a) [3m].</span></div>
<div><span class="838304610-01012011">Windows 
7</span></div>
<div>
<span class="838304610-01012011"></span>&nbsp;</div>
<div><span class="838304610-01012011">'Choose language' 
and 'submit bug report' and some other menu selections of DrRacket result 
in:</span></div>
<div>&nbsp;</div>
<div>HTHEME-&gt;C: expected argument of type 
&lt;non-null `HTHEME' pointer&gt;; given #f</div>
<div>&nbsp;</div>
<div>&nbsp;=== context ===<br>C:\Program 
Files\Racket-Full-5.0.99.5\collects\ffi\unsafe.rkt:1034:12<br>C:\Program 
Files\Racket-Full-5.0.99.5\collects\ffi\unsafe\alloc.rkt:24:9<br>C:\Program 
Files\Racket-Full-5.0.99.5\collects\mred\private\wx\win32\canvas.rkt:76:3<br>C:\Program 
Files\Racket-Full-5.0.99.5\collects\racket\private\class-internal.rkt:3529:0: 
continue-make-super<br>C:\Program 
Files\Racket-Full-5.0.99.5\collects\mred\private\wx\common\canvas-mixin.rkt:115:2<br>C:\Program 
Files\Racket-Full-5.0.99.5\collects\racket\private\class-internal.rkt:3529:0: 
continue-make-super<br>C:\Program 
Files\Racket-Full-5.0.99.5\collects\racket\private\class-internal.rkt:3529:0: 
continue-make-super<br>C:\Program 
Files\Racket-Full-5.0.99.5\collects\mred\private\wxwindow.rkt:15:6<br>C:\Program 
Files\Racket-Full-5.0.99.5\collects\racket\private\class-internal.rkt:3529:0: 
continue-make-super<br>C:\Program 
Files\Racket-Full-5.0.99.5\collects\mred\private\wxitem.rkt:35:6<br>C:\Program 
Files\Racket-Full-5.0.99.5\collects\racket\private\class-internal.rkt:3529:0: 
continue-make-super<br>C:\Program 
Files\Racket-Full-5.0.99.5\collects\mred\private\wxitem.rkt:203:4<br>C:\Program 
Files\Racket-Full-5.0.99.5\collects\racket\private\class-internal.rkt:3529:0: 
continue-make-super<br>C:\Program 
Files\Racket-Full-5.0.99.5\collects\mred\private\wxcanvas.rkt:91:4<br>C:\Program 
Files\Racket-Full-5.0.99.5\collects\racket\private\class-internal.rkt:3529:0: 
continue-make-super<br>C:\Program 
Files\Racket-Full-5.0.99.5\collects\racket\private\class-internal.rkt:3529:0: 
continue-make-super</div>
<div>&nbsp;</div>
<div><span class="838304610-01012011">Happy new year to 
all.</span></div>
<div>
<span class="838304610-01012011"></span>J<span class="838304610-01012011">os</span><br>
</div>
</div>
Sayth Renshaw | 1 Jan 2011 15:03
Picon

Defining Variables in a function

Working through HTDP and I got to this example(below) I created a working function but I reused a function, is there a better way to assign a variable in another function so, for refernce this was the question.

Exercise 4.4.2.   Develop the function tax, which consumes the gross pay and produces the amount of tax owed. For a gross pay of $240 or less, the tax is 0%; for over $240 and $480 or less, the tax rate is 15%; and for any pay over $480, the tax rate is 28%.

My Working solution

;;; Given a gross wage determine the tax that applies taxed in bands
;;; number -> number
;;; less than 240, greater than 240 < 480, greater than 480
(define (tax_pay pay)
  (cond
    [(<= pay 240) 0]
    [(<= pay 480) (* pay 0.15)]
    [(> pay 480) (* pay 0.28)]))

(define (pay hours)
  (* 12 hours))
;;; Calculate netpay (pay - tax)
;;; Pay rate 12 and user input hours
;;; (pay (payrate * hours)) - (pay -(tax (pay * tax percent))
(define (netpay hours)
  (- (pay hours)(tax_pay (pay hours))))

Proposed solution - assign a variable to the pay calculation and reuse it, however it thinks I am redefining the function tax_pay. In embryo this is a better way to crack the egg isn't it?

(define (netpay2 hours)
  (h (pay hours)
     (- h (tax_pay h))))

<div><p>Working through HTDP and I got to this example(below) I created a working function but I reused a function, is there a better way to assign a variable in another function so, for refernce this was the question.<br><br>Exercise 4.4.2.&nbsp;&nbsp; 
Develop the function <span class="variable">tax</span>, which consumes the gross pay and produces
the amount of tax owed. For a gross pay of $240 or less, the tax is 0%; for
over $240 and $480 or less, the tax rate is 15%; and for any pay over
$480, the tax rate is 28%.<br><br>My Working solution<br><br>;;; Given a gross wage determine the tax that applies taxed in bands<br>;;; number -&gt; number<br>;;; less than 240, greater than 240 &lt; 480, greater than 480<br>
(define (tax_pay pay)<br>&nbsp; (cond<br>&nbsp;&nbsp;&nbsp; [(&lt;= pay 240) 0]<br>&nbsp;&nbsp;&nbsp; [(&lt;= pay 480) (* pay 0.15)]<br>&nbsp;&nbsp;&nbsp; [(&gt; pay 480) (* pay 0.28)]))<br><br>(define (pay hours)<br>&nbsp; (* 12 hours))<br>;;; Calculate netpay (pay - tax)<br>
;;; Pay rate 12 and user input hours<br>;;; (pay (payrate * hours)) - (pay -(tax (pay * tax percent)) <br>(define (netpay hours)<br>&nbsp; (- (pay hours)(tax_pay (pay hours))))<br><br>Proposed solution - assign a variable to the pay calculation and reuse it, however it thinks I am redefining the function tax_pay. In embryo this is a better way to crack the egg isn't it?<br><br>(define (netpay2 hours)<br>&nbsp; (h (pay hours)<br>&nbsp;&nbsp;&nbsp;&nbsp; (- h (tax_pay h))))<br></p></div>
gabor papp | 1 Jan 2011 15:57
Picon
Favicon

scheme_make_vector gc macros

We are experiencing some small memory leaks in Fluxus, and I am 
wondering if the garbage collector registration of the following code is 
right. It should return an array of float values as a scheme vector.
I read the part on memory allocation in Inside: Racket C API, but I'm 
not sure how it should be done properly.

Scheme_Object *FloatsToScheme(float *src, unsigned int size)
{
     Scheme_Object *ret=NULL;
     Scheme_Object *tmp=NULL;
     MZ_GC_DECL_REG(2);
     MZ_GC_VAR_IN_REG(0, ret);
     MZ_GC_VAR_IN_REG(1, tmp);
     MZ_GC_REG();
     ret = scheme_make_vector(size, scheme_void);
     for (unsigned int n=0; n<size; n++)
     {
         tmp=scheme_make_double(src[n]);
         SCHEME_VEC_ELS(ret)[n]=tmp;
     }
     MZ_GC_UNREG();
     return ret;
}

Any help would be greatly appreciated.

Best,
Gabor
Matthew Flatt | 1 Jan 2011 16:06
Picon
Favicon
Gravatar

Re: scheme_make_vector gc macros

Assuming that `src' never refers to GCable memory, this looks fine. You
don't really need to register `tmp', but it's ok to do so.

In general, incorrectly registering variables with the GC can easily
produce a crash, but it rarely creates a memory leak. To track down a
leak, it may be helpful to build Racket with `--enable-backtrace' and
use `dump-memory-stats' to get all the paths to a particular kind of
object.

At Sat, 01 Jan 2011 15:57:53 +0100, gabor papp wrote:
> We are experiencing some small memory leaks in Fluxus, and I am 
> wondering if the garbage collector registration of the following code is 
> right. It should return an array of float values as a scheme vector.
> I read the part on memory allocation in Inside: Racket C API, but I'm 
> not sure how it should be done properly.
> 
> Scheme_Object *FloatsToScheme(float *src, unsigned int size)
> {
>      Scheme_Object *ret=NULL;
>      Scheme_Object *tmp=NULL;
>      MZ_GC_DECL_REG(2);
>      MZ_GC_VAR_IN_REG(0, ret);
>      MZ_GC_VAR_IN_REG(1, tmp);
>      MZ_GC_REG();
>      ret = scheme_make_vector(size, scheme_void);
>      for (unsigned int n=0; n<size; n++)
>      {
>          tmp=scheme_make_double(src[n]);
>          SCHEME_VEC_ELS(ret)[n]=tmp;
>      }
>      MZ_GC_UNREG();
>      return ret;
> }
> 
> Any help would be greatly appreciated.
> 
> Best,
> Gabor

Luke Jordan | 1 Jan 2011 16:12
Picon
Gravatar

Re: Defining Variables in a function

You're thinking on the right lines.  The book teaches to avoid recalculating values that are used more than once.  However the method that's used for this isn't introduced until chapter 18.  Check it out or just work according to what the book has made available to you at a given point and trust that in time all will be revealed.


Luke

On Sat, Jan 1, 2011 at 08:03, Sayth Renshaw <flebber.crue-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Working through HTDP and I got to this example(below) I created a working function but I reused a function, is there a better way to assign a variable in another function so, for refernce this was the question.

Exercise 4.4.2.   Develop the function tax, which consumes the gross pay and produces the amount of tax owed. For a gross pay of $240 or less, the tax is 0%; for over $240 and $480 or less, the tax rate is 15%; and for any pay over $480, the tax rate is 28%.

My Working solution

;;; Given a gross wage determine the tax that applies taxed in bands
;;; number -> number
;;; less than 240, greater than 240 < 480, greater than 480
(define (tax_pay pay)
  (cond
    [(<= pay 240) 0]
    [(<= pay 480) (* pay 0.15)]
    [(> pay 480) (* pay 0.28)]))

(define (pay hours)
  (* 12 hours))
;;; Calculate netpay (pay - tax)
;;; Pay rate 12 and user input hours
;;; (pay (payrate * hours)) - (pay -(tax (pay * tax percent))
(define (netpay hours)
  (- (pay hours)(tax_pay (pay hours))))

Proposed solution - assign a variable to the pay calculation and reuse it, however it thinks I am redefining the function tax_pay. In embryo this is a better way to crack the egg isn't it?

(define (netpay2 hours)
  (h (pay hours)
     (- h (tax_pay h))))

_________________________________________________
 For list-related administrative tasks:
 http://lists.racket-lang.org/listinfo/users

<div>
<p>You're thinking on the right lines. &nbsp;The book teaches to avoid recalculating values that are used more than once. &nbsp;However the method that's used for this isn't introduced until chapter 18. &nbsp;Check it out or just work according to what the book has made available to you at a given point and trust that in time all will be revealed.</p>
<div>

<br>
</div>
<div>Luke<br><br><div class="gmail_quote">On Sat, Jan 1, 2011 at 08:03, Sayth Renshaw <span dir="ltr">&lt;<a href="mailto:flebber.crue <at> gmail.com">flebber.crue@...</a>&gt;</span> wrote:<br><blockquote class="gmail_quote">

Working through HTDP and I got to this example(below) I created a working function but I reused a function, is there a better way to assign a variable in another function so, for refernce this was the question.<br><br>Exercise 4.4.2.&nbsp;&nbsp; 
Develop the function <span>tax</span>, which consumes the gross pay and produces
the amount of tax owed. For a gross pay of $240 or less, the tax is 0%; for
over $240 and $480 or less, the tax rate is 15%; and for any pay over
$480, the tax rate is 28%.<br><br>My Working solution<br><br>;;; Given a gross wage determine the tax that applies taxed in bands<br>;;; number -&gt; number<br>;;; less than 240, greater than 240 &lt; 480, greater than 480<br>

(define (tax_pay pay)<br>&nbsp; (cond<br>&nbsp;&nbsp;&nbsp; [(&lt;= pay 240) 0]<br>&nbsp;&nbsp;&nbsp; [(&lt;= pay 480) (* pay 0.15)]<br>&nbsp;&nbsp;&nbsp; [(&gt; pay 480) (* pay 0.28)]))<br><br>(define (pay hours)<br>&nbsp; (* 12 hours))<br>;;; Calculate netpay (pay - tax)<br>

;;; Pay rate 12 and user input hours<br>;;; (pay (payrate * hours)) - (pay -(tax (pay * tax percent)) <br>(define (netpay hours)<br>&nbsp; (- (pay hours)(tax_pay (pay hours))))<br><br>Proposed solution - assign a variable to the pay calculation and reuse it, however it thinks I am redefining the function tax_pay. In embryo this is a better way to crack the egg isn't it?<br><br>(define (netpay2 hours)<br>&nbsp; (h (pay hours)<br>&nbsp;&nbsp;&nbsp;&nbsp; (- h (tax_pay h))))<br><br>_________________________________________________<br>
 &nbsp;For list-related administrative tasks:<br>
 &nbsp;<a href="http://lists.racket-lang.org/listinfo/users" target="_blank">http://lists.racket-lang.org/listinfo/users</a><br>
</blockquote>
</div>
<br>
</div>
</div>
Chris Nelson | 1 Jan 2011 16:20
Picon
Favicon

ffi-lib: couldn't open "libreadline.dll.5" - Windows XP

Hello,

I'm a new user of Racket just working through the introduction examples and such. I've finished "Quick: An Introduction to Racket with Pictures" with DrRacket and I'm attempting to complete More: "Systems Programming with Racket" through cmd.exe.  However I'm receiving the following message after loading Racket at the command line.
--------------
Welcome to Racket v5.0.2.
ffi-lib: couldn't open "libreadline.dll.5" (The specified module could not be found.; errno=126)
--------------
Readline does appear to be installed in my racketrc.rktl, and DrRacket aggrees so maybe racket.exe is looking in a different path than DrRacket in Windows.

Thanks for any assistance!
Chris Nelson



<div>
<div>
<div>Hello,<br><br>I'm a new user of Racket just working through the introduction examples and such. I've finished "Quick: An Introduction to Racket with Pictures" with DrRacket and I'm attempting to complete More: "Systems Programming with Racket" through cmd.exe.&nbsp; However I'm receiving the following message after loading Racket at the command line. <br>--------------<br>Welcome to Racket v5.0.2.<br>ffi-lib: couldn't open "libreadline.dll.5" (The specified module could not be found.; errno=126)<br>--------------<br>Readline does appear to be installed in my racketrc.rktl, and DrRacket aggrees so maybe racket.exe is looking in a
  different path than DrRacket in Windows.<br><br>Thanks for any assistance!<br>Chris Nelson<br><h2><span><br></span></h2>
</div>
</div>
<br>
</div>
Matthew Flatt | 1 Jan 2011 16:23
Picon
Favicon
Gravatar

Re: problem with choose language and submit bug report

I've pushed a change that should avoid the immediate problem. 

With the change, do text fields draw correctly in the "Choose Language"
and "Submit Bug Report" windows? I expect that they draw without a
border, but I also expect that v5.0.2 draws the same way on your
machine.

At Sat, 1 Jan 2011 11:58:49 +0100, "Jos Koot" wrote:
> Because DrRacket help/submit bug report does not function, I use this list
> for the following report.
>  
> Welcome to DrRacket, version 5.0.99.5--2010-12-31(b2a297a/a) [3m].
> Windows 7
>  
> 'Choose language' and 'submit bug report' and some other menu selections of
> DrRacket result in:
>  
> HTHEME->C: expected argument of type <non-null `HTHEME' pointer>; given #f
>  
>  === context ===
> C:\Program Files\Racket-Full-5.0.99.5\collects\ffi\unsafe.rkt:1034:12
> C:\Program Files\Racket-Full-5.0.99.5\collects\ffi\unsafe\alloc.rkt:24:9
> C:\Program
> Files\Racket-Full-5.0.99.5\collects\mred\private\wx\win32\canvas.rkt:76:3
> C:\Program
> Files\Racket-Full-5.0.99.5\collects\racket\private\class-internal.rkt:3529:0
> : continue-make-super
> C:\Program
> Files\Racket-Full-5.0.99.5\collects\mred\private\wx\common\canvas-mixin.rkt:
> 115:2
> C:\Program
> Files\Racket-Full-5.0.99.5\collects\racket\private\class-internal.rkt:3529:0
> : continue-make-super
> C:\Program
> Files\Racket-Full-5.0.99.5\collects\racket\private\class-internal.rkt:3529:0
> : continue-make-super
> C:\Program
> Files\Racket-Full-5.0.99.5\collects\mred\private\wxwindow.rkt:15:6
> C:\Program
> Files\Racket-Full-5.0.99.5\collects\racket\private\class-internal.rkt:3529:0
> : continue-make-super
> C:\Program Files\Racket-Full-5.0.99.5\collects\mred\private\wxitem.rkt:35:6
> C:\Program
> Files\Racket-Full-5.0.99.5\collects\racket\private\class-internal.rkt:3529:0
> : continue-make-super
> C:\Program Files\Racket-Full-5.0.99.5\collects\mred\private\wxitem.rkt:203:4
> C:\Program
> Files\Racket-Full-5.0.99.5\collects\racket\private\class-internal.rkt:3529:0
> : continue-make-super
> C:\Program
> Files\Racket-Full-5.0.99.5\collects\mred\private\wxcanvas.rkt:91:4
> C:\Program
> Files\Racket-Full-5.0.99.5\collects\racket\private\class-internal.rkt:3529:0
> : continue-make-super
> C:\Program
> Files\Racket-Full-5.0.99.5\collects\racket\private\class-internal.rkt:3529:0
> : continue-make-super
>  
> Happy new year to all.
> Jos
> 
> _________________________________________________
>   For list-related administrative tasks:
>   http://lists.racket-lang.org/listinfo/users
Matthew Flatt | 1 Jan 2011 16:30
Picon
Favicon
Gravatar

Re: ffi-lib: couldn't open "libreadline.dll.5" - Windows XP

At Sat, 1 Jan 2011 07:20:48 -0800 (PST), Chris Nelson wrote:
> I'm a new user of Racket just working through the introduction examples and 
> such. I've finished "Quick: An Introduction to Racket with Pictures" with 
> DrRacket and I'm attempting to complete More: "Systems Programming with Racket" 
> through cmd.exe.  However I'm receiving the following message after loading 
> Racket at the command line. 
> 
> --------------
> Welcome to Racket v5.0.2.
> ffi-lib: couldn't open "libreadline.dll.5" (The specified module could not be 
> found.; errno=126)
> --------------
> Readline does appear to be installed in my racketrc.rktl, and DrRacket aggrees 
> so maybe racket.exe is looking in a different path than DrRacket in Windows.

Readline isn't useful when using "cmd.exe" in Windows, because the
Windows command shell gives you readline-like functionality
automatically. There's a note to that effect before the
`install-readline!' example in "More", but maybe it needs to be more
clear that readline typically isn't available at all under Windows.

So, I think you want to just remove the `readline' loading from your
"racketrc.rktl".

Matthias Felleisen | 1 Jan 2011 16:37
Favicon

Re: Defining Variables in a function


On Jan 1, 2011, at 10:12 AM, Luke Jordan wrote:

> the book has made available to you at a given point and trust that in time all will be revealed.

Indeed. And this kind of problem is one of the motivational points for such local definitions. -- Matthias

gabor papp | 1 Jan 2011 17:05
Picon
Favicon

Re: scheme_make_vector gc macros

> Assuming that `src' never refers to GCable memory, this looks fine. You
> don't really need to register `tmp', but it's ok to do so.
Thank you. 'src' does not refer to GCable memory, which i think is not 
the case in the opposite direction when we are receiving vectors from 
scheme. Should this be done differently?

void FloatsFromScheme(Scheme_Object *src, float *dst, unsigned int size)
{
     MZ_GC_DECL_REG(1);
     MZ_GC_VAR_IN_REG(0, src);
     MZ_GC_REG();
     assert(size<=(unsigned int)SCHEME_VEC_SIZE(src));
     for (unsigned int n=0; n<size; n++)
     {
         dst[n]=scheme_real_to_double(SCHEME_VEC_ELS(src)[n]);
     }
     MZ_GC_UNREG();
}
> leak, it may be helpful to build Racket with `--enable-backtrace' and
> use `dump-memory-stats' to get all the paths to a particular kind of
Thanks for the suggestion. I'm going to try that,

Best,
Gabor

Gmane