Wednesday, May 13, 2009

telnet protocol impl for scsh

I'm trying to port telnetlib from lisp to scheme for scsh. Code is hosted here and yes, its a work-in-progress, I work on it mostly during the weekend only. Anyway, from this exercise I've certainly observed following...

  • Lisp is just so feature rich. Its taking many workarounds to (almost)direct port telnetlib from lisp to scheme.

  • Domain knowledge is important. I always thought it was easy to understand the domain and I could just start with anything and I started this project without knowing much about telnet protocol itself and Now I realise that to do it I *have* to understand the nuances of it.



[Update] Its completed.

7 comments:

  1. "Lisp is just so feature rich. Its taking many workarounds to (almost)direct port telnetlib from lisp to scheme."

    unless you are using some particularly available-in-lisp-only library, this doesn't sound valid.

    Besides which you shouldn't be "direct porting" ;-).

    Understand the telnet protocol (independent of language) and then use the scheme native idioms to implement. Use the lisp library as a reference only. my 2 cents!

    ReplyDelete
  2. thanks, I realised that "direct porting" was not gonna work and hence it changed into "(almost)direct" porting.

    BTW, the features which make life easy in lisp(from this exercise it seems atleast) are &key, &optional in the procedure parameters; a very intelligent format function; loop macro and availability of return and return-from to unconditionally exit the procedure.

    ReplyDelete
  3. "&key, &optional in the procedure parameters; "

    This is justa differents style of formatting and when you shift t thinking in scheme (vs writing lisp in scheme) you'll be all right ;-)

    "a very intelligent format function;"

    yes this is a convenience, but people do write substabtial code with System.out.println ;-)


    "loop macro"

    This is one of the most grungy pieces of lisp. In scheme you should be using recursion to get iteration


    "availability of return and return-from to unconditionally exit the procedure"

    Agin this is fine *in lisp*. How would you code the same functionality in say Oz or HAskell, let alone scheme.

    I guess what I am saying code with the grain of the language, not against it!

    ReplyDelete
  4. aargh i meant different style of *programming* not formatting

    ReplyDelete
  5. Just putting a link to your blog-entry : http://runningupstairs.blogspot.com/2009/05/some-guidelines-on-porting.html

    very relevant(to this thread) and informative. I can pretty much "feel" 1st, 2nd and 3rd rule. :)

    ReplyDelete
  6. For using recursion for iteration. I know it works fine(and very functional) but I guess a do-while or do-until sort of wrapper(can be a macro that in turn uses recursion, and I like loop bcoz it can pretty much do all those loopings) makes the intent clear for a person reading the code.... just my thoughts :)

    ReplyDelete
  7. "Liking loop" is good *in Common Lisp* ;-)

    When using scheme, use "scheme- isms". As you rightly said, if you think do until" etc is needed to make intent clear, write a scheme function/macro/whtever it takes.

    ReplyDelete