Hi!

I've been wondering whether there is some
coding style guideline for writing gnu smalltalk
code. It's mainly because I constantly wonder how
to indent. Especially with the new syntax.

This is an example, how would you indent it and the []?

   [
      [
         socket isNil
            ifTrue: [
               [
                  | conn |
                  trycnt := trycnt + 1.
                  socket := self connect.
                  trycnt := 0.
                  conn := self makeConnection: socket.
                  conn connect.
                  conn loop
               ] on: Error do: [:ex |
                  socket := nil.
                  PLog
                     logInfo: 'connection lost to ', host, ':',
                              port printString, ' because:',
                              ex description,', ', ex messageText.
                  Smalltalk backtrace.
                  ex return
               ].

               socket := nil.
               self delay: trycnt
            ]
      ] repeat
   ] fork

Some people on IRC told me a more lisp-ish style would be more
appropriate, 'no dangling brackets':

   [[socket isNil
      ifTrue:
         [
            [| conn |
            trycnt := trycnt + 1.
            socket := self connect.
            trycnt := 0.
            conn := self makeConnection: socket.
            conn connect.
            conn loop]
               on: Error
               do: [:ex |
                   socket := nil.
                   PLog
                   logInfo: 'connection lost to ' , host , ':'
                   , port printString
                   , ' because:' , ex description
                   , ', ' , ex messageText.
                   Smalltalk backtrace.
                   ex return].
         socket := nil.
         self delay: trycnt] ] repeat ] fork

This is of course more compact, but I consider the first example more
readable. Of course in the end it's a matter of taste. But what style
do you recommend?


_______________________________________________
help-smalltalk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to