Re: [racket-dev] Character classification

2012-09-04 Thread Jens Axel Søgaard
2012/9/4 Pierpaolo Bernardi :
> On Tue, Sep 4, 2012 at 3:11 PM, Jens Axel Søgaard  
> wrote:
>> Since the R5RS version of char-numeric? (according to the documentation)
>> tests for the ten digits, you can use:
>>
>> (require (only-in r5rs char-numeric?))
>
> Thanks Jens Axel.  However, the r5rs version appears to be the same as
> the Racket version.

I consider that a bug.

http://docs.racket-lang.org/r5rs-std/r5rs-Z-H-9.html?q=char-numeric%3F#%_idx_490
"The numeric characters are the ten decimal digits."

Note that meaning changed in R6RS:
"A character is numeric if it has the Unicode “Numeric” property."

So the current Racket behaviour matches R6RS.

/Jens Axel


Tested with:
>
> 
> #lang r5rs
>
> (define (test)
>   (let again ((i 0))
> (cond ((< i #xD800)
>(let ((c (integer->char i)))
>  (cond ((char-numeric? c)
> (display (list i c))
> (newline)))
>  (again (+ i 1)))
> 



-- 
--
Jens Axel Søgaard

_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] Character classification

2012-09-04 Thread Pierpaolo Bernardi
On Tue, Sep 4, 2012 at 5:03 PM, Sam Tobin-Hochstadt  wrote:
> On Tue, Sep 4, 2012 at 10:57 AM, Pierpaolo Bernardi  
> wrote:
>>
>> What is annoying is that char-numeric? and string->number are not compatible.
>
> `char-numeric?` and `string->number` would not be "compatible" in the
> sense you're thinking of, even with the change you mention.
>
> For example:
>
> -> (string->number "+i")
> 0+1i
> -> (string->number "1#e4")
> 10.0

They would be compatible in the other direction.  A string composed of
char-numeric? chars would be accepted by string->number.

In short, my-char-numeric? is a function that is useful, has been in
scheme since the stone age, and nowadays I have to write it myself,
and remember to not use char-numeric?, since it is never what I need
(and when I'll need the char-numeric? functionality I can get it with
char-general-category).

(Sorry about the previous duplicate messages. I don't know what's causing them)

P.
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] Character classification

2012-09-04 Thread Sam Tobin-Hochstadt
On Tue, Sep 4, 2012 at 10:57 AM, Pierpaolo Bernardi  wrote:
>
> What is annoying is that char-numeric? and string->number are not compatible.

`char-numeric?` and `string->number` would not be "compatible" in the
sense you're thinking of, even with the change you mention.

For example:

-> (string->number "+i")
0+1i
-> (string->number "1#e4")
10.0

-- 
sam th
sa...@ccs.neu.edu
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] Character classification

2012-09-04 Thread Pierpaolo Bernardi
On Tue, Sep 4, 2012 at 3:56 PM, Doug Williams
 wrote:
> I would say your function would be better named is-digit?

Good point.  However, many of the characters which are char-numeric?
are digits too, in other writing systems.

> and that the
> char-numeric? is exactly what it is intended to be with respect to
> Unicode characters, which is what a Racket character represents.

What is annoying is that char-numeric? and string->number are not compatible.

It would be fine for me to leave char-numeric? as it is and fix
string->number to accept and act sensibly on everything that passes
char-numeric?.

And I'd bet that this new definition of char-numeric? has introduced
thousands of covered bugs, which are not exposed only because most the
char-numeric? characters outside of #\0 .. #\9 occurs rarely.

P.
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] Character classification

2012-09-04 Thread Pierpaolo Bernardi
On Tue, Sep 4, 2012 at 3:56 PM, Doug Williams
 wrote:
> I would say your function would be better named is-digit?

Good point.  However, many of the characters which are char-numeric?
are digits too, in other writing systems.

> and that the
> char-numeric? is exactly what it is intended to be with respect to
> Unicode characters, which is what a Racket character represents.

What is annoying is that char-numeric? and string->number are not compatible.

It would be fine for me to leave char-numeric? as it is and fix
string->number to accept and act sensibly on everything that passes
char-numeric?.

And I'd bet that this new definition of char-numeric? has introduced
thousands of covered bugs, which are not exposed only because most the
char-numeric? characters outside of #\0 .. #\9 occurs rarely.

P.
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] Character classification

2012-09-04 Thread Doug Williams
I would say your function would be better named is-digit? and that the
char-numeric? is exactly what it is intended to be with respect to
Unicode characters, which is what a Racket character represents.

