Re: [racket-dev] A few suggestions on indentation and DrRacket graphical syntax
On Sat, May 12, 2012 at 12:49 AM, Eli Barzilay e...@barzilay.org wrote: 5 hours ago, Neil Toronto wrote: On 05/09/2012 02:18 AM, Laurent wrote: From the guide: Caveat 1: Until language specifications come with fixed indentation rules, we need to use the default settings of DrRacket’s indentation for this rule to make sense. Maybe a special submodule like drracket-indentation with declarations like: (module+ drracket-indentation (like-lambda my-lambda my-function ) (like-begin my-begin ) ) could be useful for user-specific indentation. As a submodule, Racket can readload it only at appropriate moments. When indenting the file, DrRacket could first load the drracket-indentation module of the file to know how to indent it. One could then create a whole language with its own indentation rules. It would also be easier to add good indentations for for/fold and others. That would be awesome for Typed Racket macros in particular. Its `for' macros are great examples of forms that should have fairly complex indentation rules. Optional type declarations make it difficult to classify them as begin-like, define-like or lambda-like. That kind of indentation specification is more fitting in the language info, together with coloring etc. Probably. But how can the user specify its own rules then? (genuine question, I don't know where the language info lies, and how it can be extended) For specific macros in some random file something that I suggested in the past could work better: have an ability to use sub-namespaces where an identifier can have a number of related bindings -- so you could define `foo' and some `foo@indent' (or whatever) which specifies indentation. The reason that this would work better is that any context that receives the `foo' binding would also get its indentation. Interesting idea. Could sub-namespaces be loaded independently from the main identifier, in case you don't need it? Anyway, submodules already exists, hence my suggestion. Eg, think about providing it as `bar' -- if the rules are in a sub-module, then it won't work unless you construct your own sub-module. Unless `bar' knows its real name is `foo'? (which it does, maybe?) Currently, DrRacket does not seem to be able to do this anyway (which may be why you proposed sub-namespaces?): #lang racket (require (rename-in racket [define gabuzomeu])) (gabuzomeu (foo bar) (list bar)) So probably sub-moduled indentation rules would be a less important change than adding sub-namespaces, and thus requires less work which makes it more probable to appear in a near future? Laurent _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] A few suggestions on indentation and DrRacket graphical syntax
On 05/09/2012 02:18 AM, Laurent wrote: From the guide: Caveat 1: Until language specifications come with fixed indentation rules, we need to use the default settings of DrRacket’s indentation for this rule to make sense. Maybe a special submodule like drracket-indentation with declarations like: (module+ drracket-indentation (like-lambda my-lambda my-function ) (like-begin my-begin ) ) could be useful for user-specific indentation. As a submodule, Racket can readload it only at appropriate moments. When indenting the file, DrRacket could first load the drracket-indentation module of the file to know how to indent it. One could then create a whole language with its own indentation rules. It would also be easier to add good indentations for for/fold and others. That would be awesome for Typed Racket macros in particular. Its `for' macros are great examples of forms that should have fairly complex indentation rules. Optional type declarations make it difficult to classify them as begin-like, define-like or lambda-like. Neil ⊥ _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] A few suggestions on indentation and DrRacket graphical syntax
5 hours ago, Neil Toronto wrote: On 05/09/2012 02:18 AM, Laurent wrote: From the guide: Caveat 1: Until language specifications come with fixed indentation rules, we need to use the default settings of DrRacket’s indentation for this rule to make sense. Maybe a special submodule like drracket-indentation with declarations like: (module+ drracket-indentation (like-lambda my-lambda my-function ) (like-begin my-begin ) ) could be useful for user-specific indentation. As a submodule, Racket can readload it only at appropriate moments. When indenting the file, DrRacket could first load the drracket-indentation module of the file to know how to indent it. One could then create a whole language with its own indentation rules. It would also be easier to add good indentations for for/fold and others. That would be awesome for Typed Racket macros in particular. Its `for' macros are great examples of forms that should have fairly complex indentation rules. Optional type declarations make it difficult to classify them as begin-like, define-like or lambda-like. That kind of indentation specification is more fitting in the language info, together with coloring etc. For specific macros in some random file something that I suggested in the past could work better: have an ability to use sub-namespaces where an identifier can have a number of related bindings -- so you could define `foo' and some `foo@indent' (or whatever) which specifies indentation. The reason that this would work better is that any context that receives the `foo' binding would also get its indentation. Eg, think about providing it as `bar' -- if the rules are in a sub-module, then it won't work unless you construct your own sub-module. -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] A few suggestions on indentation and DrRacket graphical syntax
* Line-width In GEdit, there's an option to show a thin vertical line at 80 chars (modifiable number). I find it of great help to avoid writing long lines, which I tend to not do otherwise or often (inconveniently) look at the column number to see where I am. Such a vertical line might be a good idea for DrRacket. Laurent On Wed, May 9, 2012 at 10:18 AM, Laurent laurent.ors...@gmail.com wrote: Hi, Reading the style guide for Racket, I came up with a few debatable suggestions. ( http://www.ccs.neu.edu/home/matthias/Style/style/Textual_Matters.html ) Apologies if this has already been longly debated. * Indentation: adding new indentations constructs to DrRacket From the guide: Caveat 1: Until language specifications come with fixed indentation rules, we need to use the default settings of DrRacket’s indentation for this rule to make sense. Maybe a special submodule like drracket-indentation with declarations like: (module+ drracket-indentation (like-lambda my-lambda my-function ) (like-begin my-begin ) ) could be useful for user-specific indentation. As a submodule, Racket can readload it only at appropriate moments. When indenting the file, DrRacket could first load the drracket-indentation module of the file to know how to indent it. One could then create a whole language with its own indentation rules. It would also be easier to add good indentations for for/fold and others. * Graphical syntax When we figure out how to save such files in an editor-compatible way, we may relax this constraint. Maybe the graphical job should be done by DrRacket only, and the file itself should remain textual. For example, special forms can be turned into graphics by DrRacket when reading the file: You write: (image balloon.jpg) and DrRacket turns this into the image (if the option is turned on somewhere in the preferences). Of course, the s-exp should still be editable, for example with a contextual menu that proposes Back to s-exp or Turn me into graphical form. Or even surround it with a form like (drracket-show-image (image balloon.jpg) 48 48) for better rendering (that form obviously expands into (image balloon.jpg) for Racket). Same for code folding, 2 options: - either surround s-exps with a (drracket-fold ) form to inform DrRacket to fold the s-exp, and Racket to just do what's inside the form, (but that pollutes the file for external editors, though an `unfold-file' function should not be too difficult to do) - or do not save folding into the file (loading a file displays it unfolded, then it can be folded as desired). This might be problematic with DrSync though, unless the file is not reverted if it has not changed. But I agree all this would require some work, certainly. Laurent _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] A few suggestions on indentation and DrRacket graphical syntax
Laurent wrote at 05/09/2012 06:55 AM: * Line-width In GEdit, there's an option to show a thin vertical line at 80 chars (modifiable number). I find it of great help to avoid writing long lines, which I tend to not do otherwise or often (inconveniently) look at the column number to see where I am. Such a vertical line might be a good idea for DrRacket. This has come up before. I doubt anyone would complain if someone implemented this and made it optional. Some people (including me) would very much like it. I think that the least-controversial default preference settings would be 80 characters, light gray, and disabled. Neil V. _ Racket Developers list: http://lists.racket-lang.org/dev