Students who are trying to learn Nim complain that Emacs modes for Nim do not 
work flawlessly, and are huge. These students tried nimrod-mode and nim-mode. 
Here are a small sample of the problems that they encountered:

1 -- nimrod-mode does not highlight multiline comments.

2 -- nim-mode often fails in performing indentation. For instance, in the 
listing below, if I place the cursor in front of the for loop colon and press 
<Enter>, the part of the text that is after the colon goes to the beginning of 
the line:
    
    
    proc fib(n: int): int =
      var (r1, r2) = (1, 1)
      for i in 2..n: (r1,r2) = (r1+r2, r1)
      result= r1
    
    
    Run

The result of pressing <Enter> after the for-loop colon is shown below:
    
    
    proc fib(n: int): int =
      var (r1, r2) = (1, 1)
      for i in 2..n:
    (r1,r2) = (r1+r2, r1)
      result= r1
    
    
    Run

Interesting enough, indentation works in the absence of parenthesis. In the 
following list, if I press <Enter> after the colon, nim-mode indents correctly.
    
    
    proc fb(n: int): int =
      if n<2: result=1
      elif n<3:
        result=n
      else:
        result= fb(n-3)+fb(n-2)+fb(n-2)
    
    
    Run

Here is the result:
    
    
    proc fb(n: int): int =
      if n<2:
        result=1
      elif n<3:
        result=n
      else:
        result= fb(n-3)+fb(n-2)+fb(n-2)
    
    
    
    Run

By the way, python-mode performs the indentation without a flinch:
    
    
    def fib(n):
      (r1, r2) = (1, 1)
      for i in range(1,n+1):(r1,r2) = (r1+r2, r1)
      return r1
    
    
    Run

Here is the result of pressing <Enter> :
    
    
    def fib(n):
      (r1, r2) = (1, 1)
      for i in range(1,n+1):
        (r1,r2) = (r1+r2, r1)
      return r1
    
    
    Run

Since the nim-mode program is huge, the students were not able to fix the bugs 
that they find now and then. Therefore, they switched to lem. If somebody 
publishes a small program that performs highlighting and indentation correctly 
in Emacs, it will be easy to make the transition from lem back to Emacs, since 
the two editors are very similar. 

Reply via email to