View all entries in Reflection

Martin Fowler’s Syntactic Noise

A possible translation of Martin Fowler's Syntactic Noise:

(state-machine idle 
  (events
    (door-closed D1CL)
    (draw-opened D2OP)
    (light-on    L1ON))

  (commands
    (lock-panel  PNLK)
    (unlock-door D1UL))

  (state idle
    (=> door-closed active)
    (actions unlock-door
             lock-panel))

  (state active
    (=> draw-opened waiting-for-light)
    (=> light-on    waiting-for-draw)))

Put in a blender together with about 3 dl macrology, mix well.


Responses

You can follow any responses to this entry through the RSS 2.0 feed.

  1. Robert Kasanicky said on June 24th, 2008 at 14:08 (link)

    Most of the ‘noisy’ parentheses are not strictly necessary, indentation alone can work too - see http://www.lispin.org/

  2. Mikael Jansson said on June 24th, 2008 at 14:17 (link)

    Three things:

    1. You already do look at the indentation level, and not the parens;
    2. … moreover, most people change the paren color so they are close to the background color, making them actually disappear (mine are dark gray against a black background);
    3. the output of the parens inserter is awful:

    (defun factorial (n)
      (if (<= n 1)
        (the 1
        )(* n
          (factorial (- n 1)
    ))))
    

    Nobody would indent their code nor place their parens like that. Instead, they would write:

    (defun factorial (n)
      (if (<= n 1)
          (the 1)
          (* n (factorial (- n 1)))))
    

    Frankly, I don’t see the point of the Lispin project. But, to each his own!

  3. Bill Birch said on July 31st, 2008 at 15:08 (link)

    Yes there are two kinds of programmers those who are happy with () and those that ain’t.
    Personally I was happy with most of the (), but it puts off most developers, including
    many THWers! Hence I decided to build a parser which removed most of the parens so the majority of coders would not turn up their noses.

    The latest incarnation is in Genyris (http://sourceforge.net/projects/genyris/). This time the language is modified to suit indentation’s constraints, it looks like Ruby without ends. The rule is: If the indentation looks right the code will be too.

    e.g.

    class Person ()
       def !valid? (obj)
          obj
             bound? !age
     
    class Boomer (Person)
       def !valid? (obj)
          obj
             between 45 !age 60
     
    class Hippie (Boomer)
       def !valid? (obj)
          obj
             bound? !bong
     
    define noel
      dict
         !name: "Noel"
         !age: 49
         !bong: true
     
    classify Person noel
     
    assert
      and
        is-instance? noel Hippie
    
  4. Bill Birch said on July 31st, 2008 at 15:16 (link)

    So MF’s example in Genyris:

    state-machine idle 
      events
        door-closed D1CL
        draw-opened D2OP
        light-on    L1ON
     
      commands
        lock-panel  PNLK
        unlock-door D1UL
     
      state idle
        = door-closed active
        actions unlock-door lock-panel
     
      state active
        = draw-opened waiting-for-light
        = light-on    waiting-for-draw
    

    Which is more readable to a non-Lisper?

  5. Mikael Jansson said on October 2nd, 2008 at 14:10 (link)

    Looks alright, but the question is how user-extensible it is. Can you do macros?

  6. Bill Birch said on October 5th, 2008 at 03:55 (link)

    Yes. Macros and templates.

If this is the first time you comment on my site, your post might get held up in the moderation queue. Don't panic, I'll approve it as soon as possible!

Code (i.e. literal) blocks should be wrapped inside <PRE>.

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Close
Powered by ShareThis