Marijn | 1 Feb 11:04
Picon
Favicon

Re: text-field% isn't just for string input, but for output and numbers too!


On 30-01-12 19:08, Matthew Flatt wrote:
> A note on alignment:
> 
> The `text%' class supports 'right and 'center paragraph alignment, 
> which more or less works when the editor has a maximum width. (The
> docs have some caveats.)
> 
> So, you can get right-alignment to a useful degree with a sequence
> like this:
> 
> (define tf (new text-field% ....))
> 
> ;; Make the editor have a maximum width: (send (send tf get-editor)
> auto-wrap #t) ;; Keep the caret visible: (send (send tf get-editor)
> set-padding 0 0 2 0) ;; Right-align the first paragraph: (send
> (send tf get-editor) set-paragraph-alignment 0 'right)
> 
> I noticed that refresh wasn't right when editing right-aligned
> text, though, and I pushed a fix for that.

Thanks Matthew, that seems to work well enough; at least when some
more bugs are squished. It seems that alignment goes back to
left-aligned under certain edits. For example if I have a text-field
with an initial value of 0 and replace that 0 by anything else it gets
left-aligned.

Marijn
Matthew Flatt | 1 Feb 13:43
Picon
Favicon
Gravatar

Re: text-field% isn't just for string input, but for output and numbers too!

At Wed, 01 Feb 2012 11:04:36 +0100, Marijn wrote:
> On 30-01-12 19:08, Matthew Flatt wrote:
> > A note on alignment:
> > 
> > The `text%' class supports 'right and 'center paragraph alignment, 
> > which more or less works when the editor has a maximum width. (The
> > docs have some caveats.)
> > 
> > So, you can get right-alignment to a useful degree with a sequence
> > like this:
> > 
> > (define tf (new text-field% ....))
> > 
> > ;; Make the editor have a maximum width: (send (send tf get-editor)
> > auto-wrap #t) ;; Keep the caret visible: (send (send tf get-editor)
> > set-padding 0 0 2 0) ;; Right-align the first paragraph: (send
> > (send tf get-editor) set-paragraph-alignment 0 'right)
> > 
> > I noticed that refresh wasn't right when editing right-aligned
> > text, though, and I pushed a fix for that.
> 
> Thanks Matthew, that seems to work well enough; at least when some
> more bugs are squished. It seems that alignment goes back to
> left-aligned under certain edits. For example if I have a text-field
> with an initial value of 0 and replace that 0 by anything else it gets
> left-aligned.

Yes --- effects like that are why the `set-paragraph-alignment' method
is still labeled "experimental". I'm not sure how difficult it would be
to make paragraph alignment work better, but a possible workaround is
(Continue reading)

Stefan Schmiedl | 1 Feb 15:37
Picon
Gravatar

POP3 client

Greetings,

is there a POP3 client module for racket somewhere out there?

Thanks,
s.

--

-- 
"This is why Science and Mathematics are still much fun:
You discover things that seem impossible to be true
and then get to figure out why it's impossible for them not to be."

            -- Vi Hart: Spirals, Fibonacci, and Being a Plant, Part 3
____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Matthias Felleisen | 1 Feb 16:50
Favicon

Re: POP3 client


Would this work: 

 http://docs.racket-lang.org/net/pop3.html?q=pop3

(In general, type 'pop3' in DrRacket and hit F1. Or 'raco doc pop3' in a shell.) 

On Feb 1, 2012, at 9:37 AM, Stefan Schmiedl wrote:

> Greetings,
> 
> is there a POP3 client module for racket somewhere out there?
> 
> Thanks,
> s.
> 
> -- 
> "This is why Science and Mathematics are still much fun:
> You discover things that seem impossible to be true
> and then get to figure out why it's impossible for them not to be."
> 
>            -- Vi Hart: Spirals, Fibonacci, and Being a Plant, Part 3
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

____________________
  Racket Users list:
  http://lists.racket-lang.org/users

(Continue reading)

Rüdiger Asche | 1 Feb 17:45
Picon

macros in local namespaces?...

Hi there,

I'm trying to get a grip on macros. Here is a very simple Racket  
expression  (1):

(letrec [(a 2)
          (b 3)
          (afn (lambda (x) (+ x a)))
          (bfn (lambda (x) (+ x b)))]
    (afn (bfn 2)))

Now I need a syntactic abstraction for afn and bfn. The following will  
do in first approximation (2):

(define-syntax-rule (absfn varname) (lambda (x) (+ x varname)))

(letrec [(a 2)
          (b 3)
          (afn (absfn a))
          (bfn (absfn b))]
    (afn (bfn 2)))

However, it will fail due to scoping rules in the following example (3):

(define-syntax-rule (absfn varname) (lambda (x) (+ (+ x localc) varname)))

(letrec [(a 2)
          (b 3)
          (localc 4)
          (afn (absfn a))
(Continue reading)

Matthias Felleisen | 1 Feb 18:03
Favicon

Re: macros in local namespaces?...


Something like this might be what you want: 

(letrec-syntaxes+values ([(absfn)
                          (syntax-rules ()
                            [(_ varname) (lambda (x) (+ (+ x localc) varname))])])
  ([(a) 2]
   [(b) 3]
   [(localc) 4]
   [(afn) (absfn a)]
   [(bfn) (absfn b)])
  (afn (bfn 3)))

BUT, I strongly recommend abstraction the macro over both variables. 

On Feb 1, 2012, at 11:45 AM, Rüdiger Asche wrote:

> Hi there,
> 
> I'm trying to get a grip on macros. Here is a very simple Racket expression  (1):
> 
> (letrec [(a 2)
>         (b 3)
>         (afn (lambda (x) (+ x a)))
>         (bfn (lambda (x) (+ x b)))]
>   (afn (bfn 2)))
> 
> Now I need a syntactic abstraction for afn and bfn. The following will do in first approximation (2):
> 
> (define-syntax-rule (absfn varname) (lambda (x) (+ x varname)))
(Continue reading)

Ryan Culpepper | 1 Feb 18:11
Picon
Favicon

Re: macros in local namespaces?...

On 02/01/2012 09:45 AM, Rüdiger Asche wrote:
> Hi there,
>
> I'm trying to get a grip on macros. Here is a very simple Racket expression  (1):
>
> (letrec [(a 2)
>          (b 3)
>          (afn (lambda (x) (+ x a)))
>          (bfn (lambda (x) (+ x b)))]
>    (afn (bfn 2)))
>
> Now I need a syntactic abstraction for afn and bfn. The following will do in first approximation (2):
>
> (define-syntax-rule (absfn varname) (lambda (x) (+ x varname)))
>
> (letrec [(a 2)
>          (b 3)
>          (afn (absfn a))
>          (bfn (absfn b))]
>    (afn (bfn 2)))
>
>
> However, it will fail due to scoping rules in the following example (3):
>
> (define-syntax-rule (absfn varname) (lambda (x) (+ (+ x localc) varname)))
>
> (letrec [(a 2)
>          (b 3)
>          (localc 4)
>          (afn (absfn a))
(Continue reading)

Roelof Wobben | 1 Feb 19:55
Picon
Favicon

exercise problem

Hello,

I have this problem :

Utopia's tax accountants always use programs that compute income taxes
even though the tax rate is a solid, never-changing 15%. Define the
program tax, which determines the tax on the gross pay.

Also define netpay. The program determines the net pay of an employee
from the number of hours worked. Assume an hourly rate of $12.

So in my opion I can solve this at this way :

grosspay = hours_work * 12,5
tax = grosspay * 0,15
netpay = grosspay - tax.

So I did this :

(define (grosspay h)
    (* h 12.50))

(define (tax grosspay)
     ( * grosspay 0.15))

(define (nettoloon grosspay tax)
      (- grosspay tax))

But when I do :

(Continue reading)

Matthias Felleisen | 1 Feb 20:20
Favicon

Re: exercise problem


On Feb 1, 2012, at 1:55 PM, Roelof Wobben wrote:

> So in my opion I can solve this at this way :
> 
> 
> grosspay = hours_work * 12,5
> tax = grosspay * 0,15
> netpay = grosspay - tax.
> 
> So I did this :
> 
> (define (grosspay h)
>   (* h 12.50))
> 
> (define (tax grosspay)
>    ( * grosspay 0.15))
> 
> (define (nettoloon grosspay tax)
>     (- grosspay tax))
> 
> But when I do :
> 
> (grosspay 1)

When I do so, I get 12.5. 

> I get a message that there a 2 variables and one is given.
> So the other functions are not executed.

(Continue reading)

Curtis Dutton | 2 Feb 06:09
Picon

racket/db - query-rows: connection is permanently locked due to a terminated thread

I'm receiving this error after my webserver is running for a few days. 


Hosting a plt webserver on Ubuntu server, I'm using the racket/db library to access a local postgres database. After a few hundred requests, over a period of days, I eventually get this error message. "query-rows: connection is permanently locked due to a terminated thread"

Once this error is generated all calls made to the database then fail, and continue to fail until I restart the webserver process. 

I am using the virtual connection pooling interface as well.

Has anyone seen this yet?

I submitted  bug #12530.



I have not been able to reproduce this manually. It happens after a few days. I'm willing to instrument or hack at it to help determine the issue but a little guidance would be very welcome.


Thanks,
     Curtis

____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Gmane