On Tue, Sep 4, 2012 at 4:37 AM, Pierpaolo Bernardi  wrote:
> The non-cooperation between char-numeric? and string->number is very annoying.
>
> I had to resort to:
>
> (define (my-char-numeric? c)
>   (char<=? #\0 c #\9))
>
> Maybe I am missing a function similar to my-char-numeric? somewhere in
> the Racket docs?
>
> FWIW, my humble opinion is that char-numeric? should be defined as the
> my- version above. The Unicode category, if that's what one wants, can
> be accessed with char-general-category.
>
> Cheers
> P.
> _
>   Racket Developers list:
>   http://lists.racket-lang.org/dev
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] Character classification

2012-09-04 Thread Pierpaolo Bernardi
On Tue, Sep 4, 2012 at 3:11 PM, Jens Axel Søgaard  wrote:
> Since the R5RS version of char-numeric? (according to the documentation)
> tests for the ten digits, you can use:
>
> (require (only-in r5rs char-numeric?))

Thanks Jens Axel.  However, the r5rs version appears to be the same as
the Racket version. Tested with:


#lang r5rs

(define (test)
  (let again ((i 0))
(cond ((< i #xD800)
   (let ((c (integer->char i)))
 (cond ((char-numeric? c)
(display (list i c))
(newline)))
 (again (+ i 1)))


_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] Character classification

2012-09-04 Thread Jens Axel Søgaard
Since the R5RS version of char-numeric? (according to the documentation)
tests for the ten digits, you can use:

(require (only-in r5rs char-numeric?))

/Jens Axel

2012/9/4 Pierpaolo Bernardi :
> The non-cooperation between char-numeric? and string->number is very annoying.
>
> I had to resort to:
>
> (define (my-char-numeric? c)
>   (char<=? #\0 c #\9))
>
> Maybe I am missing a function similar to my-char-numeric? somewhere in
> the Racket docs?
>
> FWIW, my humble opinion is that char-numeric? should be defined as the
> my- version above. The Unicode category, if that's what one wants, can
> be accessed with char-general-category.
>
> Cheers
> P.
> _
>   Racket Developers list:
>   http://lists.racket-lang.org/dev



-- 
--
Jens Axel Søgaard

_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] Changing call/cc

2012-09-04 Thread Matthew Flatt
At Thu, 30 Aug 2012 11:36:55 -0400, Asumu Takikawa wrote:
> On 2012-08-30 06:53:58 -0600, Matthew Flatt wrote:
> > I think this combination of replacing both `call/cc' and `dynamic-wind'
> > would be equivalent to a smaller change to the semantics of `call/cc',
> > which is that it behaves as it does now if there's a shared
> > `dynamic-wind' between the source and target continuations, but it
> > behaves like your replacement `call/cc' if there's no intervening
> > prompt (which addresses the reasoning problem). Also, implementing the
> > change directly in the existing `call/cc' implementation sounds fairly
> > easy to me.
> 
> Sam and I discussed this some more, and we think it sounds workable and
> will go and try to add it to the Redex model and see what tests fail. We
> were concerned about one thing though: it sounds like this would modify
> the behavior of `call/cc` depending on whether or not you put a
> `dynamic-wind` in your continuation.
> 
> That also means that a programmer who installs a `dynamic-wind` might
> get fewer abort handlers run than expected, or perhaps gets *more* run
> than expected since they either didn't install the `dynamic-wind` or
> they passed the continuation out of the `dynamic-wind` to a different
> context and invoked it there.
> 
> Is that a fair point or are we misunderstanding your proposed semantics?

Yes, that's true. I don't think there will be a difference for typical
uses of `call/cc' and typical abort handlers, though. And as I
understand it, we're not at this point trying to make `call/cc' work
seamlessly, but instead support it reasonably well for backward
compatibility.

_
  Racket Developers list:
  http://lists.racket-lang.org/dev


[racket-dev] Character classification

2012-09-04 Thread Pierpaolo Bernardi
The non-cooperation between char-numeric? and string->number is very annoying.

I had to resort to:

(define (my-char-numeric? c)
  (char<=? #\0 c #\9))

Maybe I am missing a function similar to my-char-numeric? somewhere in
the Racket docs?

FWIW, my humble opinion is that char-numeric? should be defined as the
my- version above. The Unicode category, if that's what one wants, can
be accessed with char-general-category.

Cheers
P.
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


[racket-dev] Character classification

2012-09-04 Thread Pierpaolo Bernardi
The non-cooperation between char-numeric? and string->number is very annoying.

I had to resort to:

(define (my-char-numeric? c)
  (char<=? #\0 c #\9))

Maybe I am missing a function similar to my-char-numeric? somewhere in
the Racket docs?

FWIW, my humble opinion is that char-numeric? should be defined as the
my- version above. The Unicode category, if that's what one wants, can
be accessed with char-general-category.

Cheers
P.
_
  Racket Developers list:
  http://lists.racket-lang.org/dev