Newbie problem with newLisp-gs

Q&A's, tips, howto's
Locked
techdir0
Posts: 10
Joined: Thu Dec 17, 2009 9:25 am
Location: Yorkshire, UK

Newbie problem with newLisp-gs

Post by techdir0 »

New to Lisp, and newLisp

Why does

Code: Select all

(setq res (parse (read-line))) 
produce expected result in command line version,
but return
( "(" "setq" "res" "(" "parse" "(" "read-line" ")" ")" ")" )

if entered in newLisp-gs?? that is, in the IDE.

I'm using v10.1.7 on WinXP

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Newbie problem with newLisp-gs

Post by Lutz »

When running newLISP-GS, the newLISP monitor process in the lower part of the IDE is controlled using STD I/O. This is why 'read-line' and other built-in functions processing STD I/O channels should only be used when running newLISP in a terminal shell.

Ps: welcome to newLISP

techdir0
Posts: 10
Joined: Thu Dec 17, 2009 9:25 am
Location: Yorkshire, UK

Re: Newbie problem with newLisp-gs

Post by techdir0 »

Thanks - I think I understand now what is going on.

Since my interest in newLisp is for natural language interaction, I guess I will work in a terminal until or unless I have a simple graphical interface for the user.

Kazimir Majorinc
Posts: 388
Joined: Thu May 08, 2008 1:24 am
Location: Croatia
Contact:

Re: Newbie problem with newLisp-gs

Post by Kazimir Majorinc »

You can find some ways around if you want to work from gs. for example

> (begin (setq z (read-line))(println "parse z=" (parse z)))
Hey man, what are you doing there?
parse z=("Hey" "man" "," "what" "are" "you" "doing" "there?")
("Hey" "man" "," "what" "are" "you" "doing" "there?")
>

techdir0
Posts: 10
Joined: Thu Dec 17, 2009 9:25 am
Location: Yorkshire, UK

Re: Newbie problem with newLisp-gs

Post by techdir0 »

Well, that would be useful, but it doesn't seem to work that way for me.

This is what happens to me

Code: Select all

(begin (setq z (read-line))(println "parse z= " (parse z)))
hey this is great
parse z= ("(" "begin" "(" "setq" "z" "(" "read-line" ")" ")" "(" "println" "parse z= " "(" 
 "parse" "z" ")" ")" ")")
("(" "begin" "(" "setq" "z" "(" "read-line" ")" ")" "(" "println" "parse z= " "(" 
 "parse" "z" ")" ")" ")")
> nil
nil
nil
nil
Am I missing something obvious here?

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Re: Newbie problem with newLisp-gs

Post by cormullion »

This works OK for me:

Code: Select all

$ newlisp
newLISP v.10.1.8 on OSX IPv4 UTF-8, execute 'newlisp -h' for more info.

>  (begin (setq z (read-line))(println "parse z= " (parse z)))
this seems to work ok in the terminal
parse z= ("this" "seems" "to" "work" "ok" "in" "the" "terminal")
("this" "seems" "to" "work" "ok" "in" "the" "terminal")
> 
although this is less noisy if you're using the terminal:

Code: Select all

> (set 'z (parse (read-line)))
this is a test
("this" "is" "a" "test")
> 
I confess I don't use newlisp-gs - i prefer the full-on editing environment of a text editor like BBEdit, using the terminal for interaction. I would - not very convincingly and only if pushed - argue that it's better to meet newLISP first of all in the simplest environment possible (the terminal), then move up to editors and stuff later. Something to do with cognitive loading... :)

Kazimir Majorinc
Posts: 388
Joined: Thu May 08, 2008 1:24 am
Location: Croatia
Contact:

Re: Newbie problem with newLisp-gs

Post by Kazimir Majorinc »

OK, techdir0, I understand why it didn't worked for you and worked for me.


1. Write (parse (read-line)) and press enter in editor part of IDE.
2. Select (with mouse) and copy (parse (read-line)) together with enter from editor part of IDE.
3. Paste in dialog part of IDE.
4. Write the statement you want parsed and press enter.
5. Goto 3.

---

Lutz will maybe fix it when he came back from travelling. I also use GS IDE only for short programs, and Scite for longer programs. I described how it can be customized for Newlisp in one post in blog.

techdir0
Posts: 10
Joined: Thu Dec 17, 2009 9:25 am
Location: Yorkshire, UK

Re: Newbie problem with newLisp-gs

Post by techdir0 »

That seems to work - thank you for finding it.

I think I will go along with the majority opinion, and stick to the terminal view. I expect I shall end up using TextPad as my
editor, since I'm used to it, and I can modify the syntax files to suit newLisp.

Locked