ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* inconsistency with lexing number bases
@ 2003-10-15  4:24 Ryan Davis
  2003-10-15  4:31 ` Ryan Davis
  0 siblings, 1 reply; 3+ messages in thread
From: Ryan Davis @ 2003-10-15  4:24 UTC (permalink / raw
  To: ruby-core

Why is:

	0b0
	0x0
	0o0

allowed, but not:

	0d0
?

I think I'd like to propose that 0d0 is allowed and I'd think that the 
patch (ignoring indentation) should be:

<558> diff -bu parse.y parse.y.new
--- parse.y	Tue Jul 29 23:38:32 2003
+++ parse.y.new	Tue Oct 14 21:09:40 2003
@@ -3765,7 +3765,6 @@
  		if (c == 'd' || c == 'D') {
  		    /* decimal */
  		    c = nextc();
-		    if (ISDIGIT(c)) {
  			do {
  			    if (c == '_') {
  				if (nondigit) break;
@@ -3776,7 +3775,6 @@
  			    nondigit = 0;
  			    tokadd(c);
  			} while ((c = nextc()) != -1);
-		    }
  		    pushback(c);
  		    tokfix();
  		    if (toklen() == start) {

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: inconsistency with lexing number bases
  2003-10-15  4:24 inconsistency with lexing number bases Ryan Davis
@ 2003-10-15  4:31 ` Ryan Davis
  2003-10-15  5:59   ` [OT] " daz
  0 siblings, 1 reply; 3+ messages in thread
From: Ryan Davis @ 2003-10-15  4:31 UTC (permalink / raw
  To: ruby-core

um... smoking crack. I think we were mixing up our interpreters between 
1.6.7 and 1.8. Sorry.

On Tuesday, October 14, 2003, at 09:24 PM, Ryan Davis wrote:

> Why is:
>
> 	0b0
> 	0x0
> 	0o0
>
> allowed, but not:
>
> 	0d0
> ?
>
> I think I'd like to propose that 0d0 is allowed and I'd think that the 
> patch (ignoring indentation) should be:
>
> <558> diff -bu parse.y parse.y.new
> --- parse.y	Tue Jul 29 23:38:32 2003
> +++ parse.y.new	Tue Oct 14 21:09:40 2003
> @@ -3765,7 +3765,6 @@
>  		if (c == 'd' || c == 'D') {
>  		    /* decimal */
>  		    c = nextc();
> -		    if (ISDIGIT(c)) {
>  			do {
>  			    if (c == '_') {
>  				if (nondigit) break;
> @@ -3776,7 +3775,6 @@
>  			    nondigit = 0;
>  			    tokadd(c);
>  			} while ((c = nextc()) != -1);
> -		    }
>  		    pushback(c);
>  		    tokfix();
>  		    if (toklen() == start) {
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [OT] inconsistency with lexing number bases
  2003-10-15  4:31 ` Ryan Davis
@ 2003-10-15  5:59   ` daz
  0 siblings, 0 replies; 3+ messages in thread
From: daz @ 2003-10-15  5:59 UTC (permalink / raw
  To: ruby-core




> um... sm***** cr#ck ...


One part of Ruby which I wish hadn't been modelled on
other languages (Perl ? via C ?) is:

p 010

#-> 8

(i.e. unmodified leading zero implies octal)

Didn't octal die when hex came along ?

I just think that octal should be written explicitly
like the other non-decimals.

It's not uncommon to see numeric fields with leading
zeros and most humans are unlikely to think of any octal
connection, but reading them in without left-stripping
could have caused no end of banking discrepancies.

This design decision would have been taken before cr#ck
was widely available and before Ruby was born, but I
suspect some kind of hallucinogen was involved.

Still, I know it's another of those "break existing code"
things that trap us in the past.


Anonymously,


daz

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-10-15  5:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-15  4:24 inconsistency with lexing number bases Ryan Davis
2003-10-15  4:31 ` Ryan Davis
2003-10-15  5:59   ` [OT] " daz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).