On 18 Jun 2007, at 2:05 am, Jacob Rus wrote:
I think that all sounds great. I have only done a very little bit of scheme. I added a bit to the run command about a year ago to make it also work with guile set as the TM_SCHEME_INTERPRETER, and then I think added a bit of stuff to the language grammar, particularly to make it work with Lilypond (which is a music engraving description language which uses embedded scheme for customization).
Ah, cool. I was wondering if anybody did any DSSSL, too.
What I have so far is at http://love.warhead.org.uk/~alaric/ Scheme.tmbundle.tar.gz - extract that into ~/Library/Application Support/TextMate/Bundles; make sure you already have the Scheme bundle installed in /Library/... since my bundle is just a delta to that.
In addition to work on the bundle as it exists now in TM1, it would be very useful for Scheme/Lisp users to add input (i.e. talk to allan) about how the indentation/folding system could be modified/ extended for better support of languages with Lisp-like syntax.
Yeah...
The fun part is that it's normal to stack the 'end' symbols on one line.
Ruby:
def foo ... if bar foo.each do ... end else ... end ... end
Scheme:
(define (foo) (if bar (map foo ...) (...)))
^ ends the (..., the if, and the define, all in one
Funnily enough, this causes a problem with how the folding symbols are put in the left hand margin.
As for indentation - here's a few examples of normal approaches:
This is the standard indent rule, used after a line with more (s and ) s in:
(define (foo x) (body indented one standard indent))
But sometimes you're expected to make things line up neatly:
(if items lined up)
(cond ((= x 1) something) ((= x 22) something else lined up) ((= x (* y 2)) somethine else yet but still lined up)
In both of those cases, on the line before the indent, you have a "last unmatched left parens"; on the cond example, the ((= x 1) something) balanced, so the last unmatched is the one before cond, and on the if case, it's the one before if. The correct point to indent to is the character AFTER the whitespace AFTER the last unmatched left parenthesis. I think.
Let (and its many variants) are a bit special:
(let ((bindings 1) (lined 2) (up 3)) (body indented one standard indent))
Not quite sure how I'd express that as a rule!
When the arms of a cond get too long, you usually put a line break in and return to standard indenting rules:
(cond ((= x 1) one standard ndent) ((= x 22) still all lined up) ((= x (* y 2)) but on a standard indent not some other marker)
Cheers! Jacob
ABS
-- Alaric Snell-Pym Work: http://www.snell-systems.co.uk/ Play: http://www.snell-pym.org.uk/alaric/ Blog: http://www.snell-pym.org.uk/?author=4