Re: [racket-dev] exact nonnegative integers as sequences?
FWIW, I don't like that any of these 'in-*' thigns are optional. I was recently reading over a script that was used to build web pages from the output of testing runs for my compilers class and there were several nested for loops without in-* thingies and it was painfully difficult for me to reconstruct what the contracts of the functions were because of that. (These loops were iterating over the output of some other, long-lost script that generated the output and I was writing an adapter from the new, cleaned up scripts to this one.) So I'd be happier if you asked to get rid of all of any possibility to avoid writing 'in-*'. Even very short names, eg using the natural number unicode character would be better than using nothing. Robby On Mon, Apr 18, 2011 at 8:25 AM, Matthew Flatt mfl...@cs.utah.edu wrote: I often write (for ([i (in-range N)]) ...) In cases where the loop overhead is not significant (i.e., I don't care whether the compiler can tell that I'm iterating through integers), it would be nice to write just (for ([i N]) ...) which would require that integers are treated as sequences. Would anyone object to making an exact, nonnegative integer `N' a sequence equivalent to `(in-range N)'? _ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev _ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev
Re: [racket-dev] exact nonnegative integers as sequences?
On Mon, Apr 18, 2011 at 9:25 AM, Matthew Flatt mfl...@cs.utah.edu wrote: I often write (for ([i (in-range N)]) ...) In cases where the loop overhead is not significant (i.e., I don't care whether the compiler can tell that I'm iterating through integers), Or in cases where you're using Typed Racket, and the compiler can tell exactly what you're doing. :) it would be nice to write just (for ([i N]) ...) which would require that integers are treated as sequences. Would anyone object to making an exact, nonnegative integer `N' a sequence equivalent to `(in-range N)'? I am very strongly in favor of this. -- sam th sa...@ccs.neu.edu _ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev
Re: [racket-dev] exact nonnegative integers as sequences?
I have written (for ([i N]) ..) many times only to remember that it's in-range. On Apr 18, 2011, at 9:25 AM, Matthew Flatt wrote: I often write (for ([i (in-range N)]) ...) In cases where the loop overhead is not significant (i.e., I don't care whether the compiler can tell that I'm iterating through integers), it would be nice to write just (for ([i N]) ...) which would require that integers are treated as sequences. Would anyone object to making an exact, nonnegative integer `N' a sequence equivalent to `(in-range N)'? _ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev _ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev
Re: [racket-dev] exact nonnegative integers as sequences?
On Mon, Apr 18, 2011 at 9:58 AM, Robby Findler ro...@eecs.northwestern.edu wrote: I also don't buy Sam's implicit argument for my example. If I had tried to port this to code to typed racket to just read off the types, I would have spent far longer as debugging via TR's error messages is going to be less productive than debugging via tracing the flow of values in the program. While I support this change for basically the reasons Matthew and Matthias point to, I wasn't trying to claim that TR makes this easier to follow, just that TR removes the performance penalty Matthew mentioned. -- sam th sa...@ccs.neu.edu _ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev
Re: [racket-dev] exact nonnegative integers as sequences?
9 minutes ago, Matthew Flatt wrote: Thanks for the clarifications, and I now agree that it's not about genericity. I think it's about scripts to programs, though. In a script, not having to type `(in-range )' or `(in-list )' feels worthwhile. You make a good point that those scriptish shortcuts can make understanding the code a little harder, and using `in-range' or `in-list' can good for long-term maintenance. Still, I think it's better to allow the shortcuts. Is there any difference between this and other generic operations (which could also benefit from types being more explicit and more checked)? [Not intended as a flame -- I'm curious to see if there's something makes some generics be worse than others.] -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! _ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev
Re: [racket-dev] exact nonnegative integers as sequences?
Three minutes ago, Robby Findler wrote: On Mon, Apr 18, 2011 at 9:59 AM, Eli Barzilay e...@barzilay.org wrote: 9 minutes ago, Matthew Flatt wrote: Thanks for the clarifications, and I now agree that it's not about genericity. I think it's about scripts to programs, though. In a script, not having to type `(in-range )' or `(in-list )' feels worthwhile. You make a good point that those scriptish shortcuts can make understanding the code a little harder, and using `in-range' or `in-list' can good for long-term maintenance. Still, I think it's better to allow the shortcuts. Is there any difference between this and other generic operations (which could also benefit from types being more explicit and more checked)? [Not intended as a flame -- I'm curious to see if there's something makes some generics be worse than others.] As you probably guessed, I think that this is more of a coherent-language-design issue, but I bet someone could conduct some kind of a survey type thing to figure out what leads to more bugs or what programmers find confusing or something along those lines (ie, you decide on some concrete measure for worse and then conduct a study to try to answer that question). :) My own use of the for loops is usually without using the generic dispatch thing, similar to regexp functions. I get the feeling that you'd similarly want those to throw errors on strings and require an explicit `regexp' if you really want to use a string -- but there the reason is clearer: you have (regexp-match foo bar) and it's easy to mix the two -- so to avoid relying on my memory, I'd just use (regexp-match foo #rxbar) and let racket barf at me when I need to change the order. (And even TR won't save me there.) -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! _ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev
Re: [racket-dev] exact nonnegative integers as sequences?
At Mon, 18 Apr 2011 11:04:18 -0400, Eli Barzilay wrote: An hour and a half ago, Matthew Flatt wrote: I often write (for ([i (in-range N)]) ...) In cases where the loop overhead is not significant (i.e., I don't care whether the compiler can tell that I'm iterating through integers), it would be nice to write just What's the overhead? The same as using `(in-range N)' as a value: an indirection on the `(curry = N)' test, `add1' increment, and identity conversion from the loop index to the loop value. #lang racket (define N 100) (define N-range (in-range N)) (time (for/fold ([v 0]) ([i (in-range N)]) i)) ; cpu time: 4 real time: 3 gc time: 0 (time (for/fold ([v 0]) ([i N-range]) i)) ; cpu time: 103 real time: 103 gc time: 0 You have to be doing very little work in the loop body for the 100-nanosecond-per-iteration overhead to matter, though. _ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev
Re: [racket-dev] exact nonnegative integers as sequences?
FWIW, it would make sense to me if TR's regexp-match function accepted only regexps in the first argument (ditto for Racket and then Scracket could take strings (which of course are hashes mapping integers to chars)). Robby On Mon, Apr 18, 2011 at 10:09 AM, Eli Barzilay e...@barzilay.org wrote: Three minutes ago, Robby Findler wrote: On Mon, Apr 18, 2011 at 9:59 AM, Eli Barzilay e...@barzilay.org wrote: 9 minutes ago, Matthew Flatt wrote: Thanks for the clarifications, and I now agree that it's not about genericity. I think it's about scripts to programs, though. In a script, not having to type `(in-range )' or `(in-list )' feels worthwhile. You make a good point that those scriptish shortcuts can make understanding the code a little harder, and using `in-range' or `in-list' can good for long-term maintenance. Still, I think it's better to allow the shortcuts. Is there any difference between this and other generic operations (which could also benefit from types being more explicit and more checked)? [Not intended as a flame -- I'm curious to see if there's something makes some generics be worse than others.] As you probably guessed, I think that this is more of a coherent-language-design issue, but I bet someone could conduct some kind of a survey type thing to figure out what leads to more bugs or what programmers find confusing or something along those lines (ie, you decide on some concrete measure for worse and then conduct a study to try to answer that question). :) My own use of the for loops is usually without using the generic dispatch thing, similar to regexp functions. I get the feeling that you'd similarly want those to throw errors on strings and require an explicit `regexp' if you really want to use a string -- but there the reason is clearer: you have (regexp-match foo bar) and it's easy to mix the two -- so to avoid relying on my memory, I'd just use (regexp-match foo #rxbar) and let racket barf at me when I need to change the order. (And even TR won't save me there.) -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! _ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev
Re: [racket-dev] exact nonnegative integers as sequences?
Two minutes ago, Robby Findler wrote: FWIW, it would make sense to me if TR's regexp-match function accepted only regexps in the first argument (ditto for Racket and then Scracket could take strings (which of course are hashes mapping integers to chars)). I think that Sam's usual policy for that is to make things as close to Racket as possible. (And I think that it's a good policy in general.) As for Scratchit (obviously the right spelling), it does sound like a good idea, but the nice thing about the untyped - TR route is that you get to keep your code, whereas a Scratchit thing would be useless if you can't use the libraries. -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! _ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev
Re: [racket-dev] exact nonnegative integers as sequences?
On Mon, Apr 18, 2011 at 10:18 AM, Eli Barzilay e...@barzilay.org wrote: Two minutes ago, Robby Findler wrote: FWIW, it would make sense to me if TR's regexp-match function accepted only regexps in the first argument (ditto for Racket and then Scracket could take strings (which of course are hashes mapping integers to chars)). I think that Sam's usual policy for that is to make things as close to Racket as possible. (And I think that it's a good policy in general.) I know. As for Scratchit (obviously the right spelling), it does sound like a good idea, but the nice thing about the untyped - TR route is that you get to keep your code, whereas a Scratchit thing would be useless if you can't use the libraries. Yes, that would be in the plan. _ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev
Re: [racket-dev] exact nonnegative integers as sequences?
Which also raises an idea: now that TR is getting going, maybe we should have another step on this scripts-to-programs slope that is _lower_ than Racket. A language where we really only have one single datatype and everything just works on it, hashes being the obvious one (altho we probably should not _call_ them hashes; we should call them the scracket value or something). Guillaume's been doing all his programming lately with just such an infrastructure, and can't sing its praises enough. The associative table really is a powerful abstraction for lightweight programming, especially when combined with overloading of the form Matthew initially suggested. Shriram _ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev
Re: [racket-dev] exact nonnegative integers as sequences?
50 minutes ago, Robby Findler wrote: On Mon, Apr 18, 2011 at 10:18 AM, Eli Barzilay e...@barzilay.org wrote: As for Scratchit (obviously the right spelling), it does sound like a good idea, but the nice thing about the untyped - TR route is that you get to keep your code, whereas a Scratchit thing would be useless if you can't use the libraries. Yes, that would be in the plan. How would you do that? -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! _ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev
Re: [racket-dev] exact nonnegative integers as sequences?
I dunno. Do some search again-ing? On Mon, Apr 18, 2011 at 11:06 AM, Eli Barzilay e...@barzilay.org wrote: 50 minutes ago, Robby Findler wrote: On Mon, Apr 18, 2011 at 10:18 AM, Eli Barzilay e...@barzilay.org wrote: As for Scratchit (obviously the right spelling), it does sound like a good idea, but the nice thing about the untyped - TR route is that you get to keep your code, whereas a Scratchit thing would be useless if you can't use the libraries. Yes, that would be in the plan. How would you do that? -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! _ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev
Re: [racket-dev] exact nonnegative integers as sequences?
1. Racket should obviously use S-expressions as the one-and-only data structure. That's where we come from, and we're different that way. 2. I played with the idea of gluing code like that together some 10 years ago. The idea was to glue together units (no modules yet) where on one side you use lists to represent records and on the other you use generic structs. With the proper unit signature, you can actually do this -- as long as the unit adheres to the struct-like discipline. With types it might be possible to introduce this discipline on an 'assisted' basis. Say you have a unit that you want to structurize. You would change representations and the test suite plus the exceptions of the structure would guide you to the places where you mix representations. A Spidey-style type analysis could make this look better and perhaps better by default. _ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev