Open racket-bug-submit opened 9 years ago
Agreed. We need to figure out our numbers
On Feb 6, 2010, at 11:08 PM, eli@barzilay.org wrote:
> A new problem report is waiting at
> http://bugs.plt-scheme.org/query/?cmd=view&pr=10740
>
> Reported by Eli Barzilay for release: 4.2.4
>
> *** Description:
> Enter the program below, then be surprised.
> (I don't see any point in making `Integer' be what it is in other
> statically typed languages, when `integer?' means something different.)
>
> *** How to repeat:
> #lang typed-scheme
> (: foo : Any -> Integer)
> (define (foo x)
> (if (integer? x)
> x
> 1))
>
> *** Environment:
> unix "Linux winooski.ccs.neu.edu 2.6.23.17-88.fc7 #1 SMP Thu May 15 00:02:29 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux" (x86_64-linux/3m) (get-display-depth) = 16
> Human Language: english
> (current-memory-use) 176532328
>
> Collections:
> (("/home/eli/.plt-scheme/4.2.4/collects" "info-domain" "pl") ("/home/eli/plt/collects" "icons" "ffi" "mred" "dynext" "mzscheme" "make" "preprocessor" "file" "openssl" "sgl" "scriblib" "s-exp" "slideshow" "mysterx" "graphics" "test-engine" "scheme" "frtime" "wxme" "lazy" "mzlib" "macro-debugger" "scribble" "syntax-color" "mzcom" "help" "swindle" "config" "net" "hierlist" "test-box-recovery" "2htdp" "profile" "trace" "mrlib" "algol60" "browser" "framework" "typed-scheme" "at-exp" "info-domain" "compiler" "errortrace" "eopl" "syntax" "combinator-parser" "string-constants" "html" "slatex" "stepper" "launcher" "unstable" "htdp" "lang" "rnrs" "setup" "deinprogramm" "plot" "teachpack" "xml" "scribblings" "planet" "readline" "parser-tools" "embedded-gui" "drscheme" "defaults" "srfi" "afm" "r6rs" "version" "typed" "texpict" "games" "tex2page" "gui-debugger" "web-server" "r5rs" "redex"))
> Computer Language: (("Module") (#(#t write mixed-fraction-e #f #t debug) (default) #() "#lang scheme\n" #t))
>
This design is an intentional tradeoff; as nice as it would be to have integer? correspond with Integer, the set of exact-or-inexact integers does not have many operations closed over it. Arithmetic with inexact integers can result in non-integer results, so +, -, and * could no longer have the types "Integer* -> Integer". In order to make Integer a useful and sound type, it needs to be exact only. The options are then to make exact-integer? the predicate, or to replace integer? with exact-integer? in Typed Scheme, which changes its behavior from Scheme.
[Paraphrasing from conversations with Sam]
Carl Eastlund
On Sun, Feb 7, 2010 at 12:32 PM, Matthias Felleisen matthias@ccs.neu.edu wrote:
Agreed. We need to figure out our numbers
On Feb 6, 2010, at 11:08 PM, eli@barzilay.org wrote:
A new problem report is waiting at =A0http://bugs.plt-scheme.org/query/?cmd=3Dview&pr=3D10740
Reported by Eli Barzilay for release: 4.2.4
*\ Description: Enter the program below, then be surprised. (I don't see any point in making
Integer' be what it is in other statically typed languages, when
integer?' means something different.)
FWIW, the current situation is pretty bad. The fake number?' thing tricky to get over, and this lack of some
ExactInteger' thing seems
like trouble. I can see how a proper Integer' is problematic, in the sense that people don't get what they expect, but that's the same thing that happens with
integer?' so it's shouldn't be TS's business
to fix it...
(And FWIW_1, I never liked the fact that (integer? 3.0) returns true -- it's a constant surprise, it messes up code with adding more tests, and I don't get the sense for it -- since 3.0 could be some approximation like any other flonum. I wouldn't miss this feature if it went away, but it's probably too late...)
On Feb 7, Matthias Felleisen wrote:
Agreed. We need to figure out our numbers
On Feb 6, 2010, at 11:08 PM, eli@barzilay.org wrote:
A new problem report is waiting at http://bugs.plt-scheme.org/query/?cmd=view&pr=10740
Reported by Eli Barzilay for release: 4.2.4
*\ Description: Enter the program below, then be surprised. (I don't see any point in making
Integer' be what it is in other statically typed languages, when
integer?' means something different.)*\ How to repeat:
lang typed-scheme
(: foo : Any -> Integer) (define (foo x) (if (integer? x) x 1))
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!
Sam may not have made an announcement yet, this may be still a feature in development, but "typed-scheme" is essentially a legacy language -- hence the "number?" hack to keep old code working, because Sam accidentally made Number mean Real instead of Complex.
If you use "#lang typed/scheme" instead (note the slash), number? means number? and Number means Complex. The language with the slash in it is the "future of Typed Scheme". I've been adapting my typed code to it, for instance.
Carl Eastlund
On Sun, Feb 7, 2010 at 12:43 PM, Eli Barzilay <eli@barzilay.org> wrote:
> FWIW, the current situation is pretty bad. =A0The fake `number?' thing
> tricky to get over, and this lack of some `ExactInteger' thing seems
> like trouble. =A0I can see how a proper `Integer' is problematic, in the
> sense that people don't get what they expect, but that's the same
> thing that happens with `integer?' so it's shouldn't be TS's business
> to fix it...
>
> (And FWIW_1, I never liked the fact that (integer? 3.0) returns true
> -- it's a constant surprise, it messes up code with adding more tests,
> and I don't get the sense for it -- since 3.0 could be some
> approximation like any other flonum. =A0I wouldn't miss this feature if
> it went away, but it's probably too late...)
>
>
> On Feb =A07, Matthias Felleisen wrote:
>> Agreed. We need to figure out our numbers
>>
>>
>> On Feb 6, 2010, at 11:08 PM, eli@barzilay.org wrote:
>>
>> > A new problem report is waiting at
>> > =A0http://bugs.plt-scheme.org/query/?cmd=3Dview&pr=3D10740
>> >
>> > Reported by Eli Barzilay for release: 4.2.4
>> >
>> > *** Description:
>> > Enter the program below, then be surprised.
>> > (I don't see any point in making `Integer' be what it is in other
>> > statically typed languages, when `integer?' means something different.=
)
>> >
>> > *** How to repeat:
>> > #lang typed-scheme
>> > (: foo : Any -> Integer)
>> > (define (foo x)
>> > =A0(if (integer? x)
>> > =A0 =A0 =A0x
>> > =A0 =A0 =A01))
>
> --
> =A0 =A0 =A0 =A0 =A0((lambda (x) (x x)) (lambda (x) (x x))) =A0 =A0 =A0 =
=A0 =A0Eli Barzilay:
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0http://barzilay.org/ =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 Maze is Life!
>
On Feb 7, Carl Eastlund wrote:
This design is an intentional tradeoff; as nice as it would be to have integer? correspond with Integer,
I don't consider it a tradeoff from the typed scheme POV: `integer?' is what it is, and TS should follow that. Any attempts to "fix" it are going to create very bad confusions, as is the current state. It would be semi-excusable if TS couldn't follow that, but one of its main points is that it can.
the set of exact-or-inexact integers does not have many operations closed over it. Arithmetic with inexact integers can result in non-integer results, so +, -, and * could no longer have the types "Integer* -> Integer". In order to make Integer a useful and sound type, it needs to be exact only.
Right -- Integer' is not too useful, just like
integer?'.
The options are then to make exact-integer? the predicate, or to replace integer? with exact-integer? in Typed Scheme, which changes its behavior from Scheme.
Doing that in TS would be a very bad idea.
-- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life!
On Feb 7, Carl Eastlund wrote:
Sam may not have made an announcement yet, this may be still a feature in development, but "typed-scheme" is essentially a legacy language -- hence the "number?" hack to keep old code working, because Sam accidentally made Number mean Real instead of Complex.
If you use "#lang typed/scheme" instead (note the slash), number? means number? and Number means Complex. The language with the slash in it is the "future of Typed Scheme". I've been adapting my typed code to it, for instance.
(I'm not using TS in any such way. The thing that was a problem for
me is that there is a new "typed-scheme/private/base-env-numeric.ss".)
-- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life!
Ah, you want the type to be called ExactInteger so that the misunderstanding gets corrected when someone types Integer. Personally, I like the brevity of typing Integer, but now I get your implication. I'll let Sam take it from here. :)
Carl Eastlund
On Sun, Feb 7, 2010 at 12:50 PM, Eli Barzilay eli@barzilay.org wrote:
On Feb =A07, Carl Eastlund wrote:
This design is an intentional tradeoff; as nice as it would be to have integer? correspond with Integer,
I don't consider it a tradeoff from the typed scheme POV: `integer?' is what it is, and TS should follow that. =A0Any attempts to "fix" it are going to create very bad confusions, as is the current state. =A0It would be semi-excusable if TS couldn't follow that, but one of its main points is that it can.
the set of exact-or-inexact integers does not have many operations closed over it. =A0Arithmetic with inexact integers can result in non-integer results, so +, -, and * could no longer have the types "Integer* -> Integer". =A0In order to make Integer a useful and sound type, it needs to be exact only.
Right --
Integer' is not too useful, just like
integer?'.The options are then to make exact-integer? the predicate, or to replace integer? with exact-integer? in Typed Scheme, which changes its behavior from Scheme.
Doing that in TS would be a very bad idea.
=A0 =A0 =A0 =A0 =A0((lambda (x) (x x)) (lambda (x) (x x))) =A0 =A0 =A0 = =A0 =A0Eli Barzilay: =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0http://barzilay.org/ =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 Maze is Life!
On Feb 7, Carl Eastlund wrote:
Ah, you want the type to be called ExactInteger so that the misunderstanding gets corrected when someone types Integer. Personally, I like the brevity of typing Integer, but now I get your implication. I'll let Sam take it from here. :)
- Yes, `ExactInteger' would be better.
- I also like the shorter `Integer' -- but this is minor to the confused result that follows.
- The fact that this is more of a problem in TS than it is in plain scheme is, IMO, just an indicator that people tend to use
integer?' in many places where they should really be using
exact-integer?'. (Or an `and' expression before that was added.)- Perhaps something like `EInteger' would work better as a short name, but it will still be something that would surprise people. The good thing is that this will be caught by the checker, instead of as some unexpected runtime error.
- And finally -- if it is at all practical, then what I said is that I'd vote for `integer?' changing at the core language level. It's something that I never liked. (In fact, I think that this was one of the first things that annoyed me when I switched to plt.)
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!
In addition we need to make sure that the semantics of our modules stays what Untyped Racketeers expect.
On Feb 7, 2010, at 12:40 PM, Carl Eastlund wrote:
This design is an intentional tradeoff; as nice as it would be to have integer? correspond with Integer, the set of exact-or-inexact integers does not have many operations closed over it. Arithmetic with inexact integers can result in non-integer results, so +, -, and * could no longer have the types "Integer* -> Integer". In order to make Integer a useful and sound type, it needs to be exact only. The options are then to make exact-integer? the predicate, or to replace integer? with exact-integer? in Typed Scheme, which changes its behavior from Scheme.
[Paraphrasing from conversations with Sam]
Carl Eastlund
On Sun, Feb 7, 2010 at 12:32 PM, Matthias Felleisen matthias@ccs.neu.edu wrote:
Agreed. We need to figure out our numbers
On Feb 6, 2010, at 11:08 PM, eli@barzilay.org wrote:
A new problem report is waiting at http://bugs.plt-scheme.org/query/?cmd=view&pr=10740
Reported by Eli Barzilay for release: 4.2.4
*\ Description: Enter the program below, then be surprised. (I don't see any point in making
Integer' be what it is in other statically typed languages, when
integer?' means something different.)
I guess I am agreeing with Eli.
On Feb 7, 2010, at 1:12 PM, Eli Barzilay wrote:
On Feb 7, Carl Eastlund wrote:
Ah, you want the type to be called ExactInteger so that the misunderstanding gets corrected when someone types Integer. Personally, I like the brevity of typing Integer, but now I get your implication. I'll let Sam take it from here. :)
- Yes, `ExactInteger' would be better.
- I also like the shorter `Integer' -- but this is minor to the confused result that follows.
- The fact that this is more of a problem in TS than it is in plain scheme is, IMO, just an indicator that people tend to use
integer?' in many places where they should really be using
exact-integer?'. (Or an `and' expression before that was added.)- Perhaps something like `EInteger' would work better as a short name, but it will still be something that would surprise people. The good thing is that this will be caught by the checker, instead of as some unexpected runtime error.
- And finally -- if it is at all practical, then what I said is that I'd vote for `integer?' changing at the core language level. It's something that I never liked. (In fact, I think that this was one of the first things that annoyed me when I switched to plt.)
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life!
On Feb 7, Matthias Felleisen wrote:
- Let's use Entire instead of ExactInteger.
- We could divorce our Untyped semantics from that of Scheme.
I guess I am agreeing with Eli.
I'm not sure -- I would prefer it if (untyped) scheme changes... (But in any case, having `typed/scheme' as a language won't make much sense if it's a different language.)
-- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life!
More fun:
(odd? 1.0) Type Checker: Expected Integer, but got Float in: 1.0
So you see this and go to the plain scheme language in an attempt to figure things out:
> (odd? 1.0)
#t
> (odd? 1.2)
odd?: expects argument of type <integer>; given 1.2
So now you have integer?',
> denominator
- : (Number -> Integer)
#<procedure:denominator>
> (denominator 2.0)
- : Integer
1.0
> (quotient 3.0 2)
Type Checker: Expected Integer, but got Float in: 3.0
This works in plain scheme. The mistake here and in the previous
thing is that they seem to be based on translations of <integer>' to
Integer', which is invalid with the current state of things.
Another suggestion:
Int' as an alias for
InexactInteger'?More points:
[integer? (Univ . -> . B : (-LFS (list (-filter (Un -Integer -Flonum)))
(list (-not-filter -Integer))))]
[exact-integer? (make-pred-ty -Integer)]
(As an experiment: trying to explain it.) Doing what I think it
should do would make the TS code that makes these definitions much
simpler.
More than that -- doing that would probably be very productive in the find-bugs-in-untyped-code department that Sam likes so much. The current mess is almost as if he's trying hard to twist things so these bugs are not bugs.
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!
I'm late to the party, but I agree that TS is not the place to patch over things disliked about the Scheme number system. If there were another language with a different numeric tower where someone thought it thru and came to different conclusions about (integer? 3.0), for example, then we could have a different typed language for that one that might have Integer that didn't contain 3.0. But until we do, Typed Scheme is Typed Scheme not "Typed something very close to Scheme"
My $0.02.
Robby
There are several issues here, some hard, some easy, and some naming disputes:
On Sun, Feb 7, 2010 at 1:50 PM, Eli Barzilay eli@barzilay.org wrote:
- More than that -- doing that would probably be very productive in the find-bugs-in-untyped-code department that Sam likes so much. The current mess is almost as if he's trying hard to twist things so these bugs are not bugs.
Which bugs are not bugs because of these choices? If anything, too many correct programs are being statically rejected. -- sam th samth@ccs.neu.edu
For 3: I'd vote to make the names match the predicates that are in Scheme, as I see this as being like bullet 4.
Robby
On Mon, Feb 8, 2010 at 11:58 AM, Sam Tobin-Hochstadt samth@ccs.neu.edu wr= ote:
There are several issues here, some hard, some easy, and some naming disp= utes:
- Should `integer?' in Typed Scheme mean the same thing as in untyped Scheme. =C2=A0Yes, everyone agrees on this, and it is the current behavio= r.
- Should there be a type which corresponds to the inexact integers? Since untyped Scheme has them, probably Typed Scheme should too.
- What should these different types be called? =C2=A0Here, I prefer maki= ng the useful type the convenient one, but I see the argument on the other side as well. =C2=A0I'm undecided here.
- Should the semantics of `integer?' change everywhere to eliminate the concept of inexact integers? =C2=A0Mostly, I'd say yes, but I haven't thought about this that hard, nor about what compatibility problems this would cause. =C2=A0This isn't really a Typed Scheme question.
- Should I fix `denominator'? Yes. =C2=A0Fixed in SVN very soon.
On Sun, Feb 7, 2010 at 1:50 PM, Eli Barzilay eli@barzilay.org wrote:
- More than that -- doing that would probably be very productive in =C2=A0the find-bugs-in-untyped-code department that Sam likes so much. =C2=A0The current mess is almost as if he's trying hard to twist things = so =C2=A0these bugs are not bugs.
Which bugs are not bugs because of these choices? If anything, too
many correct programs are being statically rejected.
sam th samth@ccs.neu.edu
Originally submitted by Eli Barzilay on: Sat Feb 06 23:08:01 -0500 2010
Enter the program below, then be surprised. (I don't see any point in making
Integer' be what it is in other statically typed languages, when
integer?' means something different.)Steps to Reproduce:
Release:
Environment:
This bug was converted from Gnats bug 10740.
[anon-submit; eli at barzilay dot org]