[gambit-list] I/O: read versus read-line and read-all

Joel J. Adamson jadamson at partners.org
Tue Apr 22 09:29:55 EDT 2008


Hello Gambitizers,

I have the following attached program that I'm working on.  It's
"Intelligent WTF", based on the BSD Games acronym finder called wtf.
I'm working on making it "intelligent," so that you can teach it new
acronyms.

That's where I'm getting tripped up.  The learning procedure
teach-new-acronym needs to read the new acronym from the keyboard at
line 174.  Here's what happens: ("iwtf is" is the prompt for an acronym
to look up)

============================================================

> (load "iwtf.scm")

iwtf is asdf
Wow, I really ought to know what "asdf" means.

I can learn a new acronym and place it in your private database, or
learn new synonyms for acronyms that I already know.  I put synonyms
in a local hidden file (starting with ".").


Please select from the following menu:
  
(0) Teach me, iwtf, a new acronym

(1) Teach me a synonym

(2) Look up a new acronym

(3) Exit iwtf altogether

Selection:
0

Type the new definition: 
iwtf is jkl
============================================================

What's happening there at "Type the new definition: " is that it returns
to top-level instead of waiting for user input.

I'm not really sure what's going on here.  I can create a simple program
that does what I would want this to do:

============================================================
#!/usr/bin/env gsi-script

(display (read-line))
(newline)
============================================================
/home/joel/lisp/scm/wtf: ZShell> test.scm
this is input! ; typed
this is input! ; output
============================================================

Am I asking for user input too late or too early in the
teach-new-acronym function?

I appreciate any pointers or suggestions on this problem, and any style
comments.

I promise this will go to the Dumping Grounds as soon as it's finished.

Thanks,
Joel

-- 
Joel J. Adamson
Biostatistician
Pediatric Psychopharmacology Research Unit
Massachusetts General Hospital
Boston, MA  02114
(617) 643-1432
(303) 880-3109
Public key: http://pgp.mit.edu


The information transmitted in this electronic communication is intended only
for the person or entity to whom it is addressed and may contain confidential
and/or privileged material. Any review, retransmission, dissemination or other
use of or taking of any action in reliance upon this information by persons or
entities other than the intended recipient is prohibited. If you received this
information in error, please contact the Compliance HelpLine at 800-856-1983 and
properly dispose of this information.


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: iwtf.scm
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20080422/e3d18c44/attachment.ksh>


More information about the Gambit-list mailing list