home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group91a.txt
< prev
next >
Wrap
Internet Message Format
|
1991-06-13
|
433KB
From fps!mis.mcw.edu!mis.mcw.edu!TENAGLIA@uwm.edu Tue Jan 1 09:42:36 1991
Received: from uwm.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA00177; Tue, 1 Jan 91 09:42:36 -0700
Received: by uwm.edu; id AA01354; Tue, 1 Jan 91 08:34:39 -0600
Received: from mis.mcw.edu by fps.mcw.edu (DECUS UUCP ///1.2a/2.5/);
Tue, 1 Jan 91 08:01:24 CDT
Received: by mis.mcw.edu with UUCP/PMDF (DECUS UUCP);
Tue, 1 Jan 1991 07:32 CST
Date: Tue, 1 Jan 1991 07:31 CST
From: Chris Tenaglia - 257-8765 <TENAGLIA@mis.mcw.edu>
Subject: Happy New Year ! Black Jack Game.
To: icon-group@cs.arizona.edu
Message-Id: <C3284CA4006019D9@mis.mcw.edu>
X-Organization: Medical College of Wisconsin MIS Department (Milwaukee, WI)
X-Envelope-To: icon-group@cs.arizona.edu
X-Vms-To: IN%"icon-group@cs.arizona.edu"
Happy New Year! After considering all the good advice on the draw poker game
I kloojed together a simple version of black jack. It's about 291 lines.
The shuffling on the draw poker game also wasn't very good, so this game
uses the technique in the IPL which I think is more correct anyway. Enjoy!
Yours truly,
Chris Tenaglia (System Manager) | Medical College of Wisconsin
8701 W. Watertown Plank Rd. | Milwaukee, WI 53226
(414)257-8765 | tenaglia@mis.mcw.edu, mcwmis!tenaglia
#########################################################
# #
# BJ.ICN 12/19/90 BY TENAGLIA #
# #
# SIMPLE BUT FUN BLACK JACK GAME. WORKS ON ANSI SCREEN. #
# USAGE : iconx bj [starting credits] #
# #
#########################################################
global deck, message, lookup,
user_money, host_money,
user_hand, host_hand
procedure main(param)
user_money := integer(param[1]) | 3 ; host_money := user_money
write(screen("cls")," ",screen("top"),screen("hinv"),
"BLACK JACK",screen("norm"))
write(" ",screen("bot"),screen("hinv"),
"BLACK JACK",screen("norm"))
bonus := 0
repeat
{
if not any('y',(map(input(at(1,4) || screen("under") ||
"Want to play? y/n :"|| screen("norm") ||
screen("eeol")))[1])) then break
writes(at(1,4),screen("eeos"))
display_score()
deck := shuffle()
message := ""
user_hand := [] ; host_hand := []
put(user_hand,pop(deck)) ; put(host_hand,pop(deck))
put(user_hand,pop(deck)) ; put(host_hand,pop(deck))
user_points := first(host_hand[1])
if user_points > 21 then
{
writes(at(1,14),user_points," points. You went over. You loose.")
user_money -:= 1 ; host_money +:= 1 + bonus ; bonus := 0
display_score()
next
}
display_host(2)
host_points := second(user_points)
if host_points > 21 then
{
writes(at(50,23),host_points," points. ",&host," went over.")
writes(at(1,14),screen("hiblink"),"You win.",screen("norm"))
host_money -:= 1 ; user_money +:= 1 + bonus ; bonus := 0
display_score()
next
}
if host_points = user_points then
{
writes(at(1,23),screen("hiblink"),"It's a draw at ",user_points,
". The ANTY goes to bonus.",screen("norm"))
bonus +:= 2 ; host_money -:= 1 ; user_money -:= 1
display_score()
next
}
writes(at(20,13),user_points," points for user.")
writes(at(1,15),host_points," points for ",&host)
if user_points < host_points then
{
write(at(1,23),screen("hiblink"),&host," wins.",
screen("norm"),screen("eeol"))
user_money -:= 1 ; host_money +:= 1 + bonus ; bonus := 0
display_score()
next
} else {
writes(at(1,13),screen("hiblink"),"You win.",screen("norm"),screen("eeol"))
user_money +:= 1 + bonus ; host_money -:= 1 ; bonus := 0
display_score()
next
}
}
write(screen("clear"))
end
#
# THIS PROCEDURE ALLOWS THE USER TO PLAY AND TAKE HITS
#
procedure first(host_card)
display_user()
display_host(1)
points := value(user_hand) # just in case
writes(at(1,10),"(",points,") ")
repeat
if any('hy',map(input(at(1,23) || "Hit ? y/n :" || screen("eeol")))) then
{
put(user_hand,pop(deck))
display_user()
if (points := value(user_hand)) > 21 then return points
writes(at(1,10),"(",points,") ")
} else break
(points > 0) | (points := value(user_hand))
writes(at(1,10),"(",points,") ")
write(at(60,12),"You stay with ",points)
return points
end
#
# THIS SECOND PROCEDURE IS THE HOST PLAYING AGAINST THE USER
#
procedure second(ceiling)
static limits
initial limits := [14,14,15,15,19,16,17,18]
stop_at := ?limits ; points := 0
until (points := value(host_hand)) > stop_at do
{
if points > ceiling then return points
writes(at(1,20),"(",points,") ")
write(at(1,23),screen("eeol"),&host," will take a hit.",screen("eeol"))
put(host_hand,pop(deck))
display_host(2)
}
(points > 0) | (points := value(host_hand))
writes(at(1,20),"(",points,") ")
return points
end
#
# THIS ROUTINE DISPLAYS THE CURRENT SCORE
#
procedure display_score()
writes(screen("nocursor"))
writes(screen("dim"),at(1,8),"Credits",screen("norm"))
writes(screen("high"),at(1,9),right(user_money,7),screen("norm"))
writes(screen("dim"),at(1,18),"Credits",screen("norm"))
writes(screen("high"),at(1,19),right(host_money,7),screen("norm"))
end
#
# THIS PROCEDURE EVALUATES THE POINTS OF A HAND. IT TRIES TO MAKE THEM
# AS HIGH AS POSSIBLE WITHOUT GOING OVER 21.
#
procedure value(sample)
hand := copy(sample)
possible := []
repeat
{
sum := 0
every card := !hand do sum +:= lookup[card[1]]
put(possible,sum)
if Aces(hand) == "none" then break else
every i := 1 to *hand do if hand[i][1] == "A" then hand[i][1] := "a"
}
every score := !possible do
if score <= 21 then return score
return possible[1]
end
#
# ARE THERE ANY 11 POINT ACES LEFT IN HAND
#
procedure Aces(cards)
every look := !cards do if look[1] == "A" then return "some"
return "none"
end
#
# THIS ROUTINE DISPLAYS THE USER HAND AND STATUS
#
procedure display_user()
writes(screen("nocursor"),at(4,7),screen("hinv"),"USER",screen("norm"))
x := 10 ; y := 5
every card := !user_hand do
{
display(card,x,y)
x +:= 7
}
end
#
# THIS ROUTINE DISPLAYS THE HOST HAND AND STATUS
#
procedure display_host(flag)
writes(screen("nocursor"),at(1,17),screen("hinv"),&host,screen("norm"))
x := 10 ; y := 15 ; /flag := 0
every card := !host_hand do
{
if (flag=1) & (x=10) then card := "XX"
display(card,x,y)
x +:= 7
}
end
#
# THIS ROUTINE DISPLAYS A GIVEN CARD AT A GIVEN X,Y SCREEN LOCATION
#
procedure display(card,x,y)
all := [] ; j := y
if find(card[2],"CS") then card := screen("hinv") || card || screen("norm")
shape := [at(x,(j+:=1)) || screen("gchar") || "lqqqqqqqk"]
put(shape,at(x,(j+:=1)) || "x " || card || " x")
put(shape,at(x,(j+:=1)) || "x x")
put(shape,at(x,(j+:=1)) || "x x")
put(shape,at(x,(j+:=1)) || "x x")
put(shape,at(x,(j+:=1)) || "x " || card || " x")
put(shape,at(x,(j+:=1)) || "mqqqqqqqj" || screen("nchar"))
put(all,shape)
x +:= 14
while shape := pop(all) do every writes(!shape)
end
#
# THIS ROUTINE SHUFFLES THE CARD DECK
#
procedure shuffle()
static faces, suits
local cards, i
initial {
&random := map(&clock,":","7") # initial on multiple shuffles
faces := ["2","3","4","5","6","7","8","9","T","J","Q","K","A"]
suits := ["D","H","C","S"]
lookup := table(0)
every i := 2 to 9 do insert(lookup,string(i),i)
insert(lookup,"T",10)
insert(lookup,"J",10)
insert(lookup,"Q",10)
insert(lookup,"K",10)
insert(lookup,"A",11)
insert(lookup,"a",1)
}
cards := []
every put(cards,!faces || !suits)
every i := *cards to 2 by -1 do cards[?i] :=: cards[i]
return cards
end
#
# THIS ROUTINE PARSES A STRING WITH RESPECT TO SOME DELIMITER
#
procedure parse(line,delims)
static chars
chars := &cset -- delims
tokens := []
line ? while tab(upto(chars)) do put(tokens,tab(many(chars)))
return tokens
end
#
# THIS ROUTINE PROMPTS FOR INPUT AND RETURNS A STRING
#
procedure input(prompt)
writes(screen("cursor"),prompt)
return read()
end
#
# THIS ROUTINE SETS THE VIDEO OUTPUT ATTRIBUTES FOR VT102 OR LATER
# COMPATIBLE TERMINALS.
#
procedure screen(attr)
case attr of
{
"cls" : return "\e[2J\e[H" # CLEAR SCREEN
"clear": return "\e[2J\e[H" # CLEAR SCREEN
"top" : return "\e#3" # UPPER HALF CHARACTERS
"bot" : return "\e#4" # LOWER HALF CHARACTERS
"fat" : return "\e#6" # SINGLE HEIGHT FAT LETTERS
"thin" : return "\e#5" # NORMAL SIZED CHARACTERS
"hinv" : return "\e[1;7m" # HIGH INTENSITY & INVERSE
"norm" : return "\e[m" # RESTORE NORMAL VIDEO ATTRIBUTES
"dim" : return "\e[2m" # LOW INTENSITY VIDEO
"blink": return "\e[5m" # VIDEO BLINKING ATTRIBUTE
"hiblink": return "\e[1;5m" # HIGH INTENSITY BLINKING
"under": return "\e[4m" # VIDEO UNDERLINING ATTRIBUTE
"high" : return "\e[1m" # VIDEO HIGH INTENSITY ATTRIBUTE
"inv" : return "\e[7m" # VIDEO INVERSE ATTRIBUTE
"eeol" : return "\e[K" # ERASE TO END OF LINE
"esol" : return "\e[1K" # ERASE TO START OF LINE
"eeos" : return "\e[J" # ERASE TO END OF SCREEN
"gchar": return "\e(0" # TURN ON ANSI GRAPHICS MODE
"nchar": return "\e(B" # TURN OFF ANSI GRAPHICS MODE
"light": return "\e[?5h" # LIGHT COLORED SCREEN
"dark" : return "\e[?5l" # DARK COLORED SCREEN
"80" : return "\e[?3l" # 80 COLUMNS ON SCREEN
"132" : return "\e[?3h" # 132 COLUMNS ON SCREEN
"smooth": return "\e[?4h" # SMOOTH SCREEN SCROLLING
"jump" : return "\e[?4l" # JUMP SCREEN SCROLLING
"cursor": return "\e[?25h" # MAKE SURE CURSOR IS VISIBLE
"nocursor": return "\e[?25l" # HIDE THE CURSOR
default: return "("||attr||")"
}
end
#
# THIS ROUTINE SETS THE CURSOR TO A GIVEN X (COL) Y(ROW) SCREEN LOCATION
#
procedure at(x,y)
return "\e[" || y || ";" || x || "f"
end
From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS Tue Jan 1 20:06:36 1991
Received: from umich.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA12591; Tue, 1 Jan 91 20:06:36 -0700
Received: from um.cc.umich.edu by umich.edu (5.61/1123-1.0)
id AA04966; Tue, 1 Jan 91 22:06:27 -0500
Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Tue, 1 Jan 91 22:03:41 EST
Date: Tue, 1 Jan 91 16:34:36 EST
From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
To: icon-group@cs.arizona.edu
Message-Id: <281696@Wayne-MTS>
Subject: Message conventions
This isn't exactly an Icon question, but.....
I've noticed that in many of the postings to icon-group, the messages have
excerpts from previous messages preceded by "> ". Could anyone let me know
what software you're using to get this effect, and how you're using it?
Thanks.
Paul Abrahams
abrahams%wayne-mts@um.cc.umich.edu
From icon-group-request@arizona.edu Tue Jan 1 21:52:02 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA14616; Tue, 1 Jan 91 21:52:02 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu; Tue, 1 Jan 91 21:51 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA29802; Tue, 1 Jan 91 20:44:27
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Tue, 1 Jan 91 21:51 MST
Date: 2 Jan 91 02:56:21 GMT
From: netnews.upenn.edu!msuinfo!midway!quads.uchicago.edu!goer@rutgers.edu
Subject: bj, part 3 of 3
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <DEC4BED6C699400483@Arizona.edu>
Message-Id: <1991Jan2.025621.21511@midway.uchicago.edu>
Organization: University of Chicago
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
References: <1991Jan2.025428.21379@midway.uchicago.edu>
stty: Operation not supported on socket
---- Cut Here and feed the following to sh ----
#!/bin/sh
# this is bj.03 (part 3 of a multipart archive)
# do not concatenate these parts, unpack them in order with /bin/sh
# file itlibdos.icn continued
#
if test ! -r _shar_seq_.tmp; then
echo 'Please unpack part 1 first!'
exit 1
fi
(read Scheck
if test "$Scheck" != 3; then
echo Please unpack part "$Scheck" next!
exit 1
else
exit 0
fi
) < _shar_seq_.tmp || exit 1
if test ! -f _shar_wnt_.tmp; then
echo 'x - still skipping itlibdos.icn'
else
echo 'x - continuing file itlibdos.icn'
sed 's/^X//' << 'SHAR_EOF' >> 'itlibdos.icn' &&
X range := "(" || tc_table["co"]-1 || "," || tc_table["li"]-1 || ")"
X er("igoto",colline || " out of range " || (\range|""),9)
X }
X
X # Use the Iconish 1;1 upper left corner & not the C-ish 0 offsets
X increment := -1
X outstr := ""
X
X cm ? {
X while outstr ||:= tab(find("%")) do {
X tab(match("%"))
X chr := move(1)
X if case chr of {
X "." : outstr ||:= char(line + increment)
X "+" : outstr ||:= char(line + ord(move(1)) + increment)
X "d" : {
X str := string(line + increment)
X outstr ||:= right(str, integer(tab(any('23'))), "0") | str
X }
X }
X then line :=: col
X else {
X case chr of {
X "n" : line := ixor(line,96) & col := ixor(col,96)
X "i" : increment := 0
X "r" : line :=: col
X "%" : outstr ||:= "%"
X "B" : line := ior(ishift(line / 10, 4), line % 10)
X ">" : {
X x := move(1); y := move(1)
X line > ord(x) & line +:= ord(y)
X &null
X }
X } | er("goto","bad termcap entry",5)
X }
X }
X return outstr || tab(0)
X }
X
Xend
X
X
X
Xprocedure iputs(cp, affcnt)
X
X # Writes cp to the screen. Use this instead of writes() for
X # compatibility with the Unix version (which will need to send
X # null padding in some cases). Iputs() also does a useful type
X # check.
X
X static num_chars
X initial num_chars := &digits ++ '.'
X
X type(cp) == "string" |
X er("iputs","you can't iputs() a non-string value!",10)
X
X cp ? {
X if tab(many(num_chars)) & ="*" then
X stop("iputs: MS-DOS termcap files shouldn't specify padding.")
X writes(tab(0))
X }
X
X return
X
Xend
SHAR_EOF
echo 'File itlibdos.icn is complete' &&
true || echo 'restore of itlibdos.icn failed'
rm -f _shar_wnt_.tmp
fi
# ============= termcap.dos ==============
if test -f 'termcap.dos' -a X"$1" != X"-c"; then
echo 'x - skipping termcap.dos (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting termcap.dos (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'termcap.dos' &&
Xansi|color|ansi-color|ibm|ibmpc|ANSI.SYS color:\
X :co#80:li#24:bs:pt:bl=^G:le=^H:do=^J:\
X :cl=\E[H\E[2J:ce=\E[K:\
X :ho=\E[H:cm=\E[%i%d;%dH:\
X :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
X :ti=\E[0;44m:te=\E[0m:\
X :so=\E[1;35;44m:se=\E[0;44m:\
X :us=\E[1;31;44m:ue=\E[0;44m:\
X :mb=\E[5m:md=\E[1m:me=\E[0;44m:
Xmono|ansi-mono|ANSI.SYS:\
X :co#80:li#24:bs:pt:bl=^G:le=^H:do=^J:\
X :cl=\E[H\E[2J:ce=\E[K:\
X :ho=\E[H:cm=\E[%i%d;%dH:\
X :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
X :so=\E[1m:se=\E[m:us=\E[4m:ue=\E[m:\
X :mb=\E[5m:md=\E[1m:me=\E[m:
Xnnansi-mono|NNANSI.SYS:\
X :co#80:li#25:bs:pt:bl=^G:le=^H:do=^J:\
X :cl=\E[2J:cd=\E[J:ce=\E[K:\
X :ho=\E[H:cm=\E[%i%d;%dH:\
X :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
X :so=\E[1m:se=\E[2m:\
X :us=\E[4m:ue=\E[24m:\
X :mb=\E[5m:md=\E[1m:mh=\E[2m:mr=\E[7m:me=\E[m:\
X :al=\E[L:dl=\E[M:ic=\E[@:dc=\E[P:
Xnnansi|nnansi-color|NNANSI.SYS color:\
X :co#80:li#25:bs:pt:bl=^G:le=^H:do=^J:\
X :cl=\E[2J:cd=\E[J:ce=\E[K:\
X :ho=\E[H:cm=\E[%i%d;%dH:\
X :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
X :ti=\E[0;44m:te=\E[0m:\
X :so=\E[1;35;44m:se=\E[2;37m:\
X :us=\E[4m:ue=\E[24m:\
X :mb=\E[5m:md=\E[1m:mh=\E[2m:mr=\E[7m:me=\E[0;44m:\
X :al=\E[L:dl=\E[M:ic=\E[@:dc=\E[P:
Xnansi-mono|zansi-mono|N/ZANSI.SYS:\
X :co#80:li#25:bs:pt:bl=^G:le=^H:do=^J:\
X :cl=\E[2J:ce=\E[K:\
X :ho=\E[H:cm=\E[%i%d;%dH:\
X :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
X :ti=\E[0m:te=\E[0m:\
X :so=\E[1;35m:se=\E[0m:\
X :us=\E[1;31m:ue=\E[0m:\
X :mb=\E[5m:md=\E[1m:mr=\E[7m:me=\E[m:\
X :al=\E[L:dl=\E[M:ic=\E[@:dc=\E[P:
Xnansi|zansi|nansi-color|zansi-color|N/ZANSI.SYS color:\
X :co#80:li#25:bs:pt:bl=^G:le=^H:do=^J:\
X :cl=\E[2J:ce=\E[K:\
X :ho=\E[H:cm=\E[%i%d;%dH:\
X :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
X :ti=\E[0;44m:te=\E[0m:\
X :so=\E[1;35;44m:se=\E[0;44m:\
X :us=\E[1;31;44m:ue=\E[0;44m:\
X :mb=\E[5m:md=\E[1m:mr=\E[7m:me=\E[0;44m:\
X :al=\E[L:dl=\E[M:ic=\E[@:dc=\E[P:
XAX|ANSI X3.64|full ANSI X3.64 (1977) standard:\
X :co#80:li#24:bs:pt:am:mi:bl=^G:le=^H:\
X :cl=\E[2J:ce=\E[K:cd=\E[J:\
X :ho=\E[H:cm=\E[%i%d;%dH:cs=\E[%i%d;%dr:\
X :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
X :UP=\E[%dA:DO=\E[%dB:LE=\E[%dC:RI=\E[%dD:\
X :so=\E[7m:se=\E[m:us=\E[4m:ue=\E[m:\
X :mb=\E[5m:md=\E[1m:mr=\E[7m:me=\E[m:as=^N:ae=^O:\
X :ku=\E[A:kd=\E[B:kl=\E[C:kr=\E[D:kb=^H:\
X :kn#4:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:\
X :im=\E[4h:ei=\E[4l:al=\E[L:dl=\E[M:ic=\E[@:dc=\E[P:sf=\ED:sr=\EM:
SHAR_EOF
true || echo 'restore of termcap.dos failed'
rm -f _shar_wnt_.tmp
fi
# ============= README ==============
if test -f 'README' -a X"$1" != X"-c"; then
echo 'x - skipping README (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting README (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'README' &&
XThis package is a simple UNIX port of Chris Tenaglia's blackjack
Xgame for full ANSI terminals. Because of the structure of the
Xoriginal program (read: because I was lazy) this port won't work
Xwith magic cookie terminals. It works best on terminals that have
Xboldface, reverse, dim, and blink modes. If any of these are mis-
Xsing, the appearance of the game will be somewhat altered. Ter-
Xminals must be at least 24x80.
X
XTo make for UNIX, just copy Makefile.dist to Makefile and type
X"make." If all goes well, and you have root priviledges, su to
Xroot and type "make install." You'll have to edit the makefile
Xto reflect local file structures and conventions.
X
XIncluded with this distribution is also a DOS implementation of
Xthe itlib routines and a termcap file. To run this program on a
XDOS system, first compile using
X
X icont -o bj bj.icn itlibdos.icn
X
XRead the directions in the file itlibdos.icn for instructions as
Xto how to install a termcap file. NOTE WELL: THE TERMCAP FOR
XDOS IS NOT TERRIBLY GOOD, AND IN ORDER TO GET IT TO WORK, YOU
XWILL CERTAINLY NEED TO FIX IT UP. I don't use DOS much, and will
Xjust have to hope that some any revisions that get made will make
Xtheir way back to me.
X
XNaturally, UNIX users can erase all the DOS files ("rm *dos*").
XDOS users can erase itlibdos.icn and Makefile.dist. If anything
Xgoes awry, or if a standard terminal such as a VT-XXX or and
XANSI fails to run bj, please let me know. I expect that older
Xterminals without a full assortment of modes - if they run it
Xat all - will not do so very smartly.
X
XEnjoy Chris's game, and have a good 1991!
X
X-Richard Goerwitz (goer@sophist.uchicago.edu)
SHAR_EOF
true || echo 'restore of README failed'
rm -f _shar_wnt_.tmp
fi
# ============= Makefile.dist ==============
if test -f 'Makefile.dist' -a X"$1" != X"-c"; then
echo 'x - skipping Makefile.dist (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting Makefile.dist (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'Makefile.dist' &&
X# Don't change this unless you know what you are doing :-).
XPROGNAME = bj
X
X# Please edit these to reflect your local file structure & conventions.
XDESTDIR = /usr/local/bin
XOWNER = bin
XGROUP = bin
X
X# Please don't change these.
XSRC = $(PROGNAME).icn itlib.icn
X
X# I hope you won't have to use this.
X# DEBUGFLAG = -t
X
X$(PROGNAME): $(SRC)
X /usr/local/bin/icont $(DEBUGFLAG) -o $(PROGNAME) $(SRC)
X
X# Pessimistic assumptions regarding the environment (in particular,
X# I don't assume you have the BSD "install" shell script).
Xinstall: $(PROGNAME)
X @sh -c "test -d $(DESTDIR) || (mkdir $(DESTDIR) && chmod 755 $(DESTDIR))"
X cp $(PROGNAME) $(DESTDIR)/
X chgrp $(GROUP) $(DESTDIR)/$(PROGNAME)
X chown $(OWNER) $(DESTDIR)/$(PROGNAME)
X @echo "\nInstallation done.\n"
X
SHAR_EOF
true || echo 'restore of Makefile.dist failed'
rm -f _shar_wnt_.tmp
fi
rm -f _shar_seq_.tmp
echo You have unpacked the last part
exit 0
From icon-group-request@arizona.edu Tue Jan 1 21:52:26 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA14625; Tue, 1 Jan 91 21:52:26 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu; Tue, 1 Jan 91 21:51 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA29795; Tue, 1 Jan 91 20:44:06
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Tue, 1 Jan 91 21:51 MST
Date: 2 Jan 91 02:55:23 GMT
From: netnews.upenn.edu!msuinfo!midway!quads.uchicago.edu!goer@rutgers.edu
Subject: bj, part 2 of 3
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <DEC4AF716E39400484@Arizona.edu>
Message-Id: <1991Jan2.025523.21456@midway.uchicago.edu>
Organization: University of Chicago
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
References: <1991Jan2.025428.21379@midway.uchicago.edu>
stty: Operation not supported on socket
---- Cut Here and feed the following to sh ----
#!/bin/sh
# this is bj.02 (part 2 of a multipart archive)
# do not concatenate these parts, unpack them in order with /bin/sh
# file itlib.icn continued
#
if test ! -r _shar_seq_.tmp; then
echo 'Please unpack part 1 first!'
exit 1
fi
(read Scheck
if test "$Scheck" != 2; then
echo Please unpack part "$Scheck" next!
exit 1
else
exit 0
fi
) < _shar_seq_.tmp || exit 1
if test ! -f _shar_wnt_.tmp; then
echo 'x - still skipping itlib.icn'
else
echo 'x - continuing file itlib.icn'
sed 's/^X//' << 'SHAR_EOF' >> 'itlib.icn' &&
X (tab(find(":")+1), tab(0)))
X return entry
X }
X else {
X \line := &null # must precede the next line
X entry ||:= trim(trim(tab(0),'\\'),':')
X }
X }
X }
X }
X }
X
X close(f)
X er("getentry","can't find and/or process your termcap entry",3)
X
Xend
X
X
X
Xprocedure read_file(f)
X
X # Suspends all non #-initial lines in the file f.
X # Removes leading tabs and spaces from lines before suspending
X # them.
X
X local line
X
X \f | er("read_tcap_file","no valid termcap file found",3)
X while line := read(f) do {
X match("#",line) & next
X line ?:= (tab(many('\t ')) | &null, tab(0))
X suspend line
X }
X
X fail
X
Xend
X
X
X
Xprocedure maketc_table(entry)
X
X # Maketc_table(s) (where s is a valid termcap entry for some
X # terminal-type): Returns a table in which the keys are termcap
X # capability designators, and the values are the entries in
X # "entry" for those designators.
X
X local k, v
X
X /entry & er("maketc_table","no entry given",8)
X if entry[-1] ~== ":" then entry ||:= ":"
X
X /tc_table := table()
X
X entry ? {
X
X tab(find(":")+1) # tab past initial (name) field
X
X while tab((find(":")+1) \ 1) ? {
X &subject == "" & next
X if k := 1(move(2), ="=")
X then tc_table[k] := Decode(tab(find(":")))
X else if k := 1(move(2), ="#")
X then tc_table[k] := integer(tab(find(":")))
X else if k := 1(tab(find(":")), pos(-1))
X then tc_table[k] := true()
X else er("maketc_table", "your termcap file has a bad entry",3)
X }
X }
X
X return tc_table
X
Xend
X
X
X
Xprocedure getval(id)
X
X /tc_table := maketc_table(getentry(getname())) |
X er("getval","can't make a table for your terminal",4)
X
X return \tc_table[id] | fail
X # er("getval","the current terminal doesn't support "||id,7)
X
Xend
X
X
X
Xprocedure Decode(s)
X
X # Does things like turn ^ plus a letter into a genuine control
X # character.
X
X new_s := ""
X
X s ? {
X
X while new_s ||:= tab(upto('\\^')) do {
X chr := move(1)
X if chr == "\\" then {
X new_s ||:= {
X case chr2 := move(1) of {
X "\\" : "\\"
X "^" : "^"
X "E" : "\e"
X "b" : "\b"
X "f" : "\f"
X "n" : "\n"
X "r" : "\r"
X "t" : "\t"
X default : {
X if any(&digits,chr2) then {
X char(integer("8r"||chr2||move(2 to 0 by -1))) |
X er("Decode","bad termcap entry",3)
X }
X else chr2
X }
X }
X }
X }
X else new_s ||:= char(ord(map(move(1),&lcase,&ucase)) - 64)
X }
X new_s ||:= tab(0)
X }
X
X return new_s
X
Xend
X
X
X
Xprocedure igoto(cm,col,line)
X
X local colline, range, increment, str, outstr, chr, x, y
X
X if col > (tc_table["co"]) | line > (tc_table["li"]) then {
X colline := string(\col) || "," || string(\line) | string(\col|line)
X range := "(" || tc_table["co"]-1 || "," || tc_table["li"]-1 || ")"
X er("igoto",colline || " out of range " || (\range|""),9)
X }
X
X # Use the Iconish 1;1 upper left corner & not the C-ish 0 offsets
X increment := -1
X outstr := ""
X
X cm ? {
X while outstr ||:= tab(find("%")) do {
X tab(match("%"))
X chr := move(1)
X if case chr of {
X "." : outstr ||:= char(line + increment)
X "+" : outstr ||:= char(line + ord(move(1)) + increment)
X "d" : {
X str := string(line + increment)
X outstr ||:= right(str, integer(tab(any('23'))), "0") | str
X }
X }
X then line :=: col
X else {
X case chr of {
X "n" : line := ixor(line,96) & col := ixor(col,96)
X "i" : increment := 0
X "r" : line :=: col
X "%" : outstr ||:= "%"
X "B" : line := ior(ishift(line / 10, 4), line % 10)
X ">" : {
X x := move(1); y := move(1)
X line > ord(x) & line +:= ord(y)
X &null
X }
X } | er("goto","bad termcap entry",5)
X }
X }
X return outstr || tab(0)
X }
X
Xend
X
X
X
Xprocedure iputs(cp, affcnt)
X
X local baud_rates, char_rates, i, delay, PC
X static num_chars, char_times
X # global tty_speed
X
X initial {
X num_chars := &digits ++ '.'
X char_times := table()
X # Baud rates in decimal, not octal (as in termio.h)
X baud_rates := [0,7,8,9,10,11,12,13,14,15]
X char_rates := [0,333,166,83,55,41,20,10,10,10]
X every i := 1 to *baud_rates do {
X char_times[baud_rates[i]] := char_rates[i]
X }
X }
X
X type(cp) == "string" |
X er("iputs","you can't iputs() a non-string value!",10)
X
X cp ? {
X delay := tab(many(num_chars))
X if ="*" then {
X delay *:= \affcnt |
X er("iputs","affected line count missing",6)
X }
X writes(tab(0))
X }
X
X if (\delay, tty_speed ~= 0) then {
X PC := tc_table["pc"] | "\000"
X char_time := char_times[tty_speed] | (return "speed error")
X delay := (delay * char_time) + (char_time / 2)
X every 1 to delay by 10
X do writes(PC)
X }
X
X return
X
Xend
X
X
X
Xprocedure getspeed()
X
X local stty_g, stty_output, c_cflag, o_speed
X
X stty_g := open("/bin/stty -g 2>&1","pr") |
X er("getspeed","Can't access your stty command.",4)
X stty_output := !stty_g
X close(stty_g)
X
X \stty_output ? {
X # tab to the third field of the output of the stty -g cmd
X tab(find(":")+1) & tab(find(":")+1) &
X c_cflag := integer("16r"||tab(find(":")))
X } | er("getspeed","Unable to unwind your stty -g output.",4)
X
X o_speed := iand(15,c_cflag)
X return o_speed
X
Xend
SHAR_EOF
echo 'File itlib.icn is complete' &&
true || echo 'restore of itlib.icn failed'
rm -f _shar_wnt_.tmp
fi
# ============= itlibdos.icn ==============
if test -f 'itlibdos.icn' -a X"$1" != X"-c"; then
echo 'x - skipping itlibdos.icn (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting itlibdos.icn (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'itlibdos.icn' &&
X##########################################################################
X#
X# Name: itlibdos.icn
X#
X# Title: Icon termlib-type tools (MS-DOS version)
X#
X# Author: Richard L. Goerwitz
X#
X# Version: 1.12
X#
X###########################################################################
X#
X# I place this and future versions of itlibdos in the public domain - RLG
X#
X###########################################################################
X#
X# The following library represents a series of rough functional
X# equivalents to the standard Unix low-level termcap routines. They
X# are not meant as exact termlib clones. Nor are they enhanced to
X# take care of magic cookie terminals, terminals that use \D in their
X# termcap entries, or, in short, anything I felt would not affect my
X# normal, day-to-day work with ANSI and vt100 terminals.
X#
X# Requires: An MS-DOS platform & co-expressions. The MS-DOS version
X# is a port of the Unix version. Software you write for this library
X# can be made to run under Unix simply by substituting the Unix ver-
X# sion of this library. See below for additional notes on how to use
X# this MS-DOS port.
X#
X# setname(term)
X# Use only if you wish to initialize itermlib for a terminal
X# other than what your current environment specifies. "Term" is the
X# name of the termcap entry to use. Normally this initialization is
X# done automatically, and need not concern the user.
X#
X# getval(id)
X# Works something like tgetnum, tgetflag, and tgetstr. In the
X# spirit of Icon, all three have been collapsed into one routine.
X# Integer valued caps are returned as integers, strings as strings,
X# and flags as records (if a flag is set, then type(flag) will return
X# "true"). Absence of a given capability is signalled by procedure
X# failure.
X#
X# igoto(cm,destcol,destline) - NB: default 1 offset (*not* zero)!
X# Analogous to tgoto. "Cm" is the cursor movement command for
X# the current terminal, as obtained via getval("cm"). Igoto()
X# returns a string which, when output via iputs, will cause the
X# cursor to move to column "destcol" and line "destline." Column and
X# line are always calculated using a *one* offset. This is far more
X# Iconish than the normal zero offset used by tgoto. If you want to
X# go to the first square on your screen, then include in your program
X# "iputs(igoto(getval("cm"),1,1))."
X#
X# iputs(cp,affcnt)
X# Equivalent to tputs. "Cp" is a string obtained via getval(),
X# or, in the case of "cm," via igoto(getval("cm"),x,y). Affcnt is a
X# count of affected lines. It is only relevant for terminals which
X# specify proportional (starred) delays in their termcap entries.
X#
X# Notes on the MS-DOS version:
X# There are two basic reasons for using the I/O routines
X# contained in this package. First, by using a set of generalized
X# routines, your code will become much more readable. Secondly, by
X# using a high level interface, you can avoid the cardinal
X# programming error of hard coding things like screen length and
X# escape codes into your programs.
X# To use this collection of programs, you must do two things.
X# First, you must add the line "device=ansi.sys" (or the name of some
X# other driver, like zansi.sys, nansi.sys, or nnansi.sys [=new
X# nansi.sys]) to your config.sys file. Secondly, you must add two
X# lines to your autoexec.bat file: 1) "set TERM=ansi-mono" and 2)
X# "set TERMCAP=\location\termcap." The purpose of setting the TERM
X# variable is to tell this program what driver you are using. If you
X# have a color system, use "ansi-color" instead of "ansi-mono," and
X# if you are using nansi or zansi instead of vanilla ansi, use one of
X# these names instead of the "ansi" (e.g. "zansi-mono"). The purpose
X# of setting TERMCAP is to make it possible to determine where the
X# termcap file is located. The termcap file (which should have been
X# packed with this library as termcap.dos) is a short database of all
X# the escape sequences used by the various terminal drivers. Set
X# TERMCAP so that it reflects the location of this file (which should
X# be renamed as termcap, for the sake of consistency with the Unix
X# version). Naturally, you must change "\location\" above to reflect
X# the correct path on your system.
X# Although I make no pretense here of providing here a complete
X# introduction to the format of the termcap database file, it will be
X# useful, I think, to explain a few basic facts about how to use this
X# program in conjunction with it. If, say, you want to clear the
X# screen, add the line,
X#
X# iputs(getval("cl"))
X#
X# to your program. The function iputs() outputs screen control
X# sequences. Getval retrieves a specific sequence from the termcap
X# file. The string "cl" is the symbol used in the termcap file to
X# mark the code used to clear the screen. By executing the
X# expression "iputs(getval("cl"))," you are 1) looking up the "cl"
X# (clear) code in the termcap database entry for your terminal, and
X# the 2) outputting that sequence to the screen.
X# Some other useful termcap symbols are "ce" (clear to end of
X# line), "ho" (go to the top left square on the screen), "so" (begin
X# standout mode), and "se" (end standout mode). To output a
X# boldfaced string, str, to the screen, you would write -
X#
X# iputs(getval("so"))
X# writes(str)
X# iputs(getval("se"))
X#
X# You could write "iputs(getval("so") || str || getval("se")), but
X# this would only work for DOS. Some Unix terminals require padding,
X# and iputs() handles them specially. Normally you should not worry
X# about Unix quirks under DOS. It is in general wise, though, to
X# separate out screen control sequences, and output them via iputs().
X# It is also heartily to be recommended that MS-DOS programmers
X# try not to assume that everyone will be using a 25-line screen.
X# Some terminals are 24-line. Some 43. Some have variable window
X# sizes. If you want to put a status line on, say, the 2nd-to-last
X# line of the screen, then determine what that line is by executing
X# "getval("li")." The termcap database holds not only string-valued
X# sequences, but numeric ones as well. The value of "li" tells you
X# how many lines the terminal has (compare "co," which will tell you
X# how many columns). To go to the beginning of the second-to-last
X# line on the screen, type in:
X#
X# iputs(igoto(getval("cm"), 1, getval("li")-1))
X#
X# The "cm" capability is a special capability, and needs to be output
X# via igoto(cm,x,y), where cm is the sequence telling your computer
X# to move the cursor to a specified spot, x is the column, and y is
X# the row. The expression "getval("li")-1" will return the number of
X# the second-to-last line on your screen.
X#
X##########################################################################
X#
X# Requires: MS-DOS, coexpressions
X#
X# See also: iscreen.icn (a set of companion utilities)
X#
X##########################################################################
X
X
Xglobal tc_table
Xrecord true()
X
X
Xprocedure check_features()
X
X local in_params, line
X
X initial {
X find("ms-dos",map(&features)) |
X er("check_features","MS-DOS system required",1)
X find("o-expres",&features) |
X er("check_features","co-expressions not implemented - &$#!",1)
X }
X
X return
X
Xend
X
X
X
Xprocedure setname(name)
X
X # Sets current terminal type to "name" and builds a new termcap
X # capability database (residing in tc_table). Fails if unable to
X # find a termcap entry for terminal type "name." If you want it
X # to terminate with an error message under these circumstances,
X # comment out "| fail" below, and uncomment the er() line.
X
X #tc_table is global
X
X check_features()
X
X tc_table := maketc_table(getentry(name)) | fail
X # er("setname","no termcap entry found for "||name,3)
X return
X
Xend
X
X
X
Xprocedure getname()
X
X # Getname() first checks to be sure we're running under DOS, and,
X # if so, tries to figure out what the current terminal type is,
X # checking the value of the environment variable TERM, and if this
X # is unsuccessful, defaulting to "mono."
X
X local term, tset_output
X
X check_features()
X term := getenv("TERM") | "mono"
X
X return \term |
X er("getname","can't seem to determine your terminal type",1)
X
Xend
X
X
X
Xprocedure er(func,msg,errnum)
X
X # short error processing utility
X write(&errout,func,": ",msg)
X exit(errnum)
X
Xend
X
X
X
Xprocedure getentry(name, termcap_string)
X
X # "Name" designates the current terminal type. Getentry() scans
X # the current environment for the variable TERMCAP. If the
X # TERMCAP string represents a termcap entry for a terminal of type
X # "name," then getentry() returns the TERMCAP string. Otherwise,
X # getentry() will check to see if TERMCAP is a file name. If so,
X # getentry() will scan that file for an entry corresponding to
X # "name." If the TERMCAP string does not designate a filename,
X # getentry() will look through ./termcap for the correct entry.
X # Whatever the input file, if an entry for terminal "name" is
X # found, getentry() returns that entry. Otherwise, getentry()
X # fails.
X
X local f, getline, line, nm, ent1, ent2
X
X /termcap_string := getenv("TERMCAP")
X
X if \termcap_string ? (not match("\\"), pos(0) | tab(find("|")+1), =name)
X then return termcap_string
X else {
X
X # The logic here probably isn't clear. The idea is to try to use
X # the termcap environment variable successively as 1) a termcap en-
X # try and then 2) as a termcap file. If neither works, 3) go to
X # the ./termcap file. The else clause here does 2 and, if ne-
X # cessary, 3. The "\termcap_string ? (not match..." expression
X # handles 1.
X
X if find("\\",\termcap_string)
X then f := open(termcap_string)
X /f := open("termcap") |
X er("getentry","I can't access your termcap file",1)
X
X getline := create read_file(f)
X
X while line := @getline do {
X if line ? (pos(1) | tab(find("|")+1), =name, any(':|')) then {
X entry := ""
X while (\line | @getline) ? {
X if entry ||:= 1(tab(find(":")+1), pos(0))
X then {
X close(f)
X # if entry ends in tc= then add in the named tc entry
X entry ?:= tab(find("tc=")) ||
X # recursively fetch the new termcap entry
X (move(3), getentry(tab(find(":"))) ?
X # remove the name field from the new entry
X (tab(find(":")+1), tab(0)))
X return entry
X }
X else {
X \line := &null # must precede the next line
X entry ||:= trim(trim(tab(0),'\\'),':')
X }
X }
X }
X }
X }
X
X close(f)
X er("getentry","can't find and/or process your termcap entry",3)
X
Xend
X
X
X
Xprocedure read_file(f)
X
X # Suspends all non #-initial lines in the file f.
X # Removes leading tabs and spaces from lines before suspending
X # them.
X
X local line
X
X \f | er("read_tcap_file","no valid termcap file found",3)
X while line := read(f) do {
X match("#",line) & next
X line ?:= (tab(many('\t ')) | &null, tab(0))
X suspend line
X }
X
X fail
X
Xend
X
X
X
Xprocedure maketc_table(entry)
X
X # Maketc_table(s) (where s is a valid termcap entry for some
X # terminal-type): Returns a table in which the keys are termcap
X # capability designators, and the values are the entries in
X # "entry" for those designators.
X
X local k, v
X
X /entry & er("maketc_table","no entry given",8)
X if entry[-1] ~== ":" then entry ||:= ":"
X
X tc_table := table()
X
X entry ? {
X
X tab(find(":")+1) # tab past initial (name) field
X
X while tab((find(":")+1) \ 1) ? {
X
X &subject == "" & next
X if k := 1(move(2), ="=")
X then tc_table[k] := Decode(tab(find(":")))
X else if k := 1(move(2), ="#")
X then tc_table[k] := integer(tab(find(":")))
X else if k := 1(tab(find(":")), pos(-1))
X then tc_table[k] := true()
X else er("maketc_table", "your termcap file has a bad entry",3)
X }
X }
X
X return tc_table
X
Xend
X
X
X
Xprocedure getval(id)
X
X /tc_table := maketc_table(getentry(getname())) |
X er("getval","can't make a table for your terminal",4)
X
X return \tc_table[id] | fail
X # er("getval","the current terminal doesn't support "||id,7)
X
Xend
X
X
X
Xprocedure Decode(s)
X
X # Does things like turn ^ plus a letter into a genuine control
X # character.
X
X new_s := ""
X
X s ? {
X while new_s ||:= tab(upto('\\^')) do {
X chr := move(1)
X if chr == "\\" then {
X new_s ||:= {
X case chr2 := move(1) of {
X "\\" : "\\"
X "^" : "^"
X "E" : "\e"
X "b" : "\b"
X "f" : "\f"
X "n" : "\n"
X "r" : "\r"
X "t" : "\t"
X default : {
X if any(&digits,chr2) then {
X char(integer("8r"||chr2||move(2 to 0 by -1))) |
X er("Decode","bad termcap entry",3)
X }
X else chr2
X }
X }
X }
X }
X else new_s ||:= char(ord(map(move(1),&lcase,&ucase)) - 64)
X }
X new_s ||:= tab(0)
X }
X
X return new_s
X
Xend
X
X
X
Xprocedure igoto(cm,col,line)
X
X local colline, range, increment, str, outstr, chr, x, y
X
X if col > (tc_table["co"]) | line > (tc_table["li"]) then {
X colline := string(\col) || "," || string(\line) | string(\col|line)
SHAR_EOF
true || echo 'restore of itlibdos.icn failed'
fi
echo 'End of part 2'
echo 'File itlibdos.icn is continued in part 3'
echo 3 > _shar_seq_.tmp
exit 0
From icon-group-request@arizona.edu Tue Jan 1 21:52:55 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA14640; Tue, 1 Jan 91 21:52:55 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu; Tue, 1 Jan 91 21:51 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA29778; Tue, 1 Jan 91 20:43:37
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Tue, 1 Jan 91 21:52 MST
Date: 2 Jan 91 02:54:28 GMT
From: netnews.upenn.edu!msuinfo!midway!quads.uchicago.edu!goer@rutgers.edu
Subject: UNIX port of bj, part 1 of 3
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <DEC49C5CF08940048B@Arizona.edu>
Message-Id: <1991Jan2.025428.21379@midway.uchicago.edu>
Organization: University of Chicago
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Tenaglia's blackjack game was very cleanly written, and I ported
it before dinner tonight. Some of the character graphics and fonts
couldn't be reproduced portably using standard Unix terminals, so
I had to remove them. Oh well.
Needless to say, I haven't tested this program terribly thoroughly
on any system but my own, and even there some bugs might remain.
Still, I don't expect that anyone will encounter any big problems
running it (or fixing it up).
It's a nice game. In fact, I must hurry up, since my son is breathing
down my neck to let him have the console so that he can run it here at
home. Here's the first of three shell archives.
-Richard (goer@sophist.uchicago.edu)
stty: Operation not supported on socket
---- Cut Here and feed the following to sh ----
#!/bin/sh
# This is a shell archive (produced by shar 3.49)
# To extract the files from this archive, save it to a file, remove
# everything above the "!/bin/sh" line above, and type "sh file_name".
#
# made 01/02/1991 02:37 UTC by goer@sophist.uchicago.edu
# Source directory /u/richard/Bj
#
# existing files will NOT be overwritten unless -c is specified
# This format requires very little intelligence at unshar time.
# "if test", "cat", "rm", "echo", "true", and "sed" may be needed.
#
# This is part 1 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 10389 -r--r--r-- bj.icn
# 12240 -r--r--r-- itlib.icn
# 14586 -r--r--r-- itlibdos.icn
# 2391 -r--r--r-- termcap.dos
# 1654 -rw-r--r-- README
# 754 -rw-r--r-- Makefile.dist
#
if test -r _shar_seq_.tmp; then
echo 'Must unpack archives in sequence!'
echo Please unpack part `cat _shar_seq_.tmp` next
exit 1
fi
# ============= bj.icn ==============
if test -f 'bj.icn' -a X"$1" != X"-c"; then
echo 'x - skipping bj.icn (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting bj.icn (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'bj.icn' &&
X############################################################################
X#
X# Names: bj.icn
X#
X# Title: blackjack game
X#
X# Author: Chris Tenaglia (modified by Richard L. Goerwitz)
X#
X# Version: 1.1
X#
X############################################################################
X#
X# Simple but fun blackjack game. The original version was for an ANSI
X# screen. This version has been modified to work with the Unix termcap
X# database file.
X#
X############################################################################
X#
X# Links:
X#
X############################################################################
X
Xglobal deck, message, lookup,
X user_money, host_money,
X user_hand, host_hand
X
Xprocedure main(param)
X user_money := integer(param[1]) | 3 ; host_money := user_money
X write(screen("cls"))
X# Most terminals don't do oversize characters like this.
X# write(screen("cls")," ",screen("top"),screen("hinv"),
X# "BLACK JACK",screen("norm"))
X# write(" ",screen("bot"),screen("hinv"),
X# "BLACK JACK",screen("norm"))
X write(screen("high")," ---- BLACK JACK ----",screen("norm"))
X bonus := 0
X repeat
X {
X if not any('y',(map(input(at(1,3) || " " || screen("under") ||
X "Play a game? y/n : "|| screen("norm") ||
X screen("eeol")))[1])) then break
X every writes(at(1,3|4),screen("eeos"))
X display_score()
X deck := shuffle()
X message := ""
X user_hand := [] ; host_hand := []
X put(user_hand,pop(deck)) ; put(host_hand,pop(deck))
X put(user_hand,pop(deck)) ; put(host_hand,pop(deck))
X user_points := first(host_hand[1])
X if user_points > 21 then
X {
X writes(at(1,13),user_points," points. You went over. You lose.")
X user_money -:= 1 ; host_money +:= 1 + bonus ; bonus := 0
X display_score()
X next
X }
X display_host(2)
X host_points := second(user_points)
X if host_points > 21 then
X {
X writes(at(50,22),host_points," points. ",&host ? tab(find(" ")),
X " went over.")
X writes(at(1,13),screen("hiblink"),"You win.",screen("norm"))
X host_money -:= 1 ; user_money +:= 1 + bonus ; bonus := 0
X display_score()
X next
X }
X if host_points = user_points then
X {
X writes(at(1,22),screen("hiblink"),"It's a draw at ",user_points,
X ". The ANTY goes to bonus.",screen("norm"))
X bonus +:= 2 ; host_money -:= 1 ; user_money -:= 1
X display_score()
X next
X }
X writes(at(20,12),user_points," points for user.")
X writes(at(1,14),host_points," points for ",&host ? tab(find(" ")))
X if user_points < host_points then
X {
X write(at(1,22),screen("hiblink"),&host ? tab(find(" "))," wins.",
X screen("norm"),screen("eeol"))
X user_money -:= 1 ; host_money +:= 1 + bonus ; bonus := 0
X display_score()
X next
X } else {
X writes(at(1,12),screen("hiblink"),"You win.",screen("norm"),
X screen("eeol"))
X user_money +:= 1 + bonus ; host_money -:= 1 ; bonus := 0
X display_score()
X next
X }
X }
X write(screen("clear"))
X end
X
X#
X# THIS PROCEDURE ALLOWS THE USER TO PLAY AND TAKE HITS
X#
Xprocedure first(host_card)
X display_user()
X display_host(1)
X points := value(user_hand) # just in case
X writes(at(1,9),"(",points,") ")
X repeat
X if any('hy',map(input(at(1,23) || "Hit ? y/n : " || screen("eeol")))) then
X {
X put(user_hand,pop(deck))
X display_user()
X if (points := value(user_hand)) > 21 then return points
X writes(at(1,9),"(",points,") ")
X } else break
X (points > 0) | (points := value(user_hand))
X writes(at(1,9),"(",points,") ")
X write(at(60,11),"You stay with ",points)
X return points
X end
X
X#
X# THIS SECOND PROCEDURE IS THE HOST PLAYING AGAINST THE USER
X#
Xprocedure second(ceiling)
X static limits
X initial limits := [14,14,15,15,19,16,17,18]
X stop_at := ?limits ; points := 0
X until (points := value(host_hand)) > stop_at do
X {
X if points > ceiling then return points
X writes(at(1,19),"(",points,") ")
X# write(at(1,22),screen("eeol"),&host," will take a hit.",screen("eeol"))
X write(at(1,22),screen("eeol"),&host ? tab(find(" ")),
X " will take a hit.",screen("eeol"))
X put(host_hand,pop(deck))
X display_host(2)
X }
X (points > 0) | (points := value(host_hand))
X writes(at(1,19),"(",points,") ")
X return points
X end
X
X#
X# THIS ROUTINE DISPLAYS THE CURRENT SCORE
X#
Xprocedure display_score()
X writes(screen("nocursor"))
X writes(screen("dim"),at(1,7),"Credits",screen("norm"))
X writes(screen("high"),at(1,8),right(user_money,7),screen("norm"))
X writes(screen("dim"),at(1,17),"Credits",screen("norm"))
X writes(screen("high"),at(1,18),right(host_money,7),screen("norm"))
X end
X#
X# THIS PROCEDURE EVALUATES THE POINTS OF A HAND. IT TRIES TO MAKE THEM
X# AS HIGH AS POSSIBLE WITHOUT GOING OVER 21.
X#
Xprocedure value(sample)
X hand := copy(sample)
X possible := []
X repeat
X {
X sum := 0
X every card := !hand do sum +:= lookup[card[1]]
X put(possible,sum)
X if Aces(hand) == "none" then break else
X every i := 1 to *hand do if hand[i][1] == "A" then hand[i][1] := "a"
X }
X every score := !possible do
X if score <= 21 then return score
X return possible[1]
X end
X
X#
X# ARE THERE ANY 11 POINT ACES LEFT IN HAND
X#
Xprocedure Aces(cards)
X every look := !cards do if look[1] == "A" then return "some"
X return "none"
X end
X
X#
X# THIS ROUTINE DISPLAYS THE USER HAND AND STATUS
X#
Xprocedure display_user()
X writes(screen("nocursor"),at(1,6),screen("hinv"),"USER",screen("norm"))
X x := 10 ; y := 4
X every card := !user_hand do
X {
X display(card,x,y)
X x +:= 7
X }
X end
X
X#
X# THIS ROUTINE DISPLAYS THE HOST HAND AND STATUS
X#
Xprocedure display_host(flag)
X writes(screen("nocursor"),at(1,16),screen("hinv"),
X &host ? tab(find(" ")),screen("norm"))
X x := 10 ; y := 14 ; /flag := 0
X every card := !host_hand do
X {
X if (flag=1) & (x=10) then card := "XX"
X display(card,x,y)
X x +:= 7
X }
X end
X
X#
X# THIS ROUTINE DISPLAYS A GIVEN CARD AT A GIVEN X,Y SCREEN LOCATION
X#
Xprocedure display(card,x,y)
X all := [] ; j := y
X if find(card[2],"CS") then card := screen("hinv") || card || screen("norm")
X# shape := [at(x,(j+:=1)) || screen("gchar") || "lqqqqqqqk"]
X shape := [at(x,(j+:=1)) || screen("inv") || " " || screen("norm")]
X put(shape,at(x,(j+:=1)) || screen("inv") || " " || screen("norm") ||
X " " || card || " " || screen("inv") || " " || screen("norm"))
X put(shape,at(x,(j+:=1)) || screen("inv") || " " || screen("norm") ||
X " " || screen("inv") || " " || screen("norm"))
X put(shape,at(x,(j+:=1)) || screen("inv") || " " || screen("norm") ||
X " " || screen("inv") || " " || screen("norm"))
X put(shape,at(x,(j+:=1)) || screen("inv") || " " || screen("norm") ||
X " " || screen("inv") || " " || screen("norm"))
X# put(shape,at(x,(j+:=1)) || "x x")
X# put(shape,at(x,(j+:=1)) || "x x")
X put(shape,at(x,(j+:=1)) || screen("inv") || " " || screen("norm") ||
X " " || card || " " || screen("inv") || " " || screen("norm"))
X# put(shape,at(x,(j+:=1)) || "mqqqqqqqj" || screen("nchar"))
X put(shape,at(x,(j+:=1)) || screen("inv") || " " || screen("norm"))
X put(all,shape)
X x +:= 14
X while shape := pop(all) do every writes(!shape)
X end
X
X#
X# THIS ROUTINE SHUFFLES THE CARD DECK
X#
Xprocedure shuffle()
X static faces, suits
X local cards, i
X initial {
X &random := map(&clock,":","7") # initial on multiple shuffles
X faces := ["2","3","4","5","6","7","8","9","T","J","Q","K","A"]
X suits := ["D","H","C","S"]
X lookup := table(0)
X every i := 2 to 9 do insert(lookup,string(i),i)
X insert(lookup,"T",10)
X insert(lookup,"J",10)
X insert(lookup,"Q",10)
X insert(lookup,"K",10)
X insert(lookup,"A",11)
X insert(lookup,"a",1)
X }
X cards := []
X every put(cards,!faces || !suits)
X every i := *cards to 2 by -1 do cards[?i] :=: cards[i]
X return cards
X end
X
X#
X# THIS ROUTINE PARSES A STRING WITH RESPECT TO SOME DELIMITER
X#
Xprocedure parse(line,delims)
X static chars
X chars := &cset -- delims
X tokens := []
X line ? while tab(upto(chars)) do put(tokens,tab(many(chars)))
X return tokens
X end
X
X#
X# THIS ROUTINE PROMPTS FOR INPUT AND RETURNS A STRING
X#
Xprocedure input(prompt)
X writes(screen("cursor"),prompt)
X return read()
X end
X
X
X#
X# THIS ROUTINE SETS THE VIDEO OUTPUT ATTRIBUTES FOR VT102 OR LATER
X# COMPATIBLE TERMINALS.
X#
Xprocedure screen(attr)
X initial if getval("ug"|"mg"|"sg") > 0 then
X er("screen","oops, magic cookie terminal!",34)
X return {
X case attr of
X {
X "cls" : getval("cl")
X "clear": getval("cl")
X # HIGH INTENSITY & INVERSE
X "hinv" : (getval("md") | "") || getval("so")
X "norm" : (getval("se") | "") || (getval("me") | "") || (getval("ue")|"")
X # LOW INTENSITY VIDEO
X "dim" : getval("mh"|"me")
X "blink": getval("mb"|"md"|"so")
X # HIGH INTENSITY BLINKING
X "hiblink": (getval("md") | "") || getval("mb") | getval("so")
X "under": getval("us"|"md"|"so")
X "high" : getval("md"|"so"|"ul")
X "inv" : getval("so"|"md"|"ul")
X # ERASE TO END OF LINE
X "eeol" : getval("ce")
X # ERASE TO START OF LINE
X "esol" : getval("cb")
X # ERASE TO END OF SCREEN
X "eeos" : getval("cd")
X # MAKE CURSOR INVISIBLE
X "cursor": getval("vi"|"CO") | ""
X # MAKE CURSOR VISIBLE
X "nocursor": getval("ve"|"CF") | ""
X# # START ALTERNATE FONT <- very non-portable
X# "gchar": getval("as") | ""
X# # END ALTERNATE FONT
X# "nchar": getval("ae") | ""
X# "light": return "\e[?5h" # LIGHT COLORED SCREEN
X# "dark" : return "\e[?5l" # DARK COLORED SCREEN
X# "80" : return "\e[?3l" # 80 COLUMNS ON SCREEN
X# "132" : return "\e[?3h" # 132 COLUMNS ON SCREEN
X# "smooth": return "\e[?4h" # SMOOTH SCREEN SCROLLING
X# "jump" : return "\e[?4l" # JUMP SCREEN SCROLLING
X default : er("screen",attr||" is just too weird for most terminals",34)
X } | er("screen","I just can't cope with your terminal.",35)
X }
X end
X
X#
X# THIS ROUTINE SETS THE CURSOR TO A GIVEN X (COL) Y(ROW) SCREEN LOCATION
X#
Xprocedure at(x,y)
X# return "\e[" || y || ";" || x || "f"
X return igoto(getval("cm"),x,y)
X end
X
SHAR_EOF
true || echo 'restore of bj.icn failed'
rm -f _shar_wnt_.tmp
fi
# ============= itlib.icn ==============
if test -f 'itlib.icn' -a X"$1" != X"-c"; then
echo 'x - skipping itlib.icn (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting itlib.icn (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'itlib.icn' &&
X########################################################################
X#
X# Name: itlib.icn
X#
X# Title: Icon termlib-type tools
X#
X# Author: Richard L. Goerwitz
X#
X# Version: 1.23
X#
X#########################################################################
X#
X# I place this and future versions of itlib in the public domain - RLG
X#
X#########################################################################
X#
X# The following library represents a series of rough functional
X# equivalents to the standard Unix low-level termcap routines. They
X# are not meant as exact termlib clones. Nor are they enhanced to
X# take care of magic cookie terminals, terminals that use \D in their
X# termcap entries, or, in short, anything I felt would not affect my
X# normal, day-to-day work with ANSI and vt100 terminals.
X#
X# Requires: A unix platform & co-expressions. There is an MS-DOS
X# version, itlibdos.icn.
X#
X# setname(term)
X# Use only if you wish to initialize itermlib for a terminal
X# other than what your current environment specifies. "Term" is the
X# name of the termcap entry to use. Normally this initialization is
X# done automatically, and need not concern the user.
X#
X# getval(id)
X# Works something like tgetnum, tgetflag, and tgetstr. In the
X# spirit of Icon, all three have been collapsed into one routine.
X# Integer valued caps are returned as integers, strings as strings,
X# and flags as records (if a flag is set, then type(flag) will return
X# "true"). Absence of a given capability is signalled by procedure
X# failure.
X#
X# igoto(cm,destcol,destline) - NB: default 1 offset (*not* zero)!
X# Analogous to tgoto. "Cm" is the cursor movement command for
X# the current terminal, as obtained via getval("cm"). Igoto()
X# returns a string which, when output via iputs, will cause the
X# cursor to move to column "destcol" and line "destline." Column and
X# line are always calculated using a *one* offset. This is far more
X# Iconish than the normal zero offset used by tgoto. If you want to
X# go to the first square on your screen, then include in your program
X# "iputs(igoto(getval("cm"),1,1))."
X#
X# iputs(cp,affcnt)
X# Equivalent to tputs. "Cp" is a string obtained via getval(),
X# or, in the case of "cm," via igoto(getval("cm"),x,y). Affcnt is a
X# count of affected lines. It is only relevant for terminals which
X# specify proportional (starred) delays in their termcap entries.
X#
X# Bugs: I have not tested these routines on terminals that require
X# padding. These routines WILL NOT WORK if your machines stty com-
X# mand has no -g option (tisk, tisk). This includes NeXT worksta-
X# tions, and some others that I haven't had time to pinpoint.
X#
X##########################################################################
X#
X# Requires: UNIX, co-expressions
X#
X# See also: iscreen.icn (a set of companion utilities)
X#
X##########################################################################
X
X
Xglobal tc_table, tty_speed
Xrecord true()
X
X
Xprocedure check_features()
X
X local in_params, line
X # global tty_speed
X
X initial {
X find("unix",map(&features)) |
X er("check_features","unix system required",1)
X find("o-expres",&features) |
X er("check_features","co-expressions not implemented - &$#!",1)
X system("/bin/stty tabs") |
X er("check_features","can't set tabs option",1)
X }
X
X # clumsy, clumsy, clumsy, and probably won't work on all systems
X tty_speed := getspeed()
X return "term characteristics reset; features check out"
X
Xend
X
X
X
Xprocedure setname(name)
X
X # Sets current terminal type to "name" and builds a new termcap
X # capability database (residing in tc_table). Fails if unable to
X # find a termcap entry for terminal type "name." If you want it
X # to terminate with an error message under these circumstances,
X # comment out "| fail" below, and uncomment the er() line.
X
X #tc_table is global
X
X check_features()
X
X tc_table := table()
X tc_table := maketc_table(getentry(name)) | fail
X # er("setname","no termcap entry found for "||name,3)
X return "successfully reset for terminal " || name
X
Xend
X
X
X
Xprocedure getname()
X
X # Getname() first checks to be sure we're running under Unix, and,
X # if so, tries to figure out what the current terminal type is,
X # checking successively the value of the environment variable
X # TERM, and then the output of "tset -". Terminates with an error
X # message if the terminal type cannot be ascertained.
X
X local term, tset_output
X
X check_features()
X
X if not (term := getenv("TERM")) then {
X tset_output := open("/bin/tset -","pr") |
X er("getname","can't find tset command",1)
X term := !tset_output
X close(tset_output)
X }
X return \term |
X er("getname","can't seem to determine your terminal type",1)
X
Xend
X
X
X
Xprocedure er(func,msg,errnum)
X
X # short error processing utility
X write(&errout,func,": ",msg)
X exit(errnum)
X
Xend
X
X
X
Xprocedure getentry(name, termcap_string)
X
X # "Name" designates the current terminal type. Getentry() scans
X # the current environment for the variable TERMCAP. If the
X # TERMCAP string represents a termcap entry for a terminal of type
X # "name," then getentry() returns the TERMCAP string. Otherwise,
X # getentry() will check to see if TERMCAP is a file name. If so,
X # getentry() will scan that file for an entry corresponding to
X # "name." If the TERMCAP string does not designate a filename,
X # getentry() will scan /etc/termcap for the correct entry.
X # Whatever the input file, if an entry for terminal "name" is
X # found, getentry() returns that entry. Otherwise, getentry()
X # fails.
X
X local f, getline, line, nm, ent1, ent2
X
X # You can force getentry() to use a specific termcap file by cal-
X # ling it with a second argument - the name of the termcap file
X # to use instead of the regular one, or the one specified in the
X # termcap environment variable.
X /termcap_string := getenv("TERMCAP")
X
X if \termcap_string ? (not match("/"), pos(0) | tab(find("|")+1), =name)
X then return termcap_string
X else {
X
X # The logic here probably isn't clear. The idea is to try to use
X # the termcap environment variable successively as 1) a termcap en-
X # try and then 2) as a termcap file. If neither works, 3) go to
X # the /etc/termcap file. The else clause here does 2 and, if ne-
X # cessary, 3. The "\termcap_string ? (not match..." expression
X # handles 1.
X
X if find("/",\termcap_string)
X then f := open(termcap_string)
X /f := open("/etc/termcap") |
X er("getentry","I can't access your /etc/termcap file",1)
X
X getline := create read_file(f)
X
X while line := @getline do {
X if line ? (pos(1) | tab(find("|")+1), =name, any(':|')) then {
X entry := ""
X while (\line | @getline) ? {
X if entry ||:= 1(tab(find(":")+1), pos(0))
X then {
X close(f)
X # if entry ends in tc= then add in the named tc entry
X entry ?:= tab(find("tc=")) ||
X # recursively fetch the new termcap entry
X (move(3), getentry(tab(find(":"))) ?
X # remove the name field from the new entry
SHAR_EOF
true || echo 'restore of itlib.icn failed'
fi
echo 'End of part 1'
echo 'File itlib.icn is continued in part 2'
echo 2 > _shar_seq_.tmp
exit 0
From @mirsa.inria.fr:ol@cerisi.cerisi.Fr Wed Jan 2 10:48:58 1991
Resent-From: @mirsa.inria.fr:ol@cerisi.cerisi.Fr
Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA07953; Wed, 2 Jan 91 10:48:58 -0700
Received: from MIRSA.INRIA.FR by Arizona.edu; Wed, 2 Jan 91 10:48 MST
Received: from cerisi.cerisi.fr by mirsa.inria.fr with SMTP (5.61+++/IDA-1.2.8)
id AA18029; Wed, 2 Jan 91 18:51:41 +0100
Resent-Date: Wed, 2 Jan 91 10:48 MST
Date: Wed, 2 Jan 91 18:46:33 -0100
From: Lecarme Olivier <ol@cerisi.cerisi.Fr>
Subject: itlib on alt.sources
Resent-To: icon-group@cs.arizona.edu
To: goer@ellis.uchicago.edu
Cc: icon-group@arizona.edu
Resent-Message-Id: <DE582B363BD9400B03@Arizona.edu>
Message-Id: <9101021751.AA18029@mirsa.inria.fr>
Posted-Date: Wed, 2 Jan 91 18:46:33 -0100
In-Reply-To: goer@ellis.uchicago.edu's message of 21 Dec 90 06:13:05 GMT
<1990Dec21.061305.25347@midway.uchicago.edu>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: goer@ellis.uchicago.edu
X-Vms-Cc: icon-group@Arizona.edu
Since I don't even know what is alt.sources, I would be interested in a
copy of your Icon termlib-like routines.
Thanks, and my best season's greetings!
Olivier Lecarme
From icon-group-request@arizona.edu Wed Jan 2 10:53:36 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA08189; Wed, 2 Jan 91 10:53:36 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu; Wed, 2 Jan 91 10:52 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA13494; Wed, 2 Jan 91 09:49:39
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Wed, 2 Jan 91 10:52 MST
Date: 2 Jan 91 16:39:09 GMT
From: netnews.upenn.edu!msuinfo!midway!ellis.uchicago.edu!goer@rutgers.edu
Subject: bj
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <DE579E47E529400B19@Arizona.edu>
Message-Id: <1991Jan2.163909.6723@midway.uchicago.edu>
Organization: University of Chicago
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
I noticed that on terms without boldfacing, you can make bj a
bit more flexible by going to the routine screen() and changing
the line that says
# LOW INTENSITY VIDEO
"dim" : getval("mh"|"me")
so that it says
# LOW INTENSITY VIDEO
"dim" : getval("mh"|"me"|"se")
or something like that. The idea is that if you can't do a dim,
try just turning off bold or reverse attributes.
Note that the "old" way meant that if a terminal couldn't bold-
face or dim, bj would abort saying that your terminal was too
stupid, which in fact it was.
-Richard
From icon-group-request@arizona.edu Wed Jan 2 13:24:56 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA14108; Wed, 2 Jan 91 13:24:56 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu; Wed, 2 Jan 91 13:24 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA17570; Wed, 2 Jan 91 12:13:22
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Wed, 2 Jan 91 13:24 MST
Date: 2 Jan 91 17:59:57 GMT
From: tron!beser@uunet.uu.net
Subject: RE: itlib on alt.sources
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <DE4264EBF429400DB6@Arizona.edu>
Message-Id: <685@tron.UUCP>
Organization: Westinghouse Electronic Systems Group, Baltimore, MD, USA
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
References: <1990Dec21.061305.25347@midway.uchicago.edu>
Given the ability to call c routines from icon, and for c routines
to call icon, has anyone done an Xwindows interface for icon? If not,
I volunteer (ugh). In order to do this, I need the following
information.
I looked for Griswald's book on implementation of icon, and no one
has it. Anywhere. What I need is a better discription than what the
tech reference that came with rev 8 has (which refers to Griswald's
book). I have written interpretive interfaces before, and I have
a rough idea how it may work, but I would appreciate someone sending
me any information on icon calling conventions and function
return conventions. Or at least where to look.
Handling callbacks from X would be done through C interfaces to ICON.
The callbacks would be registered through the runtime and would
return through the runtime. My confusion is about how the status
information, or pointers to X structures would be passed back to ICON.
Anyone willing to help, kindly let me know through email.
Eric Beser
Westinghouse Aerospace Software Engineering
beser@tron.bwi.wec.com
From icon-group-request@arizona.edu Wed Jan 2 19:30:47 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA00444; Wed, 2 Jan 91 19:30:47 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu; Wed, 2 Jan 91 16:21 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA22451; Wed, 2 Jan 91 15:15:02
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Wed, 2 Jan 91 16:21 MST
Date: 2 Jan 91 11:57:01 GMT
From: hsi!mlfarm!ron@uunet.uu.net
Subject: Message conventions
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <DE29A8C75BD9401092@Arizona.edu>
Message-Id: <675@mlfarm.com>
Organization: Maple Lawn Farm, Stonington, CT
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Paul Abrahams writes:
> I've noticed that in many of the postings to icon-group, the messages have
> excerpts from previous messages preceded by "> ". Could anyone let me know
> what software you're using to get this effect, and how you're using it?
> Thanks.
The convention is used by many mailers and news readers, including the
Gnu Emacs mail readers, Elm, rn, and others. Here is a short icon
program which will accomplish the same thing. You can either pipe a
news-article or mail-item to `reply' directly from your mail or news
reader, or save the news-article or mail-item in a file and run
`reply' with the file as input. You will have to customize edstr and
host to suit your editor and system, and may have to customize the
addressing conventions at the end of the code. This should work for
Unix or ms-dos (the ms-dos is untested). It may be useful on VMS or
other operating systems with some modifications.
---------------------------[reply.icn]---------------------------
# reply.icn
# ron@mlfarm.com, 2 Jan 91
# usage: reply < news-article or mail-item
#
# Configure edstr and host as needed for your editor and mail feed.
procedure main()
find("UNIX",&features) & {
console := "/dev/tty"
tmpfile := "/tmp/"
}
find("MS-DOS",&features) & {
console := "CON"
tmpfile := ""
}
&clock ? while tab(upto(&digits)) do tmpfile ||:= tab(many(&digits))
tmpfile ||:= ".tmp"
edstr := "vi " || tmpfile || " < " || console
host := "mlfarm.com"
eoh := 0
reply := open(tmpfile, "w") | stop("reply: cannot open temp file")
while s := read() do {
eoh = 1 & {
write(reply, " > ", s)
next
}
(match("From: ", s) | match("Reply-To: ", s)) & {
start := s[find(" ",s)+1:0]
if find("<", s) then {
fullname := trim(start ? tab(upto("<")))
address := s[find("<",s)+1:find(">",s)]
}
else {
address := trim(start ? tab(upto("(")) | tab(0))
fullname := s[find("(",s)+1:find(")",s)]
}
quoter := (\fullname | address)
}
match("Date: ", s) & date := s[7:0]
match("Message-Id: ", s) & id := s[find("<",s):find(">",s)+1]
match("Subject: ", s) & subject := s
match("Newsgroup: ", s) & newsgroup := (s ? tab(upto(",")) | tab(0))
(\address & not any(&ascii, s)) & {
eoh := 1
write(reply, "In-reply-to: ", quoter, "'s message of ", date);
\subject & write(reply, subject)
\newsgroup & write(reply, newsgroup)
write(reply, "\nIn ", id, ", ", quoter, " writes:\n")
}
}
system(edstr)
stdin := open(console, "r")
writes("Send y/n? ")
upto('nN',read(stdin)) & {
remove(tmpfile)
stop("Reply aborted.")
}
find("@",address) & address ? {
name := tab(upto("@"))
move(1)
address := (tab(upto(" ")) | tab(0)) || "!" || name
}
address ||:= "@" || host
mailstr := "mail " || address || " < " || tmpfile
system(mailstr)
write("Reply sent to " || address)
remove(tmpfile)
end
-------------------------------[end]------------------------------
--
Ronald Florence ron@mlfarm.com
From icon-group-request@arizona.edu Thu Jan 3 02:21:58 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA12117; Thu, 3 Jan 91 02:21:58 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu; Thu, 3 Jan 91 02:21 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA06120; Thu, 3 Jan 91 01:07:33
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Thu, 3 Jan 91 02:21 MST
Date: 3 Jan 91 07:07:58 GMT
From: midway!ellis.uchicago.edu!goer@uunet.uu.net
Subject: RE: Icon as a teaching language
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <DDD5D6274EE94015AF@Arizona.edu>
Message-Id: <1991Jan3.070758.28164@midway.uchicago.edu>
Organization: University of Chicago
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
References: <9012261840.AA07710@june.cs.washington.edu>
In article <9012261840.AA07710@june.cs.washington.edu> Bill Griswold writes:
>
>>With the Christmas vacation upon us and a 12-year old around the
>>house, I wonder if anyone has had experience with Icon as a first
>>structured language....
...
>Unfortunately Icon isn't interactively interpretive, so you can't
>run-as-you-program. I've written a little line-oriented interpreter loop
>for Icon, but it changes the syntax and doesn't allow procedures....
Has anyone written an Icon interpreter? (Bill, could you post yours??)
It surely is the case that my son functions better using interpreters.
I also would not mind the ability to test out code fragments using an
Icon interpreter, even a rough and fairly fragmentary one.
-Richard (goer@sophist.uchicago.edu)
From icon-group-request@arizona.edu Thu Jan 3 08:09:04 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA24614; Thu, 3 Jan 91 08:09:04 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu; Thu, 3 Jan 91 08:08 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA11765; Thu, 3 Jan 91 06:56:31
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Thu, 3 Jan 91 08:08 MST
Date: 3 Jan 91 13:08:43 GMT
From: bbn.com!nic!hri!sparc9!rolandi@apple.com
Subject: RE: Icon as a teaching language
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <DDA55BB5F1A940182A@Arizona.edu>
Message-Id: <1991Jan3.130843.2179@hri.com>
Organization: Horizon Research
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
References: <1991Jan3.070758.28164@midway.uchicago.edu>,
<9012261840.AA07710@june.cs.washington.edu>
In article <1991Jan3.070758.28164@midway.uchicago.edu>,
goer@ellis.uchicago.edu (Richard L. Goerwitz) writes:
> In article <9012261840.AA07710@june.cs.washington.edu> Bill Griswold writes:
> >
> >>With the Christmas vacation upon us and a 12-year old around the
> >>house, I wonder if anyone has had experience with Icon as a first
> >>structured language....
> ...
> >Unfortunately Icon isn't interactively interpretive, so you can't
> >run-as-you-program. I've written a little line-oriented interpreter loop
> >for Icon, but it changes the syntax and doesn't allow procedures....
>
> Has anyone written an Icon interpreter? (Bill, could you post yours??)
> It surely is the case that my son functions better using interpreters.
> I also would not mind the ability to test out code fragments using an
> Icon interpreter, even a rough and fairly fragmentary one.
>
> -Richard (goer@sophist.uchicago.edu)
i too would like to obtain an icon interpreter. has the potential to set
a "post BASIC" first language standard been considered at the project?
--
------------------------------------------------------------------------------
Walter G. Rolandi
Horizon Research, Inc.
1432 Main Street
Waltham, MA 02154 USA
(617) 466 8367
rolandi@hri.com
------------------------------------------------------------------------------
From nowlin@iwtqg.att.com Thu Jan 3 10:05:44 1991
Message-Id: <9101031705.AA28146@megaron.cs.arizona.edu>
Received: from att.att.com by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA28146; Thu, 3 Jan 91 10:05:44 -0700
From: nowlin@iwtqg.att.com
Date: Thu, 3 Jan 91 07:55 CST
Original-From: iwtqg!nowlin (Jerry D Nowlin +1 312 979 7268)
To: icon-group@cs.arizona.edu
Subject: Re: icon interpreter
I did an Icon interpreter a number of years ago when we had some people who
wanted to use Icon but didn't want to have to learn an editor. It's been
so long I just went back and changed the cset I'd defined for digits to use
&digits. I vouch for general sanity but it hasn't been tested or used a
long time.
This program is kind of like an interactive version of BASIC in that Icon
expressions are entered with line numbers and you can resequence them list
them etc. and execute all the lines entered. There is no editor built
in. You have to retype a line to change it. Anyway here it is.
Documentation is lacking but there is a "?" help command that lists all the
other commands. It sounds like what was requested. Anyway it can be used
as a starting place.
Jerry Nowlin
(...!att!iwtqg!nowlin)
============================> cut here <===================================
global WHITE, # the white space cset
MFLAG, # the modified flag
PRTBL # the program table
procedure main(arg)
# define the needed cset
WHITE := ' \t\n\f'
# initialize the program table
PRTBL := table()
# initialize the modified flag
MFLAG := 0
# get all the input
writes("Icon> ")
while line := read() do {
# scan the input line
line ? {
# skip any initial white space
tab(many(WHITE))
# check for program lines (they have line numbers)
if lno := tab(many(&digits)) & tab(many(WHITE)) then {
# get the program line
pline := tab(0)
# store the line in the program table
PRTBL[numeric(lno)] := pline
# set the modified flag
MFLAG +:= 1
}
# read command
else if (tab(upto(WHITE)) | tab(0)) ==
("read" | "r") then {
readprog()
# clear the modified flag
MFLAG := 0
}
# write command
else if (tab(upto(WHITE)) | tab(0)) ==
("write" | "w") then {
writeprog()
# clear the modified flag
MFLAG := 0
}
# delete command
else if (tab(upto(WHITE)) | tab(0)) ==
("delete" | "d") then {
delprog()
# set the modified flag
MFLAG +:= 1
}
# sequence command
else if (tab(upto(WHITE)) | tab(0)) ==
("sequence" | "s") then {
seqprog()
}
# list command
else if (tab(upto(WHITE)) | tab(0)) ==
("list" | "l") then {
listprog()
}
# execute command
else if (tab(upto(WHITE)) | tab(0)) ==
("execute" | "e") then {
execprog()
}
# help command
else if (tab(upto(WHITE)) | tab(0)) ==
("help" | "h" | "?") then {
helpprog()
}
# quit command
else if (tab(upto(WHITE)) | tab(0)) ==
("quit" | "q") then {
quitprog()
}
# invalid syntax input
else {
write("Syntax Error: ",line)
helpprog()
}
}
writes("Icon> ")
}
end
procedure execprog()
static tmpfile
initial tmpfile := "TMPFILE.icn"
# get any runtime arguments
runargs := tab(0)
# create the temporary Icon file
(out := open(tmpfile,"w")) |
# or mention the problem and fail
(write("I can't open '",tmpfile,"' for writing") & fail)
# sort the program table
prog := sort(PRTBL)
# put the program in the file
every line := !prog do {
write(out,line[2])
}
close(out)
# format the command to execute the program
command := "icont -s " || tmpfile || " -x " || runargs
# add the command to remove the temporary file
command ||:= " ; rm -f " || tmpfile
# execute the command
system(command)
end
procedure seqprog()
# initialize the sequencing numbers
begno := incno := 10
# skip any white space
tab(many(WHITE))
# get an initial line number
begno := numeric(tab(many(&digits)))
# skip any white space
tab(many(WHITE))
# get a increment number
incno := numeric(tab(many(&digits)))
# sort the program table
prog := sort(PRTBL)
# reinitialize it
PRTBL := table()
# sequence the program lines starting with begno by incno
lno := begno
every l := !prog do {
PRTBL[lno] := l[2]
lno +:= incno
}
end
procedure readprog()
# get a possible command line file name
tab(many(WHITE))
readfile := tab(upto(WHITE) | 0)
# if there was no file with the command get one
if /readfile | *readfile = 0 then {
writes("Read file name: ")
readfile := read()
}
# make sure a modified file has been written
if MFLAG > 0 then {
writes("Write before reading over current program? ")
response := read()
if any('yY',response) then
writeprog()
}
# initialize the program table
PRTBL := table()
# read the program from the read file
in := open(readfile,"r")
lno := 10
every line := !in do {
PRTBL[lno] := line
lno +:= 10
}
close(in)
# tell them what you did
write("Read '",readfile,"'...",*PRTBL," lines")
end
procedure writeprog()
# get a possible command line file name
tab(many(WHITE))
writefile := tab(upto(WHITE) | 0)
# if there was no file with the command get one
if /writefile | *writefile = 0 then {
writes("Write file name: ")
writefile := read()
}
# sort the program table
prog := sort(PRTBL)
# write the program to the write file
out := open(writefile,"w")
every l := !prog do {
write(out,l[2])
}
close(out)
# tell them what you did
write("Write '",writefile,"'...",*PRTBL," lines")
end
procedure delprog()
# initialize the line numbers
begno := 0
endno := 99999
# skip any white space
tab(many(WHITE))
# get an initial line number
begno := endno := numeric(tab(many(&digits)))
# skip any white space
tab(many(WHITE))
# get a final line number
endno := numeric(tab(many(&digits)))
# sort the program table
prog := sort(PRTBL)
# reinitialize it
PRTBL := table()
# delete the program lines between the optional numbers
every l := !prog do {
lno := numeric(l[1])
if (lno < begno) | (lno > endno) then PRTBL[lno] := l[2]
}
end
procedure listprog()
# initialize the line numbers
begno := 0
endno := 99999
# skip any white space
tab(many(WHITE))
# get an initial line number
begno := endno := numeric(tab(many(&digits)))
# skip any white space
tab(many(WHITE))
# get a final line number
endno := numeric(tab(many(&digits)))
# sort the program table
prog := sort(PRTBL)
# list the program lines between the optional numbers
every l := !prog do {
lno := numeric(l[1])
if (lno >= begno) & (lno <= endno) then
write(right(lno,5),": ",l[2])
if lno > endno then break
}
end
procedure helpprog()
static helpmsg
# define the help message
initial {
helpmsg := [
"<<< Icon Expression Syntax >>>",
"",
"lineno expression",
"",
"<<< Command Summary >>>",
" (1st character works)",
"",
"read [ file ]",
"write [ file ]",
"list [ begno [ endno ] ]",
"delete [ begno [ endno ] ]",
"sequence [ begno [ increment ] ]",
"execute [ args ]",
"quit",
"help"
]
}
# print it
every write(!helpmsg)
end
procedure quitprog()
# make sure a modified file has been written
if MFLAG > 0 then {
writes("Write before quitting? ")
response := read()
if any('yY',response) then
writeprog()
}
stop("Goodbye.")
end
From wgg@cs.washington.edu Thu Jan 3 12:48:51 1991
Resent-From: wgg@cs.washington.edu
Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA04153; Thu, 3 Jan 91 12:48:51 -0700
Return-Path: wgg@cs.washington.edu
Received: from june.cs.washington.edu by Arizona.edu; Thu, 3 Jan 91 12:48 MST
Received: by june.cs.washington.edu (5.64/7.0jh) id AA08905; Thu, 3 Jan 91
11:47:59 -0800
Resent-Date: Thu, 3 Jan 91 12:48 MST
Date: Thu, 3 Jan 91 11:47:59 -0800
From: wgg@cs.washington.edu
Subject: RE: Icon as a teaching language
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu, midway!ellis.uchicago.edu!goer@uunet.uu.net
Resent-Message-Id: <DD7E3F0706B9401CAC@Arizona.edu>
Message-Id: <9101031947.AA08905@june.cs.washington.edu>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu, midway!ellis.uchicago.edu!goer@uunet.uu.net
I'm afraid my interpreter is not for Icon, but a language much more limited
(and syntactically bogus) than Icon. It was fun to build, but it shows
the limitations of line-based input in spades.
bill
From icon-group-request@arizona.edu Thu Jan 3 23:08:19 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA24914; Thu, 3 Jan 91 23:08:19 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu; Thu, 3 Jan 91 23:07 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA04683; Thu, 3 Jan 91 22:05:28
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Thu, 3 Jan 91 23:08 MST
Date: 4 Jan 91 06:03:46 GMT
From: zaphod.mps.ohio-state.edu!samsung!munnari.oz.au!bruce!alanf@tut.cis.ohio-state.edu
Subject: ANSI C to KNR C converter in Icon
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <DD27B86AD7E9401597@Arizona.edu>
Message-Id: <3532@bruce.cs.monash.OZ.AU>
Organization: Monash Uni. Computer Science, Australia
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
am considering writing one in Icon. However if anyone has already done
this I would be pleased to have a copy.
From fps!mis.mcw.edu!mis.mcw.edu!TENAGLIA@uwm.edu Fri Jan 4 19:13:05 1991
Received: from uwm.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA03376; Fri, 4 Jan 91 19:13:05 -0700
Received: by uwm.edu; id AA02327; Fri, 4 Jan 91 20:12:19 -0600
Received: from mis.mcw.edu by fps.mcw.edu (DECUS UUCP ///1.2a/2.5/);
Fri, 4 Jan 91 14:12:07 CDT
Received: by mis.mcw.edu with UUCP/PMDF (DECUS UUCP);
Fri, 4 Jan 1991 13:49 CST
Date: Fri, 4 Jan 1991 13:49 CST
From: Chris Tenaglia - 257-8765 <TENAGLIA@mis.mcw.edu>
Subject: Icon Interpreters
To: icon-group@cs.arizona.edu
Message-Id: <5360256BE06002C4@mis.mcw.edu>
X-Organization: Medical College of Wisconsin MIS Department (Milwaukee, WI)
X-Envelope-To: icon-group@cs.arizona.edu
X-Vms-To: IN%"icon-group@cs.arizona.edu"
I was just thinking about the Icon interpreter dialogs. Something I have,
and posted several months back might be considered along those lines.
I posted a file analyzer and filter called igrep. Syntax...
igrep from_file [to_file]
Upon invokation it prompts for icon expressions. Certain variables are
global, such as 'line' which is the current line being read, 'num' the
record count (how many lines have been read). 'items' is a global list
to put stuff into. 'group' is a global set to insert things into. 'count'
is a global table for tallying things. 'parse' is a procedure that splits
a string into a list based on a delimiter cset. 'ebcdic' is a string that
can be mapped to string(&cset) to do ascii-ebcdic translation. etc,...
Whatever is 'returned' gets written to the specified outputfile or screen.
Finally, if there was anything put into 'items', 'group', or 'count', they
get dumped likewise as a summary.
Mechanically the igrep program takes the expressions, imbeds them into a
an icon program in a list structure, writes it as 'grepawk.icn', compiles,
and runs it. No syntax or correctness checking is done at expression entry
time. Finally, the 'grepawk' modules are deleted (unless a keep flag was set).
The expressions can also be recorded to or recovered from a scratch file.
It may not be a good tool to teach structured programming, but it might be
for even earlier to learn about variables, and operations on variables.
I can repost it if there's some interest.
Chris Tenaglia (System Manager) | Medical College of Wisconsin
8701 W. Watertown Plank Rd. | Milwaukee, WI 53226
(414)257-8765 | tenaglia@mis.mcw.edu, mcwmis!tenaglia
From fps!mis.mcw.edu!mis.mcw.edu!TENAGLIA@uwm.edu Fri Jan 4 19:17:00 1991
Received: from uwm.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA03455; Fri, 4 Jan 91 19:17:00 -0700
Received: by uwm.edu; id AA02377; Fri, 4 Jan 91 20:16:29 -0600
Received: from mis.mcw.edu by fps.mcw.edu (DECUS UUCP ///1.2a/2.5/);
Fri, 4 Jan 91 17:15:32 CDT
Received: by mis.mcw.edu with UUCP/PMDF (DECUS UUCP);
Fri, 4 Jan 1991 17:00 CST
Date: Fri, 4 Jan 1991 17:00 CST
From: Chris Tenaglia - 257-8765 <TENAGLIA@mis.mcw.edu>
Subject: Icon Interpreters
To: icon-group@cs.arizona.edu
Message-Id: <6E06E4A6C04007D5@mis.mcw.edu>
X-Organization: Medical College of Wisconsin MIS Department (Milwaukee, WI)
X-Envelope-To: icon-group@cs.arizona.edu
X-Vms-To: IN%"icon-group@cs.arizona.edu"
Going through my libraries some more I also have something I call basED.
It's a BASIC style text editer. It was deigned for oddball terminals and
teletypes. I used it in the past on TEK4010 terminal emulators to write
graphics programs by piping icon output through unix plot. I have a
library of plot() procedures that generate the sequences plot looks for
much along the line of screen() or itlib.
From basED one could enter line-numbered code. Save it, un-numbered,
compile, link, and run programs from inside basED. It was real
handy. Not quite an interpreter, not quite a shell. It's about 620
lines so I won't post it unless I some requests
come through. It's written for VMS, but I recall that porting to
unix was probably less than an hour once one is familiar with the
code. It's too big for MSDOS.
Chris Tenaglia (System Manager) | Medical College of Wisconsin
8701 W. Watertown Plank Rd. | Milwaukee, WI 53226
(414)257-8765 | tenaglia@mis.mcw.edu, mcwmis!tenaglia
From icon-group-request@arizona.edu Sat Jan 5 14:25:41 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA03079; Sat, 5 Jan 91 14:25:41 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu; Sat, 5 Jan 91 14:25 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA19182; Sat, 5 Jan 91 13:12:05
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Sat, 5 Jan 91 14:25 MST
Date: 5 Jan 91 18:05:11 GMT
From: hsi!mlfarm!ron@uunet.uu.net
Subject: RE: Message conventions
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <DBDE66CF6E49403512@Arizona.edu>
Message-Id: <678@mlfarm.com>
Organization: Maple Lawn Farm, Stonington, CT
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
References: <675@mlfarm.com>
The version of reply.icn I posted earlier contained a subtle bug that
could break on some obscure headers. The version below fixes the bug,
adds additional functionality, and thanks to Richard Goerwitz,
includes more robust code to create a temporary filename. I've also
substituted some of Richard's elegant constructions for my quick and
dirty Icon hacks.
[Ralph -- use this version, please.]
----------------------------[reply.icn, 1.1]---------------------------
# reply.icn - replies to news or mail
# version 1.1 (ron@mlfarm.com, 5 Jan 91)
#
# usage: reply [quote-prefix] < news-article or mail-item
#
# Configuration:
# - change smarthost to the name of your upstream mail feed.
# - change the default editor for your operating system, or use the
# EDITOR environment variable.
# - if your upstream mail feed will not accept addresses in the format
# site.domain!user@upstream-host.domain, you may need to change the
# address parsing code.
#
# The default quote-prefix is " > ".
procedure main(arg)
smarthost := "mlfarm.com"
if find("UNIX", &features) then {
console := "/dev/tty"
tmpdir := "/tmp/"
editor := "/bin/vi"
}
else if find("MS-DOS", &features) then {
console := "CON"
tmpdir := ""
editor := "edlin"
}
else stop("reply: unsupported operating system")
every tmpfile := tmpdir || "reply." || right(1 to 999,3,"0") do
close(open(tmpfile)) | break
reply := open(tmpfile, "w") | stop("reply: cannot open temp file")
every s := !&input do s ? {
=("From: " | "Reply-To: ") & {
if find("<") then {
fullname := trim(tab(upto('<')))
address := (move(1), tab(find(">")))
}
else {
address := trim(tab(upto('(') | 0))
fullname := (move(1), tab(find(")")))
}
quoter := (\fullname | address)
}
=("Date: ") & date := tab(0)
=("Message-Id: ") & id := (tab(find("<")), tab(find(">")+1))
match("Subject: ") & subject := s
match("Newsgroups: ") & newsgroup := tab(upto(',') | 0)
match("References: ") & refs := s
(\address & *s = 0) & {
write(reply, "In-reply-to: ", quoter, "'s message of ", date);
\subject & write(reply, subject)
\newsgroup & write(reply, newsgroup)
\refs & write(reply, refs || " " || id)
write(reply, "\nIn ", id, ", ", quoter, " writes:\n")
break
}
}
prefix := \arg[1] | " > "
every write(reply, prefix, !&input)
edstr := (getenv("EDITOR") | editor) || " " || tmpfile || " < " || console
system(edstr)
stdin := open(console, "r")
writes("Send y/n? ")
upto('nN',read(stdin)) & {
remove(tmpfile)
stop("Reply aborted.")
}
find("@",address) & address ? {
name := tab(upto('@'))
address := (move(1), tab(upto(' ') | 0)) || "!" || name
}
address ||:= "@" || smarthost
mailstr := "mail " || address || " < " || tmpfile
system(mailstr)
write("Reply sent to " || address)
remove(tmpfile)
end
----------------------------------[eof]--------------------------------
--
Ronald Florence ron@mlfarm.com
From icon-group-request@arizona.edu Sun Jan 6 16:27:17 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA10022; Sun, 6 Jan 91 16:27:17 -0700
Received: from UCBVAX.Berkeley.EDU by Arizona.edu; Sun, 6 Jan 91 16:26 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA12786; Sun, 6 Jan 91 15:11:45
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Sun, 6 Jan 91 16:26 MST
Date: 6 Jan 91 17:59:12 GMT
From: hsi!mlfarm!ron@uunet.uu.net
Subject: RE: Message conventions
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <DB04453B52E14003BD@Arizona.edu>
Message-Id: <685@mlfarm.com>
Organization: Maple Lawn Farm, Stonington, CT
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
References: <675@mlfarm.com>, <678@mlfarm.com>
Oops! Some mailers and news-posters use Message-ID; others use
Message-Id. To make reply.icn robust enough to get both, change
"Message-Id: " in line 48 to "Message-I".
--
Ronald Florence ron@mlfarm.com
From KKTK_KOTUS@cc.Helsinki.FI Mon Jan 7 00:17:49 1991
Resent-From: KKTK_KOTUS@cc.Helsinki.FI
Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA19855; Mon, 7 Jan 91 00:17:49 -0700
Received: from hylka.Helsinki.FI by Arizona.edu; Mon, 7 Jan 91 00:17 MST
Resent-Date: Mon, 7 Jan 91 00:17 MST
Date: Mon, 7 Jan 1991 09:16 EET
From: KKTK_KOTUS@cc.Helsinki.FI
Subject: Computational morphology
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <DAC28D1535014006C5@Arizona.edu>
Message-Id: <88D0169D20C04EE9@cc.Helsinki.FI>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: IN%"icon-group@arizona.edu"
Hi,
is anybody out there doing computational morphology with Icon? I have
myself written a stem generator for Finnish noun stems with Icon and would
like to hear about people who have done same sort of things for any
language (which has enough morphology to tackle with.)
Kimmo Kettunen
KKTK_KOTUS@CC.HELSINKI.FI
From icon-group-request@arizona.edu Tue Jan 8 16:32:16 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA08234; Tue, 8 Jan 91 16:32:16 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu; Tue, 8 Jan 91 16:31 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA24700; Tue, 8 Jan 91 15:17:17
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Tue, 8 Jan 91 16:32 MST
Date: 8 Jan 91 03:19:56 GMT
From: hsi!mlfarm!ron@uunet.uu.net
Subject: RE: Message conventions
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <D971377EA291402416@Arizona.edu>
Message-Id: <686@mlfarm.com>
Organization: Maple Lawn Farm, Stonington, CT
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
References: <685@mlfarm.com>, <9101071716.AA29398@hpsdel.sde.hp.com>
Walter Underwood <hsi!hpsdel.sde.hp.com!wunder> writes:
> Oops! Some mailers and news-posters use Message-ID; others use
> Message-Id.
>
> The tags on header lines should be matched ignoring upper/lower case.
> "mEsSaGe-iD:" is a perfectly legal tag, and equivalent to "Message-ID:".
> The program may never see random case tags, but it will probably see all
> upper case tags. Anyway, the "right" fix is a case-insensitive match.
Walter is right (he even quoted RFC 822). I'll spare everyone another
posting of reply.icn. If anyone wants a version with the fix, write
me.
--
Ronald Florence ron@mlfarm.com
From icon-group-request@arizona.edu Wed Jan 9 09:48:14 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA10914; Wed, 9 Jan 91 09:48:14 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu; Wed, 9 Jan 91 09:47 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA12892; Wed, 9 Jan 91 08:33:36
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Wed, 9 Jan 91 09:48 MST
Date: 9 Jan 91 12:20:56 GMT
From: mcsun!cernvax!chx400!hslrswi!naz@uunet.uu.net
Subject: a small problem
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <D8E07EA07131402CB6@Arizona.edu>
Message-Id: <1716@hslrswi.hasler.ascom.ch>
Organization: Hasler AG
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
I'm new to this string scanning stuff, and I'm having difficulty finding
a nice clean way to perform the following simple calculation.
I have a string, S, in which I want to know the number of characters
which are used by any of several known substrings. There is no problem
with overlapping substrings.
Here is a small example to show exactly what I mean:
count := 0
every s ? find ("whizzy" | "ding") do count +:= 1
This would do what I want if I merely wanted to count the number of
occurrences of the substrings "whizzy" and "ding". However, what I
want to do is know the total number of characters in s which are
used for these substrings, however many times they may occur.
I'm hoping to find something with an elegance approaching that of
the above example. Brute force solutions need not apply.
P.S. The real-life problem is that I have ANSI control sequences
embedded in a string which wants to be centered.
NHA
---
PAPER: Norman Azadian; Hasler AG; Belpstrasse 23; 3000 Berne 14; Switzerland
X.400: naz@hslrswi.hasler
UUCP: ...{uunet,ukc,mcvax,...}!cernvax!hslrswi!naz
VOICE: +41 31 63 2178 BITNET: naz%hslrswi.UUCP@cernvax.BITNET
--
PAPER: Norman Azadian; Ascom AG; Belpstrasse 23; 3000 Berne 14; Switzerland
INTERNET: naz%hslrswi.uucp@uunet.uu.net
UUCP: ...{uunet,ukc,mcvax,...}!chx400!hslrswi!naz
VOICE: +41 31 63 2178 BITNET: naz%hslrswi.UUCP@cernvax.BITNET
From icon-group-request@arizona.edu Wed Jan 9 16:33:11 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA26645; Wed, 9 Jan 91 16:33:11 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu; Wed, 9 Jan 91 16:32 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA00252; Wed, 9 Jan 91 15:28:46
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Wed, 9 Jan 91 16:32 MST
Date: 9 Jan 91 15:33:30 GMT
From: hsi!mlfarm!ron@uunet.uu.net
Subject: post.icn (news poster)
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <D8A7EDD74BC1402633@Arizona.edu>
Message-Id: <689@mlfarm.com>
Organization: Maple Lawn Farm, Stonington, CT
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
It won't put gnus-post or Pnews out of business, but it works, both
for original postings and follow-ups. The code borrows from Richard
Goerwitz's tempname generator and from reply.icn. The limited ms-dos
support is untested. Perhaps someone can suggest how to include
support for VMS or other systems in this and reply.icn.
I hope this is useful to someone.
--
Ronald Florence ron@mlfarm.com
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
# post.icn
# This archive created: Wed Jan 9 10:26:12 1991
# By: Ronald Florence (Maple Lawn Farm, Stonington, CT)
export PATH; PATH=/bin:/usr/bin:$PATH
if test -f 'post.icn'
then
echo shar: "will not over-write existing file 'post.icn'"
else
cat << \SHAR_EOF > 'post.icn'
############################################################################
#
# Name: post.icn
#
# Title: News Poster
#
# Author: Ronald Florence (ron@mlfarm.com)
#
# Date: January 8, 1991
#
############################################################################
#
# This program posts a news article to Usenet via uux or mail.
# Given an optional argument (the name of a file containing a
# news article), it creates a follow-up article, with an
# attribution and quoted text.
#
# usage: post [news-article]
#
############################################################################
#
# Configure: smarthost, mode, editor or EDITOR environment variable.
#
############################################################################
#
# Requires: UNIX or MS-DOS.
# Bugs: ms-dos requires hard-coded system info.
#
############################################################################
global sitename, domain, tz
procedure main(arg)
smarthost := "news-feed" # Your news feed.
mode := "uux" # Use "mail" for a sendnews feed.
domain := ".UUCP"
if (find("UNIX", &features) & find("pipes", &features)) then {
console := "/dev/tty"
tmpdir := "/tmp/"
(inf := open("logname", "pr")) & (logname := !inf) & close(inf)
# Uuname sometimes pads with spaces.
(inf := open("uuname -l", "pr")) & (sitename := trim(!inf)) & close(inf)
(tz := getenv("TZ")) & tz ?:= (tab(many(&letters)), tab(upto(&letters)))
sigfile := getenv("HOME") || "/.signature"
editor := "/bin/vi"
}
else if find("MS-DOS", &features) then {
console := "CON"
tmpdir := ""
logname := &null
sitename := &null
tz := &null # Hours off GMT.
sigfile := &null
editor := "edlin"
}
(\logname & \sitename & \tz) | stop("post: missing system info")
article := open(tmpfile := tempname(tmpdir), "w") |
stop("post: cannot write temp file")
write(article, "Path: ", sitename, "!", logname)
write(article, "From: ", logname, "@", sitename, domain)
if \arg[1] then {
inf := open(arg[1]) | {
remove(tmpfile)
stop("post: cannot read ", arg[1])
}
reply_headers(inf, article)
every write(article, " > ", !inf)
close(inf)
}
else {
write(article, query("Newsgroups: "))
write(article, query("Subject: "))
every write(article, req_headers())
write(article, "\n")
}
edstr := (getenv("EDITOR") | editor) || " " || tmpfile || " < " || console
system(edstr)
writes("Are you sure you want to post this to Usenet y/n? ")
stdin := open(console)
upto('nN', read(stdin)) & {
remove(tmpfile)
stop("Article aborted.")
}
# Try to append the .signature.
\sigfile & (inf := open(sigfile)) & {
article := open(tmpfile, "a")
write(article, "--")
every write(article, !inf)
close(inf)
}
# Don't force an immediate poll.
if find("uux", mode) then mode ||:= " - -r"
# Sendnews format requires an initial `N'.
else if find("mail", mode) then {
inf := open(tmpfile)
outf := open(tmp2 := tempname(tmpdir), "w")
every write(outf, "N", !inf)
remove(tmpfile)
rename(tmp2, tmpfile)
}
mode ||:= " " || smarthost || "!rnews < " || tmpfile
(system(mode) = 0) & write("Article posted!")
remove(tmpfile)
end
procedure tempname(dir)
every temp_name := dir || "article." || right(1 to 999,3,"0") do {
close(open(temp_name)) & next
suspend \temp_name
}
end
procedure reply_headers(infile, art)
every s := !infile do s ? {
# Case-insensitive matches for headers.
tab(match("from: ", map(&subject))) & {
if find("<") then {
fullname := trim(tab(upto('<')))
address := (move(1), tab(find(">")))
}
else {
address := trim(tab(upto('(') | 0))
fullname := (move(1), tab(find(")")))
}
quoter := (\fullname | address)
}
tab(match("date: ", map(&subject))) & date := tab(0)
tab(match("message-id: ", map(&subject))) & id := tab(0)
match("subject: ", map(&subject)) & subject := s
match("newsgroups: ", map(&subject)) & newsgroup := tab(upto(',') | 0)
match("references: ", map(&subject)) & refs := s
(\quoter & *s = 0) & {
# Newsgroup and subject are required.
write(art, \newsgroup | query("Newsgroup: "))
write(art, \subject | query("Subject: "))
# Message-ID and Date go here.
every write(art, req_headers())
# Threaded readers need References.
write(art, \refs | "References:", " ", id)
write(art, "In-reply-to: ", quoter, "'s message of ", date)
write(art, "\nIn ", id, ", ", quoter, " writes:\n")
return
}
}
end
procedure req_headers()
# Crude, but it's a unique id.
uniq := "<"
&date || &clock ? while tab(upto(&digits)) do uniq ||:= tab(many(&digits))
uniq ||:= "@" || sitename || domain || ">"
# Date in RFC 822 format.
&dateline ? {
month := left((tab(find(" ")+1), tab(many(&letters))), 3) || " "
date := (tab(upto(&digits)), tab(many(&digits))) || " " || month
date ||:= (tab(upto(&digits)), right(tab(many(&digits)), 2))
}
# GMT would be better; this is allowed.
if (tz > 0) then zone := " -"
else zone := " +"
zone ||:= left(right(abs(tz), 2, "0"), 4, "0")
suspend "Message-ID: " || uniq
suspend "Date: " || date || " " || &clock || zone
end
procedure query(prompt)
writes(prompt)
ans := read()
return prompt || ans
end
SHAR_EOF
if test 5403 -ne "`wc -c < 'post.icn'`"
then
echo shar: "error transmitting 'post.icn'" '(should have been 5403 characters)'
fi
fi
exit 0
# End of shell archive
--
Ronald Florence ron@mlfarm.com
From nevin@apple.com Wed Jan 9 21:54:45 1991
Received: from apple.com ([130.43.2.2]) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA06447; Wed, 9 Jan 91 21:54:45 -0700
Received: from [90.1.0.10] by apple.com with SMTP (5.61/25-eef)
id AA28618; Wed, 9 Jan 91 20:54:07 -0800
for icon-group@cs.arizona.edu
Received: by goofy.apple.com (5.61/25-eef)
id AA01800; Wed, 9 Jan 91 20:54:04 -0800
for uunet!chx400!hslrsw!naz@internet-gateway.apple.com
Date: Wed, 9 Jan 91 20:54:04 -0800
From: Nevin Liber <nevin@apple.com>
Message-Id: <9101100454.AA01800@internal.apple.com>
To: icon-group@cs.arizona.edu
Subject: Re: a small problem
Cc: uunet!chx400!hslrsw!naz@goofy.apple.com
Norman Azadian writes:
> I have a string, S, in which I want to know the number of characters
> which are used by any of several known substrings. There is no problem
> with overlapping substrings.
> Here is a small example to show exactly what I mean:
> count := 0
> every s ? find ("whizzy" | "ding") do count +:= 1
> However, what I
> want to do is know the total number of characters in s which are
> used for these substrings, however many times they may occur.
The following will do the job:
iCharacterCount := 0
every find(sSubString := "whizzy" | "ding", sLine) do
iCharacterCount +:= *sSubString
(Technically, this doesn't use string scanning, although it can be easily
modified to do so. I tend to use string scanning only when I have to
actually parse something.) This solution uses a temporary variable
(sSubString) to [implicitly] keep track of the length.
Additionally, I would keep the substrings in a set, making it
easy to add or remove substrings to be checking. My code would look
something like:
SSubStrings := set(["whizzy", "ding"])
iCharacterCount := 0
every find(sSubString := !SSubStrings, sLine) do
iCharacterCount +:= *sSubString
I hope this is elegant enough for you. :-)
___
NEVIN ":-)" LIBER
email: nevin@apple.com paper: Apple Computer, Inc.
voice: (408) 974-6491 20525 Mariani Avenue, MS: 71AB
AppleLink: NEVIN.LIBER Cupertino, California 95014
From icon-group-request@arizona.edu Thu Jan 10 00:18:01 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA10464; Thu, 10 Jan 91 00:18:01 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu; Thu, 10 Jan 91 00:17 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA16356; Wed, 9 Jan 91 23:07:53
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Thu, 10 Jan 91 00:17 MST
Date: 10 Jan 91 05:57:44 GMT
From: midway!quads.uchicago.edu!goer@uunet.uu.net
Subject: RE: a small problem
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <D867059A1FD140390B@Arizona.edu>
Message-Id: <1991Jan10.055744.15170@midway.uchicago.edu>
Organization: University of Chicago
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
References: <9101100454.AA01800@internal.apple.com>
In <9101100454.AA01800@internal.apple.com> nevin@APPLE.COM (Nevin Liber) writes:
>
>> ...what I
>> want to do is know the total number of characters in s which are
>> used for these substrings, however many times they may occur.
>
>The following will do the job:
>
> iCharacterCount := 0
> every find(sSubString := !SSubStrings, sLine) do
> iCharacterCount +:= *sSubString
This is nice. One thing, though, might be added: If any of the strings
in set SSubStrings overlap, then the above solution won't work the way
Norman wants it to. The substrings variable needs to be a list, with the
elements prioritized in some way (e.g. longest strings first):
count := 0
s ? while tab(find(tmp := !substrings)) do
count +:= *=tmp
I haven't tested this code fragment. Oh no! :-)
Question: What is the best way to take a list of strings, remove those
strings which are substrings of some other string in the list, and then
sort by length?
-Richard (goer@sophist.uchicago.edu)
From fps!mis.mcw.edu!mis.mcw.edu!TENAGLIA@uwm.edu Thu Jan 10 07:05:46 1991
Received: from uwm.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA25697; Thu, 10 Jan 91 07:05:46 -0700
Received: by uwm.edu; id AA21186; Thu, 10 Jan 91 08:05:32 -0600
Received: from mis.mcw.edu by fps.mcw.edu (DECUS UUCP ///1.2a/2.5/);
Thu, 10 Jan 91 07:39:53 CDT
Received: by mis.mcw.edu with UUCP/PMDF (DECUS UUCP);
Thu, 10 Jan 1991 06:15 CST
Date: Thu, 10 Jan 1991 06:15 CST
From: Chris Tenaglia - 257-8765 <TENAGLIA@mis.mcw.edu>
Subject: Shell Archives
To: icon-group@cs.arizona.edu
Message-Id: <CAFC3229806003D5@mis.mcw.edu>
X-Organization: Medical College of Wisconsin MIS Department (Milwaukee, WI)
X-Envelope-To: icon-group@cs.arizona.edu
X-Vms-To: IN%"icon-group@cs.arizona.edu"
I've been gradually collecting software in unix shell archive format. I use
icon on a vms machine. Anyone out there who's already written an icon version
to unravel shell archives? I don't want to reinvent the wheel. Since most
icon folks are already in unix the reply should probably be emailed.
Thanx in advance.
Chris Tenaglia (System Manager) | Medical College of Wisconsin
8701 W. Watertown Plank Rd. | Milwaukee, WI 53226
(414)257-8765 | tenaglia@mis.mcw.edu, mcwmis!tenaglia
From nevin@apple.com Thu Jan 10 21:53:31 1991
Received: from apple.com by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA27026; Thu, 10 Jan 91 21:53:31 -0700
Received: from [90.1.0.10] by apple.com with SMTP (5.61/25-eef)
id AA13136; Thu, 10 Jan 91 20:53:24 -0800
for icon-group@cs.arizona.edu
Received: by goofy.apple.com (5.61/25-eef)
id AA06745; Thu, 10 Jan 91 20:53:21 -0800
for icon-group@cs.arizona.edu
Date: Thu, 10 Jan 91 20:53:21 -0800
From: Nevin Liber <nevin@apple.com>
Message-Id: <9101110453.AA06745@internal.apple.com>
To: icon-group@cs.arizona.edu
Subject: Re: A small problem
[Note: the original poster does not need to worry about overlapping
strings, since he is only looking for ANSI control sequences. This is
still an interesting problem, however.]
Richard (goer@sophist.uchicago.edu) writes:
> This is nice. One thing, though, might be added: If any of the strings
> in set SSubStrings overlap, then the above solution won't work the way
> Norman wants it to. The substrings variable needs to be a list, with the
> elements prioritized in some way (e.g. longest strings first):
> count := 0
> s ? while tab(find(tmp := !substrings)) do
> count +:= *tmp
> I haven't tested this code fragment. Oh no! :-)
You may want to look at this code again. It won't work as coded
("while" won't generate all of the substrings).
Assuming that the code did work, I'm still not sure of the approach.
Look at the following case:
What happens if you have the following List of words to look for:
["bullwinkle", "rocky", "bull"]
and the sentence is:
"rocky and bullwinkle had picked a fight with a really mean bull."
With your approach, I believe that "bullwinkle" would match first, and
"rocky" would never be found.
If you have overlapping strings, this problem becomes a bit more difficult.
One approach I was thinking of is to first analyze the set of
substrings, subtract lengths for smaller substrings contained in the
larger ones, and store the results in a table, such as:
"bullwinkle" -> 6 (10 for bullwinkle - 4 for bull)
"rocky" -> 5
"bull" -> 4
___
NEVIN ":-)" LIBER
email: nevin@apple.com paper: Apple Computer, Inc.
voice: (408) 974-6491 20525 Mariani Avenue, MS: 71AB
AppleLink: NEVIN.LIBER Cupertino, California 95014
From goer%sophist@gargoyle.uchicago.edu Thu Jan 10 23:29:59 1991
Resent-From: goer%sophist@gargoyle.uchicago.edu
Received: from Arizona.edu (Hopey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA00524; Thu, 10 Jan 91 23:29:59 -0700
Return-Path: goer@sophist.uchicago.edu
Received: from gargoyle.uchicago.edu by Arizona.edu; Thu, 10 Jan 91 23:29 MST
Received: by gargoyle.uchicago.edu from sophist (sophist.uchicago.edu)
(4.0/1.14) id AA25900; Fri, 11 Jan 91 00:29:23 CST
Received: by sophist (4.1/UofC3.1X) id AA06070; Fri, 11 Jan 91 00:32:10 CST
Resent-Date: Thu, 10 Jan 91 23:29 MST
Date: Fri, 11 Jan 91 00:32:10 CST
From: Richard Goerwitz <goer%sophist@gargoyle.uchicago.edu>
Subject: hmmm
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <D7A487636A81404941@Arizona.edu>
Message-Id: <9101110632.AA06070@sophist>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
> count := 0
> s ? while tab(find(tmp := !substrings)) do
> count +:= *tmp
> I haven't tested this code fragment. Oh no! :-)
You may want to look at this code again. It won't work as coded
("while" won't generate all of the substrings).
I'm not sure what you mean. The expression find(tmp := !substrings) will
pop elements off of the list, substrings, until a match is found. Every
time a match is found, it will tab past it, and start looking for another
substring. In point of fact, the while is not the determining factor here.
Rather, it is the success of find(). If in fact find() keeps failing (as
will eventually happen in most cases), backtracking could easily take us
through the entire substring list (regardless of the "while").
Assuming that the code did work, I'm still not sure of the approach.
Look at the following case:
What happens if you have the following List of words to look for:
["bullwinkle", "rocky", "bull"]
and the sentence is:
"rocky and bullwinkle had picked a fight with a really..."
With your approach, I believe that "bullwinkle" would match first, and
"rocky" would never be found.
Ahhh. On this point it seems you are right. And I thought I was being so
clever. I guess that's what I get for posting untested code.
As penance, I offer one brute-force solution:
count := 0
s ? every i := 1 to *&subject do
count +:= (tab(i), *=!substrings)
Incidentally, this !substrings stuff bugs me a lot. Anyone want to offer
us an fgrep-like utility that will use a deterministic finite state automa-
ton instead of endless backtracking?
-Richard (goer@sophist.uchicago.edu)
From fps!mis.mcw.edu!mis.mcw.edu!TENAGLIA@uwm.edu Sun Jan 13 07:31:45 1991
Received: from uwm.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA15480; Sun, 13 Jan 91 07:31:45 -0700
Received: by uwm.edu; id AA03806; Sun, 13 Jan 91 08:31:36 -0600
Received: from mis.mcw.edu by fps.mcw.edu (DECUS UUCP ///1.2a/2.5/);
Sun, 13 Jan 91 08:28:03 CDT
Received: by mis.mcw.edu with UUCP/PMDF (DECUS UUCP);
Sun, 13 Jan 1991 07:54 CST
Date: Sun, 13 Jan 1991 07:54 CST
From: Chris Tenaglia - 257-8765 <TENAGLIA@mis.mcw.edu>
Subject: VMS Shell Archive Facility
To: icon-group@cs.arizona.edu
Message-Id: <34526B3240600B5F@mis.mcw.edu>
X-Organization: Medical College of Wisconsin MIS Department (Milwaukee, WI)
X-Envelope-To: icon-group@cs.arizona.edu
X-Vms-To: IN%"icon-group@cs.arizona.edu"
Below is a shell archive that contains itself. I wrote it because I wanted
to extract some of the archived goodies that get posted here. I made it
for VMS and MS-DOS. I haven't tested the MS-DOS ;-) parts yet. I also can't
test the builder part as I have no unix system yet to test it. Maybe
someone can let me know if it works. Maybe someone will want to add support
for MACintosh, AMIGA, etc,... Maybe we should have an icon archiver, that's
hardware/os independent? Any comments?
Chris Tenaglia (System Manager) | Medical College of Wisconsin
8701 W. Watertown Plank Rd. | Milwaukee, WI 53226
(414)257-8765 | tenaglia@mis.mcw.edu, mcwmis!tenaglia
#!/bin/sh
# This is shar.sh, a shell archive (sh.icn 1.0)
# made Sunday, January 13, 1991 7:47 am by tenaglia@mis.mcw.edu
# Source directory /usr53/tenaglia/i/
#
# existing files will Not be overwritten, hopefully
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 7556 -rw-r--r-- sh.icn
# 928 -rw-r--r-- sh.txt
#
# Test of VMS Shell Archive Facility
# Does everything extract properly under unix?
#
# ============== sh.icn ==============
if test X"$1" != X"-c" -a -f 'sh.icn'; then
echo "File already exists: skipping 'sh.icn'"
else
echo "x - extracting sh.icn (Text)"
sed 's/^X//' << 'SHEOF' > sh.icn &&
X##################################################################
X# #
X# SH.ICN 01/11/91 BY TENAGLIA #
X# #
X# PROGRAM HANDLES UNIX SHELL ARCHIVES #
X# USAGE : sh archive [action] [target] #
X# Where action is extract(default) list or build #
X# If action is list, target is ignored. #
X# If action is extract (""), target is ignored #
X# If action id build, target is filespec to archive #
X# NOTE : Does not make split archives yet. #
X# NOTE : Extraction doesn't check for overwrite, just does it. #
X# NOTE : shar 3.xx lengths include the leading X, and don't #
X# match here. This uses their real lengths. #
X# #
X##################################################################
Xglobal os, files
Xprocedure main(param)
X source := param[1] | input("_Source:")
X option := param[2] | "extract"
X target := param[3] | "!nill"
X work := case option of
X {
X "list" : " Lister\n"
X "build": " Builder\n"
X default: " Extractor\n"
X }
X write("sh : Unix Shell Archive",work)
X os := getsys()
X sum := 0
X if option == "build" then build(source)
X (in := open(source)) | stop("Can't open ",source)
X while line := read(in) do
X {
X stuff := parse(line,'\"\'\t ')
X if stuff[1] == "sed" & stuff[2] == "s/^X//" then
X {
X every i := 1 to *stuff do
X {
X if stuff[i] == "<<" then { eof := stuff[i+1] ; next }
X if match("<<",stuff[i]) then { eof := stuff[i][3:0] ; next }
X if stuff[i] == ">>" then
X {
X name := stuff[i+1]
X method := "a" # append
X what := "appended."
X next
X }
X if match(">>",stuff[i]) then
X {
X name := stuff[i][2:0]
X method := "a" # append
X what := "appended."
X next
X }
X if stuff[i] == ">" then
X {
X name := stuff[i+1]
X method := "w" # create
X what := "written."
X next
X }
X if match(">",stuff[i]) then
X {
X name := stuff[i][2:0]
X method := "w" # create
X what := "written."
X next
X }
X }
X prog := extract(in,eof)
X } else next
X directory := if target == "!nill" then "" else target
X (out := open(target||name,method)) | stop("Can't write ",name)
X every stmt := !prog do
X {
X if option == "extract" then write(out,stmt)
X sum +:= *stmt
X }
X if option == "extract"
X then write(name," : ",sum," bytes ",what)
X else write(name," : contains ",sum," bytes.")
X sum := 0
X close(out)
X }
X close(in)
X end
X
X#
X# This routine extracts the shell archive for a module. It returns
X# the module in a list structure.
X#
Xprocedure extract(file,eofstr)
X lst := []
X until match(eofstr,(str := read(file))) do
X put(lst,str[2:0])
X return lst
X end
X
X#
X# This routine builds a shell archive. archive is the archive to be made.
X# The rest of this is interactive.
X#
Xprocedure build(archive)
X username := input("Username :")
X directory := input("Directory :")
X modules := table([])
X find(".",archive) | (archive ||:= ".sh")
X (output := open(archive,"w")) | stop("Can't write to ",archive)
X comments := ["#"] ; write("Enter Comments (blank line when done)")
X repeat {
X comment := input("Comment :")
X if trim(comment) == "" then break
X put(comments,"# " || comment) }
X put(comments,"#")
X begin := ["#!/bin/sh",
X "# This is " || archive || ", a shell archive (sh.icn 1.0)",
X "# made " || &dateline || " by " || username,
X "# Source directory " || fsmap(directory),
X "#", "# existing files will Not be overwritten, hopefully","#",
X "# This shar contains:",
X "# length mode name",
X "# ------ ---------- ------------------------------------------",
X ]
X namelist := []
X repeat {
X name := input("File (blank when done) :")
X if trim(name) == "" then break
X (infile := open(directory||name)) | { write("Can't open ",directory,name) ; next }
X code := [ "# ============== " || name || " ==============",
X "if test X\"$1\" != X\"-c\" -a -f '" || name || "'; then",
X " echo \"File already exists: skipping '" || name || "'\"",
X "else",
X "echo \"x - extracting " || name || " (Text)\"",
X "sed 's/^X//' << 'SHEOF' > " || name || " &&" ]
X measure := 0
X while text := read(infile) do
X {
X measure +:= *text
X put(code,"X" || text)
X }
X put(code,"SHEOF") ; close(infile)
X put(begin,"# " || right(measure,6) || " -rw-r--r-- " || name)
X insert(modules,name,copy(code)) ; put(namelist,name) }
X output := open(archive,"a")
X every write(output,!begin)
X every write(output,!comments)
X every file := !namelist do every write(output,!(modules[file]))
X write(output,"#")
X write(output,"# End of sh archive.")
X close(output)
X stop("sh archive written to ",archive)
X end
X
X# # ============= README ============== this is what the
X# if test X"$1" != X"-c" -a -f 'README'; then beginning of a shell
X# echo "File already exists: skipping 'README'" archive body should
X# else look like.
X# echo "x - extracting README (Text)"
X# sed 's/^X//' << 'SHAR_EOF' > README &&
X
X#
X# This routine parses a string with respect to some delimiter.
X# It returns the tokens in a list structure.
X#
Xprocedure parse(line,delims)
X static chars
X chars := &cset -- delims
X tokens := []
X line ? while tab(upto(chars)) do put(tokens,tab(many(chars)))
X return tokens
X end
X
X#
X# This routine prompts for a string input. The entered string is returned.
X#
Xprocedure input(prompt)
X writes(prompt)
X return read()
X end
X
X#
X# This procedure determines the os by examining &features.
X#
Xprocedure getsys()
X files := "DIR " # most logical initially
X if &host == "MS-DOS" then
X return &host
X tmp := []
X every feature := &features do
X put(tmp,feature)
X if tmp[1] ~== "VMS" then files := "ls "
X return tmp[1]
X end
X
X#
X# This routine maps the directory spec to unix style notation
X#
Xprocedure fsmap(spec)
X if spec == "" then return spec
X case os of
X {
X "VMS" : { if (i := find(":",spec)) then
X {
X path := "/usr" || ord(spec[i-1]) || "/"
X if (x := find("[",spec)) then
X {
X y := find("]",spec)
X path ||:= map(spec[x+1:y],".","/") || "/"
X } else path ||:= spec[i+1:0] || "/"
X } else {
X if (x := find("[",spec)) then
X {
X y := find("]",spec)
X path := map(spec[x+1:y],".","/") || "/"
X } else path ||:= spec || "/"
X }
X return path
X }
X "MS-DOS" : { if find(":",spec) then
X {
X path := "/usr" || ord(map(spec[1])) - 96 || "/" ||
X map(spec[3:0],"\\","/")
X } else {
X path := map(spec,"\\","/")
X }
X (path[-1] == "/") | (path ||:= "/")
X }
X default : { return spec }
X }
X end
X
SHEOF
# ============== sh.txt ==============
if test X"$1" != X"-c" -a -f 'sh.txt'; then
echo "File already exists: skipping 'sh.txt'"
else
echo "x - extracting sh.txt (Text)"
sed 's/^X//' << 'SHEOF' > sh.txt &&
X
XThis is a shell archive utility for non-unix hosts. It can extract from
Xshell archives (no overwrite checking done). It can list archives. And
Xit can create archives. No actual shell script interpretation is done.
XFor extraction it reads the important stuff and extracts the files. For
Xbuilding, it runs through an interactive dialog.
X
XExamples : sh termlib1.sh Extracts by default
X sh mystuff build Builds mystuff.sh archive
X sh mgale.sh list Lists modules of mgale archive
X
XI've written it primarily for VMS and MS-DOS. I haven't tested the MS-DOS
Xpart yet. Also since I don't have unix out there, someone out there in
Xunixland can test it to make sure that what it builds is extractable.
X
XYours truly,
X
XChris Tenaglia (System Manager) | Medical College of Wisconsin
X8701 W. Watertown Plank Rd. | Milwaukee, WI 53226
X(414)257-8765 | tenaglia@mis.mcw.edu, mcwmis!tenaglia
X
SHEOF
#
# End of sh archive.
From ralph Mon Jan 14 05:54:53 1991
Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA24039; Mon, 14 Jan 91 05:54:53 -0700
Date: Mon, 14 Jan 91 05:54:50 MST
From: "Ralph Griswold" <ralph>
Message-Id: <9101141254.AA13162@cheltenham.cs.arizona.edu>
Received: by cheltenham.cs.arizona.edu; Mon, 14 Jan 91 05:54:50 MST
To: dave@cs.arizona.edu
Subject: Re: Icon V8 for the Amiga?
Cc: icon-group
Version 8 of Icon was implemented for the Amiga about a year ago. It's
part of our regular distribution.
Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
+1 602 621 6609 ralph@cs.arizona.edu uunet!arizona!ralph
From icon-group-request@arizona.edu Mon Jan 14 11:04:25 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Osprey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA04692; Mon, 14 Jan 91 11:04:25 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu; Sun, 13 Jan 91 17:36 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA09315; Sun, 13 Jan 91
16:23:07 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Sun, 13 Jan 91 17:36 MST
Date: 14 Jan 91 00:11:55 GMT
From: dave@arizona.edu
Subject: Icon V8 for the Amiga?
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <D57A6E6FA8D14062A5@Arizona.edu>
Message-Id: <661@caslon.cs.arizona.edu>
Organization: U of Arizona CS Dept, Tucson
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Is anyone working on a port of Icon V8 for the Amiga?
Dave Schaumann | We've all got a mission in life, though we get into ruts;
dave@cs.arizona.edu | some are the cogs on the wheels, others just plain nuts.
-Daffy Duck.
From icon-group-request@arizona.edu Mon Jan 14 11:18:39 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Osprey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA05453; Mon, 14 Jan 91 11:18:39 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu; Sat, 12 Jan 91 16:19 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA03279; Sat, 12 Jan 91
15:15:09 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Sat, 12 Jan 91 16:20 MST
Date: 12 Jan 91 13:52:18 GMT
From: hsi!mlfarm!ron@uunet.uu.net
Subject: RE: post.icn (news poster)
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <D64E3597DC11405083@Arizona.edu>
Message-Id: <693@mlfarm.com>
Organization: Maple Lawn Farm, Stonington, CT
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
References: <689@mlfarm.com>
This patch will add (Full Name) to the From line of outgoing postings
from post.icn. Most of the changes are added lines, so if you don't
have `patch' it shouldn't be too onerous to do manually.
If your passwd file keeps full names between a "-" and a "(", try
setting "unixtype" to "usg". Use "bsd" for Xenix, V7 or other passwd
files which have the full name the first item after the colon in the
field. The ms-dos support relies on a hard-coded full name (ugh!).
*** post.icn~ Tue Jan 8 19:57:00 1991
--- post.icn Thu Jan 10 23:15:24 1991
***************
*** 19,25 ****
#
############################################################################
#
! # Configure: smarthost, mode, editor or EDITOR environment variable.
#
############################################################################
#
--- 19,25 ----
#
############################################################################
#
! # Configure: smarthost, mode, unixtype, editor or EDITOR env. variable.
#
############################################################################
#
***************
*** 34,39 ****
--- 34,40 ----
smarthost := "news-feed" # Your news feed.
mode := "uux" # Use "mail" for a sendnews feed.
+ unixtype := "bsd" # Use "usg" for "-Full Name(" passwd file.
domain := ".UUCP"
if (find("UNIX", &features) & find("pipes", &features)) then {
***************
*** 43,48 ****
--- 44,57 ----
# Uuname sometimes pads with spaces.
(inf := open("uuname -l", "pr")) & (sitename := trim(!inf)) & close(inf)
(tz := getenv("TZ")) & tz ?:= (tab(many(&letters)), tab(upto(&letters)))
+ \logname & (inf := open("/etc/passwd")) & every s := !inf do s ? {
+ =(logname) & {
+ every tab(upto(':')+1) \4
+ if find("bsd", unixtype) then fullname := tab(upto(':'))
+ else fullname := (tab(upto('-')+1), tab(upto('(')))
+ break
+ }
+ }
sigfile := getenv("HOME") || "/.signature"
editor := "/bin/vi"
}
***************
*** 52,57 ****
--- 61,67 ----
logname := &null
sitename := &null
tz := &null # Hours off GMT.
+ fullname := &null
sigfile := &null
editor := "edlin"
}
***************
*** 59,65 ****
article := open(tmpfile := tempname(tmpdir), "w") |
stop("post: cannot write temp file")
write(article, "Path: ", sitename, "!", logname)
! write(article, "From: ", logname, "@", sitename, domain)
if \arg[1] then {
inf := open(arg[1]) | {
--- 69,77 ----
article := open(tmpfile := tempname(tmpdir), "w") |
stop("post: cannot write temp file")
write(article, "Path: ", sitename, "!", logname)
! writes(article, "From: ", logname, "@", sitename, domain)
! \fullname & writes(article, " (", fullname, ")")
! write(article)
if \arg[1] then {
inf := open(arg[1]) | {
--
Ronald Florence ron@mlfarm.com
From icon-group-request@arizona.edu Mon Jan 14 16:17:34 1991
Resent-From: icon-group-request@arizona.edu
Received: from MERLIN.TELCOM.ARIZONA.EDU by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA19400; Mon, 14 Jan 91 16:17:34 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Mon, 14 Jan
1991 16:11 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA07481; Mon, 14 Jan 91
14:52:48 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Mon, 14 Jan 1991 16:17 MST
Date: 14 Jan 91 19:16:50 GMT
From: mcsun!cernvax!chx400!hslrswi!naz@uunet.uu.net (Norman Azadian)
Subject: gripe
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <43B50DF0808009A8@Arizona.edu>
Message-Id: <1724@hslrswi.hasler.ascom.ch>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: Hasler AG
I spent a bunch of time this weekend fiddling with Icon library routines.
Have I overlooked a feature, or is Icon just amazingly deficient in this
department? Sorely lacking is the ability to make something global at
the module (file) level, without making it public for the whole world.
This lack means that library files have to be very carefully coordinated
indeed, practically precluding the casual sharing of routines that the
net is so good for.
Have I missed something, or is there some good reason that this has
been excluded from the language, or has this subject already been
beaten to death in past net wars?
While I'm at it, I'd like to put in a gripe for the linker under DOS,
or to be more precise, under the MKS Toolkit running under DOS. The
Toolkit gives me 80% of an unix environment on my measly AT clone, and
with good speed and features. Best of all I can type paths as God
meant them to be typed, with forward slashes. But the linker has
problems with this. Either the files must be in the same directory,
or an absolute path has to be given, or one must do the link under DOS.
All of these options stink, but for now I'm using plan B. I suspect
the linker considers pathname component separators to always be "\",
and so loses under the MKS Toolkit. Fixing it is probably simple.
I believe open() has similar difficulties, but I've been able to
get around that without undue strain.
I've written a module, soon to be released at a net node near you,
which solves this problem for Icon programs. By judicious fiddling
with what DOS calls the "switch character", one can convince programs
to work in both DOS and the MKS Toolkit, without loss of generality.
True it does dive into an undocumented DOS function (ugggh), but it
beats the alternative of running under DOS (yeccch).
NHA
---
--
PAPER: Norman Azadian; Ascom AG; Belpstrasse 23; 3000 Berne 14; Switzerland
INTERNET: naz%hslrswi.uucp@uunet.uu.net
UUCP: ...{uunet,ukc,mcvax,...}!chx400!hslrswi!naz
VOICE: +41 31 63 2178 BITNET: naz%hslrswi.UUCP@cernvax.BITNET
From icon-group-request@arizona.edu Wed Jan 16 09:41:34 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA18548; Wed, 16 Jan 91 09:41:34 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Wed, 16 Jan
1991 09:41 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA02655; Wed, 16 Jan 91
08:25:28 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Wed, 16 Jan 1991 09:41 MST
Date: 16 Jan 91 16:06:17 GMT
From: eru!hagbard!sunic!sics.se!sics!soder@bloom-beacon.mit.edu (Hakan
Soderstrom)
Subject: Summary: exit codes from Icon programs
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <9EBB9E36108015BD@Arizona.edu>
Message-Id: <SODER.91Jan16170617@basm.inmic.se>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: Swedish Institute of Microelectronics, Kista
A while ago I thought I had a problem with Icon exit codes
under recent versions of SunOS. I wondered if anyone could
verify that an Icon program always exits by calling the Unix
'exit' and promised to post a summary.
The summary is that without net response I had to resolve
the problem myself. Icon very carefully exits through a Unix
'exit'. The problem I had turned out to be a C program which
piped its output into the Icon program and exited by just
flowing out of 'main'...
I would like to remove any stain of suspicion against Icon
that my previous posting might have caused among readers.
The project I am involved in has developed an
object-oriented database management system. In particular
its DDL and DML compilers include 17.000 lines of Icon code
and run on several major brands of Unix workstations.
So far, we have never found a bug in Icon. (For the sake of
portability we have avoided co-expressions, however.) Even
more remarkable is that among all the complaints we have had
about our system few, if any, have complained about the
execution speed of the compilers. Our implementation
technique is to implement lexer and parser as a C program,
using lex and yacc. An Icon program reads the resulting
parse tree and does all the semantic processing.
--
----------------------------------------------------
Hakan Soderstrom Phone: +46 (8) 752 1138
NMP-CAD Fax: +46 (8) 750 8056
P.O. Box 1193 E-mail: soder@nmpcad.se
S-164 22 Kista, Sweden
From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS Wed Jan 16 10:15:31 1991
Received: from umich.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA19958; Wed, 16 Jan 91 10:15:31 -0700
Received: from um.cc.umich.edu by umich.edu (5.61/1123-1.0)
id AA24948; Wed, 16 Jan 91 12:15:24 -0500
Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Wed, 16 Jan 91 12:09:05 EST
Date: Wed, 16 Jan 91 12:04:10 EST
From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
To: icon-group@cs.arizona.edu
Message-Id: <285847@Wayne-MTS>
Subject: Usage of break
Today I ran into the kind of problem I'm sure most of us have now and then:
a single line in an Icon program whose behavior I just couldn't understand.
What I wrote was:
repeat{
...
until find("\\syntax", read(infile) | break)
...
}
The idea was to read lines until I found one containing `\syntax' or the
file was exhausted. (I intended to throw out the `\syntax' line; I was
only interested in what followed it.) I couldn't understand why the
expression was exiting immediately.
What I finally realized was that in the constructs
while expr1 do expr2
and
until expr1 do expr2
a `break' in expr1 terminates the construct in the same way as if it's in
expr2. I read page 19 of the Icon book fairly carefully, but not carefully
enough; it says that a break expression causes immediate termination of the
loop in which it occurs. I had thought that `the loop' was just expr2, but
in fact it includes expr1 as well. So the failure of `find' provoked the
evaluation of `break' ~(as a result of goal-directed evaluation) and
therefore the termination of the expression each time a line was read.
I do understand now what's going on, and it does make sense---but it isn't
what I initially expected.
Paul Abrahams
abrahams%wayne-mts@um.cc.umich.edu
From icon-group-request@arizona.edu Wed Jan 16 16:58:06 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA05808; Wed, 16 Jan 91 16:58:06 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Wed, 16 Jan
1991 16:57 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA16146; Wed, 16 Jan 91
15:42:10 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Wed, 16 Jan 1991 16:57 MST
Date: 16 Jan 91 23:14:51 GMT
From: snorkelwacker.mit.edu!bu.edu!rpi!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!midway!quads.uchicago.edu!goer@apple.com
(Richard L. Goerwitz)
Subject: RE: Usage of break
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <DBB58EC5E0801C17@Arizona.edu>
Message-Id: <1991Jan16.231451.7136@midway.uchicago.edu>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: University of Chicago
References: <285847@Wayne-MTS>
In <285847@Wayne-MTS> Paul_Abrahams%Wayne-MTS@UM.CC.UMICH.EDU writes:
>repeat {
> until find("\\syntax", read(infile) | break)
>}
>
>...I couldn't understand why the expression was exiting immediately.
Paul then went on to explain why the expression was exiting immediately.
His point is a good one, and I suspect that if there are new Icon pro-
grammers online reading this, the subtleties might evade easy under-
standing. Let me endeavor to explain what is happening above for any-
one who feels a bit lost.
>repeat {
> until find("\\syntax", read(infile) | break)
>}
What happens here? Well, repeat simply does whatever is in the curly
braces over and over again until a break, return, stop(), or exit() is
executed. What is in the curly braces? An "until" control structure.
What does the until do? It executes its argument repeatedly until it
succeeds. What is its argument? It is a find function. What does find
do? It looks for a string in another string. If it fails, its argu-
ments are resumed, until they are exhausted, at which point the entire
function fails, and the until re-executes it once again in an attempt
to get a result.
The trouble here is with the arguments of find. Find will look for
"\\syntax" in the string produced by read(infile). The function read()
is not a generator, so if the find fails, and read(infile) is resumed,
it cannot produce any more results. It therefore fails. In this case
though, read(infile) is not alone. It is part of an expression con-
taining a vertical slash (|). The expression
a | b
is a generator, which produces all results of expression a, followed by
those of expression b. In the above case,
read(infile) | break
is resumed by find() when find fails to "find" the string "\\syntax" in
the string produced by read(infile). The
expression read(infile) | break, when resumed, first tries to get another
result out of read(infile) but can't. Having exhausted this expression
(expression a), it then tries expression b (the break). The break then
exits the containing loop (repeat).
Note that the argument to until is not considered to be within the until
control loop. This was Paul's (important) point. If the code had run:
until find("\\syntax", \line) do {
line := read(intext) | break
}
THEN the break would have terminated the until loop.
If until didn't work this way, things would be quite confusing. The
"a" in "until a do b" is really an exit condition for the loop con-
sisting of expression b. It is not so much part of the loop as it is
a specification for how the loop is to be executed. A break there is
redundant because the success of "a" itself causes termination of the
loop.
Incidentally, the best way to read lines up to the first one containing
"\\syntax" is to let Icon's resumptive mechanisms do most of the work.
Try:
find("\\syntax", !intext)
Find will keep failing, and keep on resuming its arguments, and then
keep on getting new lines from !intext until one of those lines has a
"\\syntax" in it. If you need to store results, then the idea of a
control loop was perfect -
every line := !&input do {
find("\\syntax", line) & break
etc...
}
(whatever).
I hope that this helps beginners just starting to learn about Icon's
powerful backtracking mechanisms. Many thanks to Paul for pointing
out the difficulty with break and exit conditions.
-Richard (goer@sophist.uchicago.edu)
From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS Wed Jan 16 20:26:08 1991
Received: from umich.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA11467; Wed, 16 Jan 91 20:26:08 -0700
Received: from um.cc.umich.edu by umich.edu (5.61/1123-1.0)
id AA23473; Wed, 16 Jan 91 22:26:04 -0500
Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Wed, 16 Jan 91 22:22:47 EST
Date: Wed, 16 Jan 91 18:18:40 EST
From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
To: icon-group@cs.arizona.edu
Message-Id: <285979@Wayne-MTS>
Subject: Semantics of compound expressions
Is there a full explanation of the semantics of compound expressions
somewhere in the Icon book? It appears that in the expression
{e1; e2; ... ; en}
the result is independent of whether e1 through e(n-1) succeed or fail
(though they are evaluated in bounded context as described on p. 85), and
the result sequence is then that of en. But I can't find any explicit
statement of that. Does such a statement exist?
Paul Abrahams
abrahams%wayne-mts@um.cc.umich.edu
From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS Wed Jan 16 20:26:17 1991
Received: from umich.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA11476; Wed, 16 Jan 91 20:26:17 -0700
Received: from um.cc.umich.edu by umich.edu (5.61/1123-1.0)
id AA23480; Wed, 16 Jan 91 22:26:13 -0500
Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Wed, 16 Jan 91 22:23:09 EST
Date: Wed, 16 Jan 91 18:19:40 EST
From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
To: icon-group@cs.arizona.edu
Message-Id: <285980@Wayne-MTS>
Subject: Overcoming inelegance?
Many times I've encountered the following problem: I have a procedure *p*
that each time it's called writes some material to a file *f*. I want to
pass *f* as a command-line parameter and close *f* when I'm done. There
are two inelegant ways to do this:
(1) Make the file name a global variable; open and close it outside of *p*.
(2) Jigger the parameters passed to *p* so that a special form of argument
indicates file opening or closing rather than data to be written.
Is there an elegant way? (A similar problem exists for input.)
Paul Abrahams
abrahams%wayne-mts@um.cc.umich.edu
From goer%sophist@gargoyle.uchicago.edu Thu Jan 17 10:12:49 1991
Resent-From: goer%sophist@gargoyle.uchicago.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA10652; Thu, 17 Jan 91 10:12:49 -0700
Return-Path: goer@sophist.uchicago.edu
Received: from gargoyle.uchicago.edu by Arizona.edu with PMDF#10282; Thu, 17
Jan 1991 10:11 MST
Received: by gargoyle.uchicago.edu from sophist (sophist.uchicago.edu)
(4.0/1.14) id AA07100; Thu, 17 Jan 91 11:11:49 CST
Received: by sophist (4.1/UofC3.1X) id AA10819; Thu, 17 Jan 91 11:14:34 CST
Resent-Date: Thu, 17 Jan 1991 10:12 MST
Date: Thu, 17 Jan 91 11:14:34 CST
From: Richard Goerwitz <goer%sophist@gargoyle.uchicago.edu>
Subject: generalized io library
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <6C405705D080213A@Arizona.edu>
Message-Id: <9101171714.AA10819@sophist>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Norman Azadian had correctly criticized me privately for not offering
a version of itlib.icn which is common to MS-DOS and UNIX. He has also
offered me a revised version of itlib. I've looked over his revised
version, taken out the portions which seemed to me to be overly spe-
cific to his environment, and come up with a new library.
This file is general enough that I believe, with a little tweaking, it
could be made to work on virtually any system for which a termcap file
can be found. Anyone have a termcap file for VMS? I think the nethack
distribution has one. One for the Amiga as well.
Anyway, here is a preliminary posting. Norman Azadian may well change
some things somewhere down the line.
########################################################################
#
# Name: iolib.icn
#
# Title: Icon termlib-type tools for MS-DOS and UNIX
#
# Author: Richard Goerwitz and Norman Azadian
#
# Version: 1.1
#
#########################################################################
#
# The following library represents a series of rough functional
# equivalents to the standard Unix low-level termcap routines. It is
# not meant as an exact termlib clone. Nor is it enhanced to take
# care of magic cookie terminals, terminals that use \D in their
# termcap entries, or archaic terminals that require padding. These
# routines are geared mainly for use with ANSI and VT-100 devices.
# Note that this file may, in many instances, be used in place of the
# older UNIX-only itlib.icn or DOS-only itlibdos.icn files. The sole
# problems that might be encountered would come with certain archaic
# or arcane UNIX terminals and/or system file arrangements. Note that
# because these routines ignore padding, they can (unlike itlib.icn)
# be run on the NeXT and other systems which fail to implement the -g
# option of the stty command.
#
#########################################################################
#
# Contents:
#
# setname(term)
# Use only if you wish to initialize itermlib for a terminal
# other than what your current environment specifies. "Term" is the
# name of the termcap entry to use. Normally this initialization is
# done automatically, and need not concern the user.
#
# getval(id)
# Works something like tgetnum, tgetflag, and tgetstr. In the
# spirit of Icon, all three have been collapsed into one routine.
# Integer valued caps are returned as integers, strings as strings,
# and flags as records (if a flag is set, then type(flag) will return
# "true"). Absence of a given capability is signalled by procedure
# failure.
#
# igoto(cm,destcol,destline) - NB: default 1 offset (*not* zero)!
# Analogous to tgoto. "Cm" is the cursor movement command for
# the current terminal, as obtained via getval("cm"). Igoto()
# returns a string which, when output via iputs, will cause the
# cursor to move to column "destcol" and line "destline." Column and
# line are always calculated using a *one* offset. This is far more
# Iconish than the normal zero offset used by tgoto. If you want to
# go to the first square on your screen, then include in your program
# "iputs(igoto(getval("cm"),1,1))."
#
# iputs(cp,affcnt)
# Equivalent to tputs. "Cp" is a string obtained via getval(),
# or, in the case of "cm," via igoto(getval("cm"),x,y). Affcnt is a
# count of affected lines. It is completely irrelevant for most
# modern terminals, and is supplied here merely for the sake of
# backward compatibility with itlib, a UNIX-only version of these
# routines (one which handles padding on archaic terminals).
#
##########################################################################
#
# Notes for MS-DOS users:
#
# There are two basic reasons for using the I/O routines
# contained in this package. First, by using a set of generalized
# routines, your code will become much more readable. Secondly, by
# using a high level interface, you can avoid the cardinal
# programming error of hard coding things like screen length and
# escape codes into your programs.
#
# To use this collection of programs, you must do two things.
# First, you must add the line "device=ansi.sys" (or the name of some
# other driver, like zansi.sys, nansi.sys, or nnansi.sys [=new
# nansi.sys]) to your config.sys file. Secondly, you must add two
# lines to your autoexec.bat file: 1) "set TERM=ansi-mono" and 2)
# "set TERMCAP=\location\termcap." The purpose of setting the TERM
# variable is to tell this program what driver you are using. If you
# have a color system, you could use "ansi-color" instead of
# "ansi-mono," although for compatibility with a broader range of
# users, it would perhaps be better to stick with mono. The purpose
# of setting TERMCAP is to make it possible to determine where the
# termcap database file is located. The termcap file (which should
# have been packed with this library as termcap.dos) is a short
# database of all the escape sequences used by the various terminal
# drivers. Set TERMCAP so that it reflects the location of this file
# (which should be renamed as termcap, for the sake of consistency
# across UNIX and MS-DOS spectra). If desired, you can also try
# using termcap2.dos. Certain games work a lot better using this
# alternate file. To try it out, rename it to termcap, and set
# the environment variable TERMCAP to its location.
#
# Although the authors make no pretense of providing here a
# complete introduction to the format of the termcap database file,
# it will be useful, we believe, to explain a few basic facts about
# how to use this program in conjunction with it. If, say, you want
# to clear the screen, add the line,
#
# iputs(getval("cl"))
#
# to your program. The function iputs() outputs screen control
# sequences. Getval retrieves a specific sequence from the termcap
# file. The string "cl" is the symbol used in the termcap file to
# mark the code used to clear the screen. By executing the
# expression "iputs(getval("cl"))," you are 1) looking up the "cl"
# (clear) code in the termcap database entry for your terminal, and
# the 2) outputting that sequence to the screen.
#
# Some other useful termcap symbols are "ce" (clear to end of
# line), "ho" (go to the top left square on the screen), "so" (begin
# standout mode), and "se" (end standout mode). To output a
# boldfaced string, str, to the screen, you would write -
#
# iputs(getval("so"))
# writes(str)
# iputs(getval("se"))
#
# You can also write "writes(getval("so") || str || getval("se")),
# but this would make reimplementation for UNIX terminals that
# require padding rather difficult.
#
# It is also heartily to be recommended that MS-DOS programmers
# try not to assume that everyone will be using a 25-line screen.
# Most terminals are 24-line. Some 43. Some have variable window
# sizes. If you want to put a status line on, say, the 2nd-to-last
# line of the screen, then determine what that line is by executing
# "getval("li")." The termcap database holds not only string-valued
# sequences, but numeric ones as well. The value of "li" tells you
# how many lines the terminal has (compare "co," which will tell you
# how many columns). To go to the beginning of the second-to-last
# line on the screen, type in:
#
# iputs(igoto(getval("cm"), 1, getval("li")-1))
#
# The "cm" capability is a special capability, and needs to be output
# via igoto(cm,x,y), where cm is the sequence telling your computer
# to move the cursor to a specified spot, x is the column, and y is
# the row. The expression "getval("li")-1" will return the number of
# the second-to-last line on your screen.
#
##########################################################################
#
# Requires: UNIX or MS-DOS, co-expressions
#
# See also: itlib.icn, itlibdos.icn, iscreen.icn
#
##########################################################################
global tc_table, isDOS
record true()
procedure check_features()
initial {
if find("UNIX",&features) then
isDOS := &null
else if find("MS-DOS", &features) then
isDOS := 1
else stop("check_features: OS not (yet?) supported.")
find("expressi",&features) |
er("check_features","co-expressions not implemented - &$#!",1)
}
return
end
procedure setname(name)
# Sets current terminal type to "name" and builds a new termcap
# capability database (residing in tc_table). Fails if unable to
# find a termcap entry for terminal type "name." If you want it
# to terminate with an error message under these circumstances,
# comment out "| fail" below, and uncomment the er() line.
#tc_table is global
check_features()
tc_table := table()
tc_table := maketc_table(getentry(name)) | fail
# er("setname","no termcap entry found for "||name,3)
return "successfully reset for terminal " || name
end
procedure getname()
# Getname() first checks to be sure we're running under DOS or
# UNIX, and, if so, tries to figure out what the current terminal
# type is, checking successively the value of the environment
# variable TERM, and then (under UNIX) the output of "tset -".
# Terminates with an error message if the terminal type cannot be
# ascertained. DOS defaults to "mono."
local term, tset_output
check_features()
if \isDOS then {
term := getenv("TERM") | "mono"
}
else {
if not (term := getenv("TERM")) then {
tset_output := open("/bin/tset -","pr") |
er("getname","can't find tset command",1)
term := !tset_output
close(tset_output)
}
}
return \term |
er("getname","can't seem to determine your terminal type",1)
end
procedure er(func,msg,errnum)
# short error processing utility
write(&errout,func,": ",msg)
exit(errnum)
end
procedure getentry(name, termcap_string)
# "Name" designates the current terminal type. Getentry() scans
# the current environment for the variable TERMCAP. If the
# TERMCAP string represents a termcap entry for a terminal of type
# "name," then getentry() returns the TERMCAP string. Otherwise,
# getentry() will check to see if TERMCAP is a file name. If so,
# getentry() will scan that file for an entry corresponding to
# "name." If the TERMCAP string does not designate a filename,
# getentry() will scan the termcap file for the correct entry.
# Whatever the input file, if an entry for terminal "name" is
# found, getentry() returns that entry. Otherwise, getentry()
# fails.
local f, getline, line, nm, ent1, ent2
static slash, dirinits, termcap_name
initial {
if \isDOS then {
slash := "\\"
dirinits := create (tab(any(&letters)), =":") | match(slash)
termcap_name := "termcap"
}
else {
slash := "/"
dirinits := create match(slash)
termcap_name := "/etc/termcap"
}
}
# You can force getentry() to use a specific termcap file by cal-
# ling it with a second argument - the name of the termcap file
# to use instead of the regular one, or the one specified in the
# termcap environment variable.
/termcap_string := getenv("TERMCAP")
dirinits := ^dirinits
if \termcap_string ? (not @dirinits, pos(1) | tab(find("|")+1), =name)
then return termcap_string
else {
# The logic here probably isn't clear. The idea is to try to use
# the termcap environment variable successively as 1) a termcap en-
# try and then 2) as a termcap file. If neither works, 3) go to
# the /etc/termcap file. The else clause here does 2 and, if ne-
# cessary, 3. The "\termcap_string ? (not match..." expression
# handles 1.
if find(slash, \termcap_string)
then f := open(termcap_string)
/f := open(termcap_name) |
er("getentry","I can't access your /etc/termcap file",1)
getline := create read_file(f)
while line := @getline do {
if line ? (pos(1) | tab(find("|")+1), =name, any(':|')) then {
entry := ""
while (\line | @getline) ? {
if entry ||:= 1(tab(find(":")+1), pos(0))
then {
close(f)
# if entry ends in tc= then add in the named tc entry
entry ?:= tab(find("tc=")) ||
# recursively fetch the new termcap entry
(move(3), getentry(tab(find(":"))) ?
# remove the name field from the new entry
(tab(find(":")+1), tab(0)))
return entry
}
else {
\line := &null # must precede the next line
entry ||:= trim(trim(tab(0),'\\'),':')
}
}
}
}
}
close(f)
er("getentry","can't find and/or process your termcap entry",3)
end
procedure read_file(f)
# Suspends all non #-initial lines in the file f.
# Removes leading tabs and spaces from lines before suspending
# them.
local line
\f | er("read_tcap_file","no valid termcap file found",3)
while line := read(f) do {
match("#",line) & next
line ?:= (tab(many('\t ')) | &null, tab(0))
suspend line
}
fail
end
procedure maketc_table(entry)
# Maketc_table(s) (where s is a valid termcap entry for some
# terminal-type): Returns a table in which the keys are termcap
# capability designators, and the values are the entries in
# "entry" for those designators.
local k, v
/entry & er("maketc_table","no entry given",8)
if entry[-1] ~== ":" then entry ||:= ":"
/tc_table := table()
entry ? {
tab(find(":")+1) # tab past initial (name) field
while tab((find(":")+1) \ 1) ? {
&subject == "" & next
if k := 1(move(2), ="=")
then tc_table[k] := Decode(tab(find(":")))
else if k := 1(move(2), ="#")
then tc_table[k] := integer(tab(find(":")))
else if k := 1(tab(find(":")), pos(-1))
then tc_table[k] := true()
else er("maketc_table", "your termcap file has a bad entry",3)
}
}
return tc_table
end
procedure getval(id)
/tc_table := maketc_table(getentry(getname())) |
er("getval","can't make a table for your terminal",4)
return \tc_table[id] | fail
# er("getval","the current terminal doesn't support "||id,7)
end
procedure Decode(s)
# Does things like turn ^ plus a letter into a genuine control
# character.
new_s := ""
s ? {
while new_s ||:= tab(upto('\\^')) do {
chr := move(1)
if chr == "\\" then {
new_s ||:= {
case chr2 := move(1) of {
"\\" : "\\"
"^" : "^"
"E" : "\e"
"b" : "\b"
"f" : "\f"
"n" : "\n"
"r" : "\r"
"t" : "\t"
default : {
if any(&digits,chr2) then {
char(integer("8r"||chr2||move(2 to 0 by -1))) |
er("Decode","bad termcap entry",3)
}
else chr2
}
}
}
}
else new_s ||:= char(ord(map(move(1),&lcase,&ucase)) - 64)
}
new_s ||:= tab(0)
}
return new_s
end
procedure igoto(cm,col,line)
local colline, range, increment, str, outstr, chr, x, y
if col > (tc_table["co"]) | line > (tc_table["li"]) then {
colline := string(\col) || "," || string(\line) | string(\col|line)
range := "(" || tc_table["co"]-1 || "," || tc_table["li"]-1 || ")"
er("igoto",colline || " out of range " || (\range|""),9)
}
# Use the Iconish 1;1 upper left corner & not the C-ish 0 offsets
increment := -1
outstr := ""
cm ? {
while outstr ||:= tab(find("%")) do {
tab(match("%"))
chr := move(1)
if case chr of {
"." : outstr ||:= char(line + increment)
"+" : outstr ||:= char(line + ord(move(1)) + increment)
"d" : {
str := string(line + increment)
outstr ||:= right(str, integer(tab(any('23'))), "0") | str
}
}
then line :=: col
else {
case chr of {
"n" : line := ixor(line,96) & col := ixor(col,96)
"i" : increment := 0
"r" : line :=: col
"%" : outstr ||:= "%"
"B" : line := ior(ishift(line / 10, 4), line % 10)
">" : {
x := move(1); y := move(1)
line > ord(x) & line +:= ord(y)
&null
}
} | er("goto","bad termcap entry",5)
}
}
return outstr || tab(0)
}
end
procedure iputs(cp, affcnt)
# Writes cp to the screen. Use this instead of writes() for
# compatibility with itlib (a UNIX-only version which can handle
# albeit inelegantly) terminals that need padding.
static num_chars
initial num_chars := &digits ++ '.'
type(cp) == "string" |
er("iputs","you can't iputs() a non-string value!",10)
cp ? {
if tab(many(num_chars)) & ="*" then
stop("iputs: iolib can't use terminals that require padding.")
writes(tab(0))
}
return
end
From fps!mis.mcw.edu!mis.mcw.edu!TENAGLIA@uwm.edu Thu Jan 17 10:40:29 1991
Received: from uwm.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA11762; Thu, 17 Jan 91 10:40:29 -0700
Received: by uwm.edu; id AA15663; Thu, 17 Jan 91 11:40:19 -0600
Received: from mis.mcw.edu by fps.mcw.edu (DECUS UUCP ///1.2a/2.5/);
Thu, 17 Jan 91 10:54:55 CDT
Received: by mis.mcw.edu with UUCP/PMDF (DECUS UUCP);
Thu, 17 Jan 1991 10:10 CST
Date: Thu, 17 Jan 1991 10:09 CST
From: Chris Tenaglia - 257-8765 <TENAGLIA@mis.mcw.edu>
Subject: sh.icn : Shell Archive
To: icon-group@cs.arizona.edu
Message-Id: <6BDCE31FC0A0013F@mis.mcw.edu>
X-Organization: Medical College of Wisconsin MIS Department (Milwaukee, WI)
X-Envelope-To: icon-group@cs.arizona.edu
X-Vms-To: IN%"icon-group@cs.arizona.edu"
Here's the icon shell archive utility. It's in shell archive format. I
would like comments and bug reports from unix sites. It tests out fairly
well under DOS and VMS.
Thanx,
Chris Tenaglia (System Manager) | Medical College of Wisconsin
8701 W. Watertown Plank Rd. | Milwaukee, WI 53226
(414)257-8765 | tenaglia@mis.mcw.edu, mcwmis!tenaglia
#!/bin/sh
# This is shar.sh, a shell archive (sh.icn 1.1)
# made Thursday, January 17, 1991 9:55 am by tenaglia@mis.mcw.edu
# Source directory /usr53/tenaglia/i/
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 928 -rw-r--r-- sh.txt
# 7866 -rw-r--r-- sh.icn
#
# This is the icon Shell Archive Utility
# *** The Next Generation ***
# Needs testing on unix systems.
# It seems to work fine on VMS and MS-DOS.
# Interested in your comments and/or bug reports.
# Thank you.
#
# ============== sh.txt ==============
if test X"$1" != X"-c" -a -f 'sh.txt'; then
echo "File already exists: skipping 'sh.txt'"
else
echo "x - extracting sh.txt (Text)"
sed 's/^X//' << 'SHEOF' > sh.txt &&
X
XThis is a shell archive utility for non-unix hosts. It can extract from
Xshell archives (no overwrite checking done). It can list archives. And
Xit can create archives. No actual shell script interpretation is done.
XFor extraction it reads the important stuff and extracts the files. For
Xbuilding, it runs through an interactive dialog.
X
XExamples : sh termlib1.sh Extracts by default
X sh mystuff build Builds mystuff.sh archive
X sh mgale.sh list Lists modules of mgale archive
X
XI've written it primarily for VMS and MS-DOS. I haven't tested the MS-DOS
Xpart yet. Also since I don't have unix out there, someone out there in
Xunixland can test it to make sure that what it builds is extractable.
X
XYours truly,
X
XChris Tenaglia (System Manager) | Medical College of Wisconsin
X8701 W. Watertown Plank Rd. | Milwaukee, WI 53226
X(414)257-8765 | tenaglia@mis.mcw.edu, mcwmis!tenaglia
X
SHEOF
true || echo "Restore of sh.txt failed."
set `wc -c sh.txt`;Wc_c=$1
if test "$Wc_c" != "928"; then
echo original size 928, current size $Wc_c
fi
fi
# ============== sh.icn ==============
if test X"$1" != X"-c" -a -f 'sh.icn'; then
echo "File already exists: skipping 'sh.icn'"
else
echo "x - extracting sh.icn (Text)"
sed 's/^X//' << 'SHEOF' > sh.icn &&
X##################################################################
X# #
X# SH.ICN V1.1 01/14/91 BY TENAGLIA #
X# #
X# PROGRAM HANDLES UNIX SHELL ARCHIVES #
X# USAGE : sh archive [action] [target] #
X# Where action is extract(default) list or build #
X# If action is list, target is ignored. #
X# If action is extract (""), target is ignored #
X# If action id build, target is filespec to archive #
X# NOTE : Does not make split archives yet. #
X# NOTE : Extraction doesn't check for overwrite, just does it. #
X# NOTE : shar 3.xx lengths include the leading X, and don't #
X# match here. This uses their real lengths. #
X# #
X##################################################################
Xglobal os, files
Xprocedure main(param)
X source := param[1] | input("_Source:")
X option := param[2] | "extract"
X target := param[3] | "!nill"
X work := case option of
X {
X "list" : " Lister\n"
X "build": " Builder\n"
X default: " Extractor\n"
X }
X write("sh v1.1 : (Icon) Unix Shell Archive",work)
X os := getsys()
X sum := 0
X find(".",source) | (os ~== "VMS") | (source ||:= ".sh")
X if option == "build" then build(source)
X (in := open(source)) | stop(&line," : Can't open ",source)
X while line := read(in) do
X {
X stuff := parse(line,'\"\'\t ')
X if stuff[1] == "sed" & stuff[2] == "s/^X//" then
X {
X every i := 1 to *stuff do
X {
X if stuff[i] == "<<" then { eof := stuff[i+1] ; next }
X if match("<<",stuff[i]) then { eof := stuff[i][3:0] ; next }
X if stuff[i] == ">>" then
X {
X name := stuff[i+1]
X method := "a" # append
X what := "appended."
X next
X }
X if match(">>",stuff[i]) then
X {
X name := stuff[i][2:0]
X method := "a" # append
X what := "appended."
X next
X }
X if stuff[i] == ">" then
X {
X name := stuff[i+1]
X method := "w" # create
X what := "written."
X next
X }
X if match(">",stuff[i]) then
X {
X name := stuff[i][2:0]
X method := "w" # create
X what := "written."
X next
X }
X }
X prog := extract(in,eof)
X } else next
X directory := if target == "!nill" then "" else target
X (option == "list") |
X (out := open(directory||name,method)) |
X stop(&line," : Can't write ",name)
X every stmt := !prog do
X {
X if option == "extract" then write(out,stmt)
X sum +:= *stmt
X }
X if option == "extract"
X then write(name," : ",sum," bytes ",what)
X else write(name," : contains ",sum," bytes.")
X sum := 0
X (option == "list") | close(out)
X }
X close(in)
X end
X
X#
X# This routine extracts the shell archive for a module. It returns
X# the module in a list structure.
X#
Xprocedure extract(file,eofstr)
X lst := []
X until match(eofstr,(str := read(file))) do
X put(lst,str[2:0])
X return lst
X end
X
X#
X# This routine builds a shell archive. archive is the archive to be made.
X# The rest of this is interactive.
X#
Xprocedure build(archive)
X username := input("Username :")
X directory := input("Directory :")
X if (os=="MS-DOS") then
X (directory[-1] == "\\") | (directory ||:= "\\")
X modules := table([])
X find(".",archive) | (archive ||:= ".sh")
X (output := open(archive,"w")) | stop(&line," : Can't write to ",archive)
X comments := ["#"] ; write("Enter Comments (blank line when done)")
X repeat {
X comment := input("Comment :")
X if trim(comment) == "" then break
X put(comments,"# " || comment) }
X put(comments,"#")
X begin := list()
X put(begin,"#!/bin/sh")
X put(begin,"# This is " || archive || ", a shell archive (sh.icn 1.1)")
X put(begin,"# made " || &dateline || " by " || username)
X put(begin,"# Source directory " || fsmap(directory))
X put(begin,"#", "# existing files will Not be overwritten, hopefully","#")
X put(begin,"# This shar contains:")
X put(begin,"# length mode name")
X put(begin,"# ------ ---------- ------------------------------------------")
X namelist := []
X repeat {
X name := input("File (blank when done) :")
X if trim(name) == "" then break
X (infile := open(directory||name)) | { write("Can't open ",directory,name) ; next }
X code := [ "# ============== " || name || " ==============",
X "if test X\"$1\" != X\"-c\" -a -f '" || name || "'; then",
X " echo \"File already exists: skipping '" || name || "'\"",
X "else",
X "echo \"x - extracting " || name || " (Text)\"",
X "sed 's/^X//' << 'SHEOF' > " || name || " &&" ]
X measure := 0
X while text := read(infile) do
X {
X measure +:= *text
X put(code,"X" || text)
X }
X put(code,"SHEOF")
X put(code,"true || echo \"Restore of " || name || " failed.\"")
X put(code,"set `wc -c " || name || "`;Wc_c=$1")
X put(code,"if test \"$Wc_c\" != \"" || measure || "\"; then")
X put(code," echo original size " || measure || ", current size $Wc_c")
X put(code,"fi")
X put(code,"fi")
X close(infile)
X put(begin,"# " || right(measure,6) || " -rw-r--r-- " || name)
X insert(modules,name,copy(code)) ; put(namelist,name) }
X output := open(archive,"a")
X every write(output,!begin)
X every write(output,!comments)
X every file := !namelist do every write(output,!(modules[file]))
X write(output,"#")
X write(output,"# End of sh archive.")
X close(output)
X stop("sh archive written to ",archive)
X end
X
X#
X# This routine parses a string with respect to some delimiter.
X# It returns the tokens in a list structure.
X#
Xprocedure parse(line,delims)
X static chars
X chars := &cset -- delims
X tokens := []
X line ? while tab(upto(chars)) do put(tokens,tab(many(chars)))
X return tokens
X end
X
X#
X# This routine prompts for a string input. The entered string is returned.
X#
Xprocedure input(prompt)
X writes(prompt)
X return read()
X end
X
X#
X# This procedure determines the os by examining &features.
X#
Xprocedure getsys()
X files := "DIR " # most logical initially
X if &host == "MS-DOS" then
X return &host
X tmp := []
X every feature := &features do
X put(tmp,feature)
X if tmp[1] ~== "VMS" then files := "ls "
X return tmp[1]
X end
X
X#
X# This routine maps the directory spec to unix style notation
X#
Xprocedure fsmap(spec)
X if spec == "" then return spec
X case os of
X {
X "VMS" : { if (i := find(":",spec)) then
X {
X path := "/usr" || ord(spec[i-1]) || "/"
X if (x := find("[",spec)) then
X {
X y := find("]",spec)
X path ||:= map(spec[x+1:y],".","/") || "/"
X } else path ||:= spec[i+1:0] || "/"
X } else {
X if (x := find("[",spec)) then
X {
X y := find("]",spec)
X path := map(spec[x+1:y],".","/") || "/"
X } else path ||:= spec || "/"
X }
X return path
X }
X "MS-DOS" : { if find(":",spec) then
X {
X path := "/usr" || ord(map(spec[1])) - 96 ||
X (map(spec[3:0],"\\","/") | "")
X } else {
X path := map(spec,"\\","/")
X }
X (path[-1] == "/") | (path ||:= "/")
X return path || " (MS-DOS " || spec || ")"
X }
X default : { return spec }
X }
X end
X
SHEOF
true || echo "Restore of sh.icn failed."
set `wc -c sh.icn`;Wc_c=$1
if test "$Wc_c" != "7866"; then
echo original size 7866, current size $Wc_c
fi
fi
#
# End of sh archive.
From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS Thu Jan 17 14:25:41 1991
Received: from umich.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA21736; Thu, 17 Jan 91 14:25:41 -0700
Received: from um.cc.umich.edu by umich.edu (5.61/1123-1.0)
id AA07748; Thu, 17 Jan 91 16:25:36 -0500
Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Thu, 17 Jan 91 16:15:09 EST
Date: Thu, 17 Jan 91 16:09:48 EST
From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
To: icon-group@cs.arizona.edu
Message-Id: <286296@Wayne-MTS>
Subject: Ignoring failure
One way to evaluate an expression e solely for its side effects, ignoring
whether or not it fails, is to write:
{e;}
Does anyone know of a better (more elegant or even shorter) way?
Paul Abrahams
abrahams%wayne-mts@um.cc.umich.edu
From ralph Thu Jan 17 14:43:18 1991
Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA22699; Thu, 17 Jan 91 14:43:18 -0700
Date: Thu, 17 Jan 91 14:43:13 MST
From: "Ralph Griswold" <ralph>
Message-Id: <9101172143.AA16309@cheltenham.cs.arizona.edu>
Received: by cheltenham.cs.arizona.edu; Thu, 17 Jan 91 14:43:13 MST
To: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
Subject: Re: Ignoring failure
Cc: icon-group
You get the effect of {e;} by putting just e on a separate line, provided
it's not inside another expression. There are lots of ways to get the
effect if e is inside another expression, such as (e | &null). I think
that's clearer than {e;}.
From cjeffery Thu Jan 17 17:08:51 1991
Resent-From: "Clinton Jeffery" <cjeffery>
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA00611; Thu, 17 Jan 91 17:08:51 -0700
Received: from megaron.cs.Arizona.EDU by Arizona.edu with PMDF#10282; Thu, 17
Jan 1991 17:08 MST
Received: from caslon.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via
SMTP id AA00595; Thu, 17 Jan 91 17:08:07 -0700
Received: by caslon.cs.arizona.edu; Thu, 17 Jan 91 17:08:06 -0700
Resent-Date: Thu, 17 Jan 1991 17:08 MST
Date: Thu, 17 Jan 91 17:08:06 -0700
From: Clinton Jeffery <cjeffery@cs.arizona.edu>
Subject: gripe
In-Reply-To: Norman Azadian's message of 14 Jan 91 19:16:50 GMT
<1724@hslrswi.hasler.ascom.ch>
Resent-To: icon-group@cs.arizona.edu
To: mcsun!cernvax!chx400!hslrswi!naz@uunet.uu.net
Cc: icon-group@arizona.edu
Resent-Message-Id: <A660E4DE00802514@Arizona.edu>
Message-Id: <9101180008.AA21515@caslon.cs.arizona.edu>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: mcsun!cernvax!chx400!hslrswi!naz@uunet.uu.net
X-Vms-Cc: icon-group@Arizona.edu
The question of modules and Icon's single global name space is discussed
about once every six months or so. I can't speak for Icon's designers,
but the module deficiency is no longer relevant to me because of two
factors:
(a) Icon programs tend to be way shorter than other language's programs.
Short programs are not the problem.
(b) For larger Icon programs I use Idol, the object-oriented Icon
preprocessor. Idol classes can vastly reduce the problem of the
global name space, especially the problem of having procedures
with the same name in different libraries.
Sorry, I couldn't resist the chance to advertise.
Clint
From nowlin@iwtqg.att.com Fri Jan 18 08:44:17 1991
Message-Id: <9101181544.AA01662@megaron.cs.arizona.edu>
Received: from att.att.com by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA01662; Fri, 18 Jan 91 08:44:17 -0700
From: nowlin@iwtqg.att.com
Date: Fri, 18 Jan 91 07:42 CST
Original-From: iwtqg!nowlin (Jerry D Nowlin +1 312 979 7268)
To: icon-group@cs.arizona.edu
Subject: Re: overcoming inelegance
> Subject: Overcoming inelegance?
>
> Many times I've encountered the following problem: I have a procedure *p*
> that each time it's called writes some material to a file *f*. I want to
> pass *f* as a command-line parameter and close *f* when I'm done. There
> are two inelegant ways to do this:
>
> (1) Make the file name a global variable; open and close it outside of *p*.
>
> (2) Jigger the parameters passed to *p* so that a special form of argument
> indicates file opening or closing rather than data to be written.
>
> Is there an elegant way? (A similar problem exists for input.)
>
> Paul Abrahams
> abrahams%wayne-mts@um.cc.umich.edu
A compromise to the global variable is to pass an opened file pointer into
the procedure p(). Just open the file outside the procedure and close it
after the last time the procedure is called. The ability to have the
entire open(), write(), close() suite of calls contained in the procedure
is tricky. The procedure then has to know the file name somehow.
The real problem I see with the self-contained approach is the same one
that was batted around when the discussion of a "final" clause was going
on. How do you know when it's the last time you're calling a procedure?
In this special case you should be able to rely on the language itself or
the underlying operating system to flush all buffers and close all opened
files as a program terminates. Then you only need to worry about opening
the file. Is the following the kind of idea you had? The comment explains
the concept:
procedure main(args)
p("first output")
every f := !args do every p(1 to 10,f)
p("last output")
end
# This procedure writes the data 'd' to an output stream. 'f' is optional
# but if passed it's assumed to be a file name and is checked against the
# currently open file. If they're the same continue writing to the open
# file. If they're different close the current file and open the new one.
# If no file is ever passed all writing is to standard output. NOTE: It is
# assumed that the system itself will flush and close the final file opened.
procedure p(d,f)
static o
initial o := &null
if \f & not (image(o) ? (="file(" & f == tab(upto(')')))) then {
if image(o) ? ="file(" then close(o)
o := open(f,"w") | stop("can't open: ",f)
}
write(o,d)
return
end
Realize, I don't like the idea of relying on the system to close files for
me. That's sloppy not elegant. Maybe someone will come up with a better
idea.
Jerry Nowlin
att!iwtqg!nowlin
From R.J.Hare@edinburgh.ac.uk Fri Jan 18 09:29:27 1991
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA03452; Fri, 18 Jan 91 09:29:27 -0700
Received: from UKACRL.BITNET (MAILER@UKACRL) by Arizona.edu with PMDF#10282;
Fri, 18 Jan 1991 09:29 MST
Received: from RL.IB by UKACRL.BITNET (Mailer R2.07) with BSMTP id 9190; Fri,
18 Jan 91 15:19:24 GMT
Received: from RL.IB by UK.AC.RL.IB (Mailer R2.07) with BSMTP id 3179; Fri, 18
Jan 91 15:19:24 GMT
Date: 18 Jan 91 15:19:22 gmt
From: R.J.Hare@edinburgh.ac.uk
Subject: non-echoed input
To: icon-group@cs.arizona.edu
Message-Id: <18 Jan 91 15:19:22 gmt 060607@EMAS-A>
X-Envelope-To: icon-group@cs.arizona.edu
Via: UK.AC.ED.EMAS-A; 18 JAN 91 15:19:21 GMT
I am trying to enter a parameter to an Icon program which I don't want echoing
(it's a password). I'm sure I should be able to do this either with getch() or
reads(,1) and then writes(\b*) or something similar, but I can't get it to go.
Has anyone got a solution to this oroblem?
Thanks.
Roger Hare.
PS: I am running on a Unix machine.
From goer%sophist@gargoyle.uchicago.edu Fri Jan 18 09:57:17 1991
Received: from gargoyle.uchicago.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA04415; Fri, 18 Jan 91 09:57:17 -0700
Received: by gargoyle.uchicago.edu from sophist (sophist.uchicago.edu) (4.0/1.14)
id AA11530; Fri, 18 Jan 91 10:57:13 CST
Return-Path: <goer@sophist.uchicago.edu>
Received: by sophist (4.1/UofC3.1X)
id AA11351; Fri, 18 Jan 91 10:59:57 CST
Date: Fri, 18 Jan 91 10:59:57 CST
From: Richard Goerwitz <goer%sophist@gargoyle.uchicago.edu>
Message-Id: <9101181659.AA11351@sophist>
To: R.J.Hare@edinburgh.ac.uk, icon-group@cs.arizona.edu
Subject: Re: non-echoed input
> I am trying to enter a parameter to an Icon program which I don't want echoing
> (it's a password). I'm sure I should be able to do this either with getch() or
> reads(,1) and then writes(\b*) or something similar, but I can't get it to go.
> Has anyone got a solution to this problem?
If you are using Unix, you won't be able to access getch(). It can't be done
portably. You'll have to do a system() of some kind. E.g.:
system("stty -echo")
read(&input)
system("stty echo")
Difficulty: What if, for some reason the system() fails? Oh no! Your
password gets echoed! There's no way to test whether system() forked
a shell, and that shell couldn't execute the command. You can't tell
whether the command worked or not using pipes, for the same reason. All
you get is a diagnostic written to stderr by the shell, I believe. Hmmm.
Maybe you can do this:
instty := open("stty -echo 2>&1","pr")
if ("" ~== !instty) then
stop("Can't seem to reset your tty to no echo mode.")
close(instty)
read(&input)
Then do the same sort of thing to reset to echo mode.
I have an implementation of getch() for UNIX around, but it's not per-
fect. And it suffers from the same problem as above.
Anyone have any bright ideas, short of hacking a stub that will do an
extcall to stty, and then recompiling an idiosyncratic interpreter?
-Richard
From nowlin@iwtqg.att.com Fri Jan 18 12:36:41 1991
Message-Id: <9101181936.AA10542@megaron.cs.arizona.edu>
Received: from att.att.com by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA10542; Fri, 18 Jan 91 12:36:41 -0700
From: nowlin@iwtqg.att.com
Date: Fri, 18 Jan 91 12:59 CST
Original-From: iwtqg!nowlin (Jerry D Nowlin +1 312 979 7268)
To: icon-group@cs.arizona.edu
Subject: Re non-echoed input
> > I am trying to enter a parameter to an Icon program which I don't want
> > echoing (it's a password). I'm sure I should be able to do this either
> > with getch() or reads(,1) and then writes(\b*) or something similar, but
> > I can't get it to go. Has anyone got a solution to this problem?
>
> If you are using Unix, you won't be able to access getch(). It can't be
> done portably. You'll have to do a system() of some kind. E.g.:
>
> system("stty -echo")
> read(&input)
> system("stty echo")
>
> Difficulty: What if, for some reason the system() fails? Oh no! Your
> password gets echoed! There's no way to test whether system() forked a
> shell, and that shell couldn't execute the command. You can't tell whether
> the command worked or not using pipes, for the same reason. All you get is
> a diagnostic written to stderr by the shell, I believe. Hmmm.
This seems like the best way for now to turn off the echoing of typed
input.
I've been using the return code from system() calls on UNIX for some time
and they always seem to return the exit code of the command spawned with
them. The Icon book (2nd edition) says they do. If you use the open(,"p")
call in UNIX the exit code of the command piped is returned from the
close() call of the file pointer returned by the open. That seems to work
just fine too. You have to look at the iconx source to see that that's
what's happening though. I couldn't find a reference to it in the book.
Jerry Nowlin
att!iwtqg!nowlin
From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS Fri Jan 18 14:13:22 1991
Received: from umich.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA14348; Fri, 18 Jan 91 14:13:22 -0700
Received: from um.cc.umich.edu by umich.edu (5.61/1123-1.0)
id AA04712; Fri, 18 Jan 91 16:13:16 -0500
Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Fri, 18 Jan 91 16:09:04 EST
Date: Fri, 18 Jan 91 16:01:26 EST
From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
To: icon-group@cs.arizona.edu
Message-Id: <286624@Wayne-MTS>
Subject: Ignoring failure
Ralph has suggested some other ways of ignoring failure than {e;}. The
specific context I was interested in is (...,e,...) where the sequential
expression is part of a pattern match. In this case putting e on a
separate line won't work. But perhaps, in the spirit of Ralph's
suggestion, a good solution is to write (...,e|0,...), which takes two
characters rather than the three required by the solution I proposed. But
of course e|0 doesn't work if there are other operators in the vicinity.
Paul Abrahams
From goer%sophist@gargoyle.uchicago.edu Fri Jan 18 14:43:16 1991
Resent-From: goer%sophist@gargoyle.uchicago.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA15416; Fri, 18 Jan 91 14:43:16 -0700
Return-Path: goer@sophist.uchicago.edu
Received: from gargoyle.uchicago.edu by Arizona.edu with PMDF#10282; Fri, 18
Jan 1991 14:42 MST
Received: by gargoyle.uchicago.edu from sophist (sophist.uchicago.edu)
(4.0/1.14) id AA19303; Fri, 18 Jan 91 15:41:53 CST
Received: by sophist (4.1/UofC3.1X) id AA11619; Fri, 18 Jan 91 15:44:37 CST
Resent-Date: Fri, 18 Jan 1991 14:42 MST
Date: Fri, 18 Jan 91 15:44:37 CST
From: Richard Goerwitz <goer%sophist@gargoyle.uchicago.edu>
Subject: RE: Re non-echoed input
Resent-To: icon-group@cs.arizona.edu
To: nowlin@iwtqg.att.com
Cc: icon-group@arizona.edu
Resent-Message-Id: <5B3082624080292A@Arizona.edu>
Message-Id: <9101182144.AA11619@sophist>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: nowlin@iwtqg.att.com
X-Vms-Cc: icon-group@Arizona.edu
>> system("stty -echo")
>> read(&input)
>> system("stty echo")
>>
>> Difficulty: What if, for some reason the system() fails? Oh no! Your
>> password gets echoed! There's no way to test whether system() forked a
>> shell, and that shell couldn't execute the command. You can't tell whether
>> the command worked or not using pipes, for the same reason.
> I've been using the return code from system() calls on UNIX for some time
> and they always seem to return the exit code of the command spawned with
> them. The Icon book (2nd edition) says they do.
I looked at the first ed., and it does, too. I remember writing
system("something") | fail
a long time ago, and finding out that it didn't work. It never occurred
to me to do something that I saw as very un-Iconish: Test for an exit
status.
I suppose, though, that if we are going to interface on this level with
the operating system, it makes sense to do it on the operating system's
terms, especially when important information might be lost.
Just the other day, Ralph Griswold pointed out to me that &subject is
never null. It's always at least going to dereference to an empty
string. Funny, but I'd never had any reason since starting to program
in Icon to question my (mis)conception that, outside of a scanning
expression, type(&subject) yielded "null." The bit on system() was
of the same order.
Oh well.
-Richard
From goer%sophist@gargoyle.uchicago.edu Fri Jan 18 14:57:31 1991
Resent-From: goer%sophist@gargoyle.uchicago.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA16131; Fri, 18 Jan 91 14:57:31 -0700
Return-Path: goer@sophist.uchicago.edu
Received: from gargoyle.uchicago.edu by Arizona.edu with PMDF#10282; Fri, 18
Jan 1991 14:56 MST
Received: by gargoyle.uchicago.edu from sophist (sophist.uchicago.edu)
(4.0/1.14) id AA19923; Fri, 18 Jan 91 15:56:53 CST
Received: by sophist (4.1/UofC3.1X) id AA11629; Fri, 18 Jan 91 15:59:37 CST
Resent-Date: Fri, 18 Jan 1991 14:57 MST
Date: Fri, 18 Jan 91 15:59:37 CST
From: Richard Goerwitz <goer%sophist@gargoyle.uchicago.edu>
Subject: Ignoring failure (idiomatic Icon)
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <5D33944B4080233D@Arizona.edu>
Message-Id: <9101182159.AA11629@sophist>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
> Ralph has suggested some other ways of ignoring failure than {e;}. The
> specific context I was interested in is (...,e,...) where the sequential
> expression is part of a pattern match. In this case putting e on a
> separate line won't work. But perhaps, in the spirit of Ralph's
> suggestion, a good solution is to write (...,e|0,...), which takes two
> characters rather than the three required by the solution I proposed. But
> of course e|0 doesn't work if there are other operators in the vicinity.
It's just personal opinion, but I find
tab(find(this)+that) &
=something_else | &null &
do-some-other-things
a lot clearer than
(tab(find(this)+that), =something_else | 0, do-some-other-things)
It looks like you need to use the zero for something other than to pro-
vide a dummy result. From an Iconish standpoint, the zero looks a lot
more "interesting" than &null.
Of course, if you are planning on using matched substrings, you'll have
to use the empty string:
tab(find(this)+that) ||
(=something_else | "") ||
do-some-other-things
-Richard
From ralph Fri Jan 18 15:13:12 1991
Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA16939; Fri, 18 Jan 91 15:13:12 -0700
Date: Fri, 18 Jan 91 15:13:08 MST
From: "Ralph Griswold" <ralph>
Message-Id: <9101182213.AA16103@cheltenham.cs.arizona.edu>
Received: by cheltenham.cs.arizona.edu; Fri, 18 Jan 91 15:13:08 MST
To: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
Subject: Re: Ignoring failure
Cc: icon-group
If you're seeking elegance, I'd argue against (e | 0), since it looks
like the zero is meaningful, while &null is less likely to be
interpreted that way. Of course, if you're just concerned about
keystrokes, your method is briefer.
Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
+1 602 621 6609 ralph@cs.arizona.edu uunet!arizona!ralph
From ralph Fri Jan 18 15:33:55 1991
Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA17772; Fri, 18 Jan 91 15:33:55 -0700
Date: Fri, 18 Jan 91 15:33:54 MST
From: "Ralph Griswold" <ralph>
Message-Id: <9101182233.AA16796@cheltenham.cs.arizona.edu>
Received: by cheltenham.cs.arizona.edu; Fri, 18 Jan 91 15:33:54 MST
To: icon-group
Subject: system()
I suspect the intention of the earlier comment "What if ... system() fails"
didn't mean failure in the Icon sense, but that the specified action
didn't take place.
The reason that system() in Icon returns the exit code of the process
is that there are many possible values, not just "error exit" and
"normal exit". Some programs terminate with a variety of different
error codes to signal different situations. Icon has to have a way
to capture this.
I suppose system() could fail on "error exit" and return a value on
other exits, but since it just reflects a capability of the C
runtime library in Icon, it seems unnecessarily confusing to have
it behave in a different way, since no real functionality would be
gained.
Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
+1 602 621 6609 ralph@cs.arizona.edu uunet!arizona!ralph
From icon-group-request@arizona.edu Fri Jan 18 18:44:56 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA24178; Fri, 18 Jan 91 18:44:56 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Fri, 18 Jan
1991 18:44 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA24738; Fri, 18 Jan 91
17:39:15 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Fri, 18 Jan 1991 18:44 MST
Date: 18 Jan 91 23:47:53 GMT
From: midway!quads.uchicago.edu!goer@handies.ucar.edu (Richard L. Goerwitz)
Subject: blackjack
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <7CF50958A0802917@Arizona.edu>
Message-Id: <1991Jan18.234753.13506@midway.uchicago.edu>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: University of Chicago
I posted a Unix port of Chris Tenaglia's bj game some time ago.
My son has found several bugs in it since then. If any Unixoids
want an update, please drop me a line. I'll be glad to mail them
out.
-Richard (goer@sophist.uchicago.edu)
From goer%sophist@gargoyle.uchicago.edu Fri Jan 18 23:14:14 1991
Resent-From: goer%sophist@gargoyle.uchicago.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA01446; Fri, 18 Jan 91 23:14:14 -0700
Return-Path: goer@sophist.uchicago.edu
Received: from gargoyle.uchicago.edu by Arizona.edu with PMDF#10282; Fri, 18
Jan 1991 23:13 MST
Received: by gargoyle.uchicago.edu from sophist (sophist.uchicago.edu)
(4.0/1.14) id AA01710; Sat, 19 Jan 91 00:13:35 CST
Received: by sophist (4.1/UofC3.1X) id AA11802; Sat, 19 Jan 91 00:16:19 CST
Resent-Date: Fri, 18 Jan 1991 23:14 MST
Date: Sat, 19 Jan 91 00:16:19 CST
From: Richard Goerwitz <goer%sophist@gargoyle.uchicago.edu>
Subject: DOS->Unix/Unix->DOS
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <A2984956D0802F8B@Arizona.edu>
Message-Id: <9101190616.AA11802@sophist>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Here's a set of short UNIX->DOS and DOS->UNIX text file translators.
They are pretty fresh, and I wouldn't mind hearing suggestions from
anyone who happens to try them out.
Now that you all have Chris Tenaglia's shell archiver, I don't have
to worry that people won't be able to unpack this.
-Richard (goer@sophist.uchicago.edu)
---- Cut Here and feed the following to sh ----
#!/bin/sh
# This is a shell archive (produced by shar 3.49)
# To extract the files from this archive, save it to a file, remove
# everything above the "!/bin/sh" line above, and type "sh file_name".
#
# made 01/19/1991 06:02 UTC by goer@sophist.uchicago.edu
# Source directory /u/richard/Nocr
#
# existing files will NOT be overwritten unless -c is specified
# This format requires very little intelligence at unshar time.
# "if test", "cat", "rm", "echo", "true", and "sed" may be needed.
#
#
#
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 3401 -r--r--r-- yescr.icn
# 3177 -r--r--r-- nocr.icn
# 1024 -rw-r--r-- README
# 728 -rw-r--r-- Makefile.dist
#
if test -r _shar_seq_.tmp; then
echo 'Must unpack archives in sequence!'
echo Please unpack part `cat _shar_seq_.tmp` next
exit 1
fi
# ============= yescr.icn ==============
if test -f 'yescr.icn' -a X"$1" != X"-c"; then
echo 'x - skipping yescr.icn (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting yescr.icn (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'yescr.icn' &&
X############################################################################
X#
X# Name: yescr.icn
X#
X# Title: yescr (convert UNIX text files to DOS format)
X#
X# Author: Richard L. Goerwitz
X#
X# Version: 1.2
X#
X############################################################################
X#
X# usage: yescr file1 [file2 [etc.]]
X#
X# PURPOSE: Yescr simply inserts MS-DOS carriage-return+linefeed
X# sequences in place of UNIX newlines. Effects conversion from the
X# native UNIX text file format to its DOS correspondent.
X#
X# BUGS: Doesn't check to see whether the input files are in fact
X# text files.
X#
X############################################################################
X#
X# Links: none
X#
X# Requires: UNIX or MS-DOS
X#
X# See also: nocr.icn
X#
X############################################################################
X
X
Xprocedure main(a)
X
X local fname, infile, outfile, line
X
X # Static variables, initial clause not really necessary in main().
X static slash, l, ms, DOSos, nok, ok
X initial {
X nok := string(~&letters)
X ok := repl("X",*nok)
X # Find us a place to put temporary files.
X if find("UNIX",&features) then {
X slash := "/"
X l := 10
X ms := ""
X }
X else if find("MS-DOS", &features) then {
X slash := "\\"
X l := 8
X ms := "u"
X DOSos := 1
X }
X # Don't take this out unless you're sure of what you're doing.
X else stop("yescr: tested only under UNIX and MS-DOS")
X }
X
X # Check to see if we have any arguments.
X *a = 0 & stop("usage: yescr file1 [file2...]")
X
X # Start popping filenames off of the argument list.
X while fname := pop(a) do {
X
X # Open input file.
X infile := open(fname,"r"||ms) | (er_out(fname), next)
X # Get temporary file name.
X every temp_name :=
X pathname(fname, slash) ||
X map(left(basename(fname,slash),l,"X"), nok, ok) ||
X "." || right(0 to 999,3,"0")
X do close(open(temp_name)) | break
X # Open temporary file.
X outfile := open(temp_name,"w"||ms) | (er_out(temp_name), next)
X
X if \DOSos then {
X # Read in blocks of 80 chars.
X while line := reads(infile,80) do {
X line ? {
X # Replace ASCII LF with CR+LF, effecting a translation
X # from UNIX to DOS format.
X while writes(outfile, tab(find("\x0A")), "\x0D", move(1))
X writes(outfile, tab(0))
X }
X }
X }
X else {
X # I presume I'm running under UNIX (unless I've been hacked).
X # Convert lines into DOS format by appending a carriage return,
X # and then write()'ing (which automatically adds a newline).
X every line := !infile do {
X if line[-1] == "\x0D"
X then write(outfile, line)
X else write(outfile, line || "\x0D")
X }
X }
X
X # Close opened input and output files.
X close(infile) | stop("yescr: cannot close, ",fname,"; aborting")
X close(outfile) | stop("yescr: cannot close, ",temp_name,"; aborting")
X
X # Remove physical input file.
X remove(fname) | stop("yescr: cannot remove ",fname,"; aborting")
X
X # Give temp name the same name as the input file, completing the
X # conversion process.
X rename(temp_name,fname) |
X stop("yescr: Can't find temp file ",temp_name,"; aborting")
X }
X
Xend
X
X
Xprocedure er_out(s)
X write(&errout,"yescr: cannot open ",s," for reading")
X return
Xend
X
X
Xprocedure basename(s,slash)
X s ? {
X while tab(find(slash)+1)
X return tab(0)
X }
Xend
X
X
Xprocedure pathname(s,slash)
X s2 := ""
X s ? {
X while s2 ||:= tab(find(slash)+1)
X return s2
X }
Xend
SHAR_EOF
true || echo 'restore of yescr.icn failed'
rm -f _shar_wnt_.tmp
fi
# ============= nocr.icn ==============
if test -f 'nocr.icn' -a X"$1" != X"-c"; then
echo 'x - skipping nocr.icn (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting nocr.icn (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'nocr.icn' &&
X############################################################################
X#
X# Name: nocr.icn
X#
X# Title: nocr (convert MS-DOS text files to UNIX format)
X#
X# Author: Richard L. Goerwitz
X#
X# Version: 1.2
X#
X############################################################################
X#
X# usage: nocr file1 [file2 [etc.]]
X#
X# PURPOSE: Nocr simply converts \r\n to \n in each line of each of the
X# files supplied as command-line arguments, thereby effecting conversion
X# of MS-DOS format text files to the corresponding UNIX format.
X#
X# BUGS: No check done to see whether the file is in fact a text file.
X#
X############################################################################
X#
X# Links: none
X#
X# Requires: UNIX or MS-DOS
X#
X# See also: yescr.icn
X#
X############################################################################
X
X
Xprocedure main(a)
X
X local fname, infile, outfile, line
X
X # Static variables, initial clause not really necessary in main().
X static slash, l, ms, DOSos, nok, ok
X initial {
X
X nok := string(~&letters)
X ok := repl("X",*nok)
X
X # Find us a place to put temporary files.
X if find("UNIX",&features) then {
X slash := "/"
X l := 10
X ms := ""
X }
X else if find("MS-DOS", &features) then {
X slash := "\\"
X l := 8
X ms := "u"
X DOSos := 1
X }
X # Don't take this out unless you're sure of what you're doing.
X else stop("nocr: tested only under UNIX and MS-DOS")
X }
X
X # Check to see if we have any arguments.
X *a = 0 & stop("usage: nocr file1 [file2...]")
X
X # Start popping filenames off of the argument list.
X while fname := pop(a) do {
X
X # Open input file.
X infile := open(fname,"r") | (er_out(fname), next)
X # Get temporary file name.
X every temp_name :=
X pathname(fname, slash) ||
X map(left(basename(fname,slash),l,"X"), nok, ok) ||
X "." || right(0 to 999,3,"0")
X do close(open(temp_name)) | break
X # Open temporary file.
X outfile := open(\temp_name,"w"||ms) | (er_out(fname), next)
X
X if \DOSos then {
X # Infile above was opened in translate mode (removing the CR),
X # while outfile was opened in untranslate mode (automatically
X # writing the line in UNIX format).
X while write(outfile,read(infile))
X }
X else {
X # If not running under DOS, then we're under UNIX (unless
X # we've been hacked). Trim CR manually, then write.
X while write(outfile, read(infile) ? tab(-1|0))
X }
X
X # Close opened input and output files.
X close(infile) | stop("nocr: cannot close, ",fname,"; aborting")
X close(outfile) | stop("nocr: cannot close, ",temp_name,"; aborting")
X
X # Remove physical input file.
X remove(fname) | stop("nocr: cannot remove ",fname,"; aborting")
X
X # Give temp name the same name as the input file, completing the
X # conversion process.
X rename(temp_name,fname) |
X stop("nocr: Can't find temp file ",temp_name,"; aborting")
X }
X
Xend
X
X
Xprocedure er_out(s)
X write(&errout,"nocr: cannot open ",s," for reading")
X return
Xend
X
X
Xprocedure basename(s,slash)
X s ? {
X while tab(find(slash)+1)
X return tab(0)
X }
Xend
X
X
Xprocedure pathname(s,slash)
X s2 := ""
X s ? {
X while s2 ||:= tab(find(slash)+1)
X return s2
X }
Xend
SHAR_EOF
true || echo 'restore of nocr.icn failed'
rm -f _shar_wnt_.tmp
fi
# ============= README ==============
if test -f 'README' -a X"$1" != X"-c"; then
echo 'x - skipping README (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting README (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'README' &&
X
XContained in this distribution are two Icon programs, the one (yescr)
Xused to translate UNIX into MS-DOS text-files, the other (nocr) used
Xto perform the opposite conversion.
X
XTo make these programs under UNIX, just type "cp Makefile.dist
XMakefile" and make. If you are satisfied that the programs work fine
Xedit the Makefile, su root, and "make -f Makefile.dist install."
X
XThose without a makefile facility will have to translate manually:
X
X icont yescr.icn
X icont nocr.icn
X
XPlease send me bug reports and modifications. These programs should
Xwork okay under UNIX and DOS. Haven't really tested anything else.
XNote that you must have an Icon interpreter or compiler installed. If
Xyou don't, then I'd suggest ftping the files from cs.arizona.edu. The
Xsource is public domain, and is as bugless and easy to install as any
Xacademic distribution I've ever seen. DOS users need not bother with
Xthe source, as there are optimized and tested executables online.
X
X-Richard Goerwitz (goer@sophist.uchicago.edu)
SHAR_EOF
true || echo 'restore of README failed'
rm -f _shar_wnt_.tmp
fi
# ============= Makefile.dist ==============
if test -f 'Makefile.dist' -a X"$1" != X"-c"; then
echo 'x - skipping Makefile.dist (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting Makefile.dist (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'Makefile.dist' &&
X# Please edit these to reflect your local file structure & conventions.
XDESTDIR = /usr/local/bin
XOWNER = bin
XGROUP = bin
X
X# I hope you won't have to use this.
XDEBUGFLAG = #-t
X
Xall: nocr yescr
X
Xnocr:
X icont $(DEBUGFLAG) nocr.icn
Xyescr:
X icont $(DEBUGFLAG) yescr.icn
X
X# Pessimistic assumptions regarding the environment (in particular,
X# I don't assume you have the BSD "install" shell script).
Xinstall: all
X @sh -c "test -d $(DESTDIR) || (mkdir $(DESTDIR) && chmod 755 $(DESTDIR))"
X cp yescr $(DESTDIR)/
X chgrp $(GROUP) $(DESTDIR)/yescr
X chown $(OWNER) $(DESTDIR)/yescr
X cp nocr $(DESTDIR)/
X chgrp $(GROUP) $(DESTDIR)/nocr
X chown $(OWNER) $(DESTDIR)/nocr
X @echo "\nInstallation done.\n"
X
Xclean:
X -rm -f *.u *~
X -rm -f yescr nocr
SHAR_EOF
true || echo 'restore of Makefile.dist failed'
rm -f _shar_wnt_.tmp
fi
exit 0
From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS Sat Jan 19 10:09:54 1991
Received: from umich.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA19906; Sat, 19 Jan 91 10:09:54 -0700
Received: from um.cc.umich.edu by umich.edu (5.61/1123-1.0)
id AA15526; Sat, 19 Jan 91 12:08:34 -0500
Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Sat, 19 Jan 91 12:03:25 EST
Date: Sat, 19 Jan 91 11:34:02 EST
From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
To: icon-group@cs.arizona.edu
Message-Id: <286791@Wayne-MTS>
Subject: Error in Icon Analyst #4
Icon Analyst 4 (Feb 1991) has an error in the example that runs from the
end of page 3 to the beginning of page 4. In two places, the first
tab(many(&letters)) should be replaced by tab(upto(&letters)) (as it is in
the preceding parts of the example).
Paul Abrahams
From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS Sat Jan 19 10:10:06 1991
Received: from umich.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA19927; Sat, 19 Jan 91 10:10:06 -0700
Received: from um.cc.umich.edu by umich.edu (5.61/1123-1.0)
id AA15551; Sat, 19 Jan 91 12:08:46 -0500
Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Sat, 19 Jan 91 12:03:46 EST
Date: Sat, 19 Jan 91 11:34:52 EST
From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
To: icon-group@cs.arizona.edu
Message-Id: <286792@Wayne-MTS>
Subject: How to write string scanning operations
Version 4 of the Icon Analyst suggests, as an example of good style, the
string scanning expression:
expression ? {
="(" &
tab(bal()) &
=")" &
pos(0)
}
I'd argue for the superiority of:
expression ? (
="(" ,
tab(bal()) ,
=")" ,
pos(0)
)
This version is less vulnerable to confusions about precedence. It also
makes explicit the circumstances under which the match fails, and follows
the general suggestion in the Icon book that (..., ... , ...) should be
used in preference to a long sequence of conjunctions.
Paul Abrahams
From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS Sat Jan 19 10:10:20 1991
Received: from umich.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA19958; Sat, 19 Jan 91 10:10:20 -0700
Received: from um.cc.umich.edu by umich.edu (5.61/1123-1.0)
id AA15558; Sat, 19 Jan 91 12:08:59 -0500
Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Sat, 19 Jan 91 12:04:07 EST
Date: Sat, 19 Jan 91 11:35:46 EST
From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
To: icon-group@cs.arizona.edu
Message-Id: <286793@Wayne-MTS>
Subject: Efficiency of search
I'm sure this has come up a hundred times, but I don't remember the answer.
Assume that c is a single character. Which is more efficient,
find("c",s)
or
upto('c', s) ?
I think they are semantically equivalent.
Paul Abrahams
From @um.cc.umich.edu:Paul_Abrahams@Wayne-MTS Sat Jan 19 10:10:33 1991
Received: from umich.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA19989; Sat, 19 Jan 91 10:10:33 -0700
Received: from um.cc.umich.edu by umich.edu (5.61/1123-1.0)
id AA15563; Sat, 19 Jan 91 12:09:12 -0500
Received: from Wayne-MTS by um.cc.umich.edu via MTS-Net; Sat, 19 Jan 91 12:04:28 EST
Date: Sat, 19 Jan 91 11:36:24 EST
From: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
To: icon-group@cs.arizona.edu
Message-Id: <286794@Wayne-MTS>
Subject: Typesetting Icon
The usual style for typesetting Icon seems to be to use a Helvetica
(sans-serif) font. The problem with such a font is that uppercase I and
lowercase l are indistinguishable. Has anybody thought about that problem
and how to overcome it, e.g., by somehow jiggering the font to put tiny
serifs on the uppercase I? Am I the only one bothered by this ambiguity?
(Consider typesetting the identifier `SmallInteger'.)
This problem arises in typesetting other programming languages also, of
course.
Paul Abrahams
From ralph Sat Jan 19 10:30:56 1991
Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA20549; Sat, 19 Jan 91 10:30:56 -0700
Date: Sat, 19 Jan 91 10:30:53 MST
From: "Ralph Griswold" <ralph>
Message-Id: <9101191730.AA04912@cheltenham.cs.arizona.edu>
Received: by cheltenham.cs.arizona.edu; Sat, 19 Jan 91 10:30:53 MST
To: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
Subject: Re: Efficiency of search
Cc: icon-group
find("c",s) is faster than upto('c',s). The reason is the extra time
needed to set up the character table for upto().
The difference is small, however.
Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
+1 602 621 6609 ralph@cs.arizona.edu uunet!arizona!ralph
From ralph Sat Jan 19 10:35:21 1991
Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA20647; Sat, 19 Jan 91 10:35:21 -0700
Date: Sat, 19 Jan 91 10:35:16 MST
From: "Ralph Griswold" <ralph>
Message-Id: <9101191735.AA05044@cheltenham.cs.arizona.edu>
Received: by cheltenham.cs.arizona.edu; Sat, 19 Jan 91 10:35:16 MST
To: Paul_Abrahams%Wayne-MTS@um.cc.umich.edu
Subject: Re: Typesetting Icon
Cc: icon-group
The style used in typesetting the second edition of the Icon book is
the one specified by the publisher.
We're aware, of course, of the visual ambiguity of "el" and "one". That
ambiguity occurs not just in sans-serif faces; for many line-printer and
screen faces it is easy to confuse the two characters.
We try to avoid program text where this ambiguity is serious.
Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
+1 602 621 6609 ralph@cs.arizona.edu uunet!arizona!ralph
From goer%sophist@gargoyle.uchicago.edu Sun Jan 20 09:01:14 1991
Resent-From: goer%sophist@gargoyle.uchicago.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA24067; Sun, 20 Jan 91 09:01:14 -0700
Return-Path: goer@sophist.uchicago.edu
Received: from gargoyle.uchicago.edu by Arizona.edu with PMDF#10282; Sun, 20
Jan 1991 09:00 MST
Received: by gargoyle.uchicago.edu from sophist (sophist.uchicago.edu)
(4.0/1.14) id AA07213; Sun, 20 Jan 91 10:00:36 CST
Received: by sophist (4.1/UofC3.1X) id AA12219; Sun, 20 Jan 91 10:03:18 CST
Resent-Date: Sun, 20 Jan 1991 09:00 MST
Date: Sun, 20 Jan 91 10:03:18 CST
From: Richard Goerwitz <goer%sophist@gargoyle.uchicago.edu>
Subject: Icon compression
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <BDC156E8F080292C@Arizona.edu>
Message-Id: <9101201603.AA12219@sophist>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Has anyone created any compression routines in Icon? I know of
Robert Alexander's LZW compression utility, but, as he notes, it
contains a lot of tracing and tests, and it much too slow for
practical use. If anyone has written, say, a Huffmon encoding
routine in Icon, I'd love to have it and not have to write it my-
self....
-Richard
From icon-group-request@arizona.edu Sun Jan 20 11:16:58 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA27043; Sun, 20 Jan 91 11:16:58 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Sun, 20 Jan
1991 11:16 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA04469; Sun, 20 Jan 91
10:12:12 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Sun, 20 Jan 1991 11:16 MST
Date: 20 Jan 91 16:26:07 GMT
From: tron!beser@uunet.uu.net (Eric Beser)
Subject: icon program to shorten file names
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <D0B9736E208029BF@Arizona.edu>
Message-Id: <692@tron.UUCP>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: Westinghouse Electronic Systems Group, Baltimore, MD, USA
I read in one of the technical reports that there was a program
written in icon that read a tar file, checked if the names were
longer than 15 characters, if so, shortened them.
Is there such a critter? If so, and someone has it, could they
email it ?
thanks
Eric Beser
Westinghouse Aerospace Software Engineering
From goer%sophist@gargoyle.uchicago.edu Sun Jan 20 15:00:01 1991
Resent-From: goer%sophist@gargoyle.uchicago.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA02569; Sun, 20 Jan 91 15:00:01 -0700
Return-Path: goer@sophist.uchicago.edu
Received: from gargoyle.uchicago.edu by Arizona.edu with PMDF#10282; Sun, 20
Jan 1991 14:59 MST
Received: by gargoyle.uchicago.edu from sophist (sophist.uchicago.edu)
(4.0/1.14) id AA12555; Sun, 20 Jan 91 15:59:25 CST
Received: by sophist (4.1/UofC3.1X) id AA12295; Sun, 20 Jan 91 16:02:08 CST
Resent-Date: Sun, 20 Jan 1991 14:59 MST
Date: Sun, 20 Jan 91 16:02:08 CST
From: Richard Goerwitz <goer%sophist@gargoyle.uchicago.edu>
Subject: shortening long filenames
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <EFE15461A0803144@Arizona.edu>
Message-Id: <9101202202.AA12295@sophist>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
I read in one of the technical reports that there was a program
written in icon that read a tar file, checked if the names were
longer than 15 characters, if so, shortened them.
I wrote such a utility nearly a year ago, and have posted several
versions of it to this newsgroup. I have been getting enough sporadic
requests for it that I've decided to post it to alt.sources. Anyone
who is unable to look it up there can write to me directly, and I'll
happily send them a copy.
Gotta send me bug reports and comments, though!
-Richard
From icon-group-request@arizona.edu Sun Jan 20 23:49:16 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA19217; Sun, 20 Jan 91 23:49:16 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Sun, 20 Jan
1991 23:48 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA18892; Sun, 20 Jan 91
22:42:07 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Sun, 20 Jan 1991 23:49 MST
Date: 21 Jan 91 05:02:59 GMT
From: midway!quads.uchicago.edu!goer@uunet.uu.net (Richard L. Goerwitz)
Subject: DOS->UNIX conversion, patch
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <39D179D9A0802B02@Arizona.edu>
Message-Id: <1991Jan21.050259.9512@midway.uchicago.edu>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: University of Chicago
Eeek! A bug!
Please apply the following patch to nocr.icn. If anyone is unable
to apply patches, send me a note, and I'll mail you the whole thing
in toto.
-Richard
*** nocr.icn Sun Jan 20 23:00:00 1991
--- nocr.icn.old Sun Jan 20 22:59:52 1991
***************
*** 6,12 ****
#
# Author: Richard L. Goerwitz
#
! # Version: 1.4
#
############################################################################
#
--- 6,12 ----
#
# Author: Richard L. Goerwitz
#
! # Version: 1.2
#
############################################################################
#
***************
*** 82,92 ****
else {
# If not running under DOS, then we're under UNIX (unless
# we've been hacked). Trim CR manually, then write.
! while line := read(infile) do {
! if line[-1] == "\x0D" then
! line[-1] := ""
! write(outfile, line)
! }
}
# Close opened input and output files.
--- 82,88 ----
else {
# If not running under DOS, then we're under UNIX (unless
# we've been hacked). Trim CR manually, then write.
! while write(outfile, read(infile) ? tab(-1|0))
}
# Close opened input and output files.
From icon-group-request@arizona.edu Wed Jan 23 12:08:06 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA06797; Wed, 23 Jan 91 12:08:06 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Wed, 23 Jan
1991 12:07 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA10871; Wed, 23 Jan 91
11:02:56 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Wed, 23 Jan 1991 12:07 MST
Date: 23 Jan 91 17:16:55 GMT
From: midway!quads.uchicago.edu!goer@handies.ucar.edu (Richard L. Goerwitz)
Subject: simple text-base utility
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <3359802B60804218@Arizona.edu>
Message-Id: <1991Jan23.171655.14402@midway.uchicago.edu>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: University of Chicago
Ever want to work with tables, in order to retrieve entries on the
basis of a key, but yet have entries that are so big that the whole
process gets terribly unweildy? If you have, here's a little util-
ity that lets you dump all your text into a file, but yet still be
able to access it as if it were in a table.
I wrote this for a project I was doing the other day, but I think
it would be of general interest. Note that it's *not* been extensively
tested.
-Richard
---- Cut Here and feed the following to sh ----
#!/bin/sh
# This is a shell archive (produced by shar 3.49)
# To extract the files from this archive, save it to a file, remove
# everything above the "!/bin/sh" line above, and type "sh file_name".
#
# made 01/22/1991 16:13 UTC by goer@sophist.uchicago.edu
# Source directory /u/richard/Gettext
#
# existing files will NOT be overwritten unless -c is specified
# This format requires very little intelligence at unshar time.
# "if test", "cat", "rm", "echo", "true", and "sed" may be needed.
#
#
#
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 1943 -r--r--r-- idxtext.icn
# 4681 -r--r--r-- gettext.icn
# 1310 -r--r--r-- adjuncts.icn
# 2222 -rw-r--r-- README
# 611 -rw-r--r-- Makefile.dist
#
if test -r _shar_seq_.tmp; then
echo 'Must unpack archives in sequence!'
echo Please unpack part `cat _shar_seq_.tmp` next
exit 1
fi
# ============= idxtext.icn ==============
if test -f 'idxtext.icn' -a X"$1" != X"-c"; then
echo 'x - skipping idxtext.icn (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting idxtext.icn (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'idxtext.icn' &&
X############################################################################
X#
X# Name: idxtext.icn
X#
X# Title: idxtext (index text-base for gettext() routine)
X#
X# Author: Richard L. Goerwitz
X#
X# Version: 1.2
X#
X############################################################################
X#
X# Turns a file associated with gettext() routine into an indexed text-
X# base. Though gettext() will work fine with files that haven't been
X# indexed via idxtext(), access is much faster if the indexing is done.
X#
X# Usage is simply:
X#
X# idxtext file1 [file2 [...]]
X#
X# where file1, file2, etc are the names of gettext-format files that
X# are to be (re-)indexed.
X#
X############################################################################
X#
X# Links: ./adjuncts.icn
X#
X# Requires: UNIX or MS-DOS
X#
X# See also: gettext.icn
X#
X############################################################################
X
X
Xglobal _slash, _baselen
X
Xprocedure main(a)
X
X local temp_name, fname, infile, outfile
X initial {
X if find("UNIX", &features) then {
X _slash := "/"
X _baselen := 10
X }
X else if find("MS-DOS", &features) then {
X _slash := "\\"
X _baselen := 8
X }
X else stop("idxtext: OS not supported")
X }
X
X # Check to see if we have any arguments.
X *a = 0 & stop("usage: idxtext file1 [file2 [...]]")
X
X # Start popping filenames off of the argument list.
X while fname := pop(a) do {
X
X # Open input file.
X infile := open(fname) | stop("idxtext: ",fname," not found")
X # Get index file name.
X outfile := open(temp_name := Pathname(fname)||getidxname(fname),"w") |
X stop("idxtext: ",temp_name," not found")
X
X # Write index to temporary file.
X write_index(infile, outfile)
X
X every close(infile | outfile)
X
X }
X
Xend
X
X
Xprocedure write_index(in, out)
X
X local w, line
X
X while (w := where(in), line := read(in)) do {
X line ? {
X if ="::" then
X write(out, trim(tab(0)), "\t", w)
X }
X }
X
X return
X
Xend
SHAR_EOF
true || echo 'restore of idxtext.icn failed'
rm -f _shar_wnt_.tmp
fi
# ============= gettext.icn ==============
if test -f 'gettext.icn' -a X"$1" != X"-c"; then
echo 'x - skipping gettext.icn (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gettext.icn (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gettext.icn' &&
X############################################################################
X#
X# Name: gettext.icn
X#
X# Title: gettext (simple text-base routines)
X#
X# Author: Richard L. Goerwitz
X#
X# Version: 1.4
X#
X############################################################################
X#
X# Gettext() and associated routines allow the user to maintain a file
X# of KEY/value combinations such that a call to gettext(KEY, FNAME)
X# will produce value. Fails if no such KEY exists. Returns an empty
X# string if the key exists, but has no associated value in the file,
X# FNAME.
X#
X# The file format is simple. Keys belong on separate lines, marked
X# as such by an initial colon+colon (::). Values begin on the line
X# following their respective keys, and extend up to the next
X# colon+colon-initial line or EOF. E.g.
X#
X# ::sample.1
X# Notice how the key above, sample.1, has :: prepended to mark it
X# out as a key. The text you are now reading represents that key's
X# value. To retrieve this text, you would call gettext() with the
X# name of the key passed as its first argument, and the name of the
X# file in which this text is stored as its second argument (as in
X# gettext("sample.1","tmp.idx")).
X# ::next.key
X# etc...
X#
X# For faster access, an indexing utility is included, idxtext. Idxtext
X# creates a separate index for a given text-base file. If an index file
X# exists in the same directory as FNAME
X#
X# Donts:
X# 1) Don't nest gettext text-base files.
X# 2) Don't use spaces and/or tabs in key names.
X# 3) Don't modify indexed files in any way other than to append
X# additional keys/values (unless you want to re-index).
X#
X# This program is intended for situations where keys tend to have
X# very large values, and use of an Icon table structure would be
X# unweildy.
X#
X# BUGS: Fairly slow. Could be modified to use the library routine
X# findre.icn, and do regexp pattern matches on keys. Wouldn't that
X# be nice? Should be modified to alphabetize indices, and then do a
X# real binary search of the index. This would preclude easy regexp
X# pattern matches, but would be worth it for larger databases.
X#
X# Note: This program is NOT YET TESTED UNDER DOS. In particular,
X# I have no idea whether the indexing mechanism will work, due to
X# translation that has to be done on MS-DOS text files.
X#
X############################################################################
X#
X# Links: ./adjuncts.icn
X#
X# Requires: UNIX (maybe MS-DOS; untested)
X#
X############################################################################
X
X
Xglobal _slash, _baselen
X
Xprocedure gettext(KEY,FNAME)
X
X local line, value
X static last_FNAME, intext, inidx
X initial {
X if find("UNIX", &features) then {
X _slash := "/"
X _baselen := 10
X }
X else if find("MS-DOS", &features) then {
X _slash := "\\"
X _baselen := 8
X }
X else stop("gettext: OS not supported")
X }
X
X (/KEY | /FNAME) & stop("error (gettext): null argument")
X
X if FNAME ~== \last_FNAME then {
X seek(intext, 1)
X seek(inidx, 1)
X }
X else {
X # We've got a new text-base file. Close the old one.
X every close(\intext | \inidx)
X # Try to open named text-base file.
X intext := open(FNAME) | stop("gettext: ",FNAME," not found")
X # Try to open index file.
X inidx := open(Pathname(FNAME) || getidxname(FNAME))
X }
X last_FNAME := FNAME
X
X # Find offsets for key KEY in index file. Defaults to 1.
X every seek(intext, get_offsets(KEY, inidx)) do {
X
X # Find key. Should be right there, unless the user has
X # appended key/value pairs to the end without re-indexing, or
X # else has not bothered to index in the first place.
X while line := (read(intext) | fail) do {
X line ? {
X if (="::", =KEY, pos(0))
X then break
X }
X }
X
X # Collect all text upto the next colon+colon-initial line (::)
X # or EOF.
X value := ""
X while line := read(intext) do {
X match("::",line) & break
X value ||:= line || "\n"
X }
X
X # Note that a key with an empty value returns an empty string.
X suspend value
X
X }
X
Xend
X
X
Xprocedure get_offsets(KEY, inidx)
X
X # If there's no index file, then just return an offset of 1.
X if /inidx then
X return 1
X
X # I guess we could insert some sort of binary search routine
X # here, but I'm feeling lazy.
X
X # Find every instance of this key, KEY, in the index file.
X while line := read(inidx) do {
X line ? {
X # Tab separates key from offset.
X (=KEY, ="\t") | next
X # Rest of the line contains the offset.
X suspend integer(tab(0))
X }
X }
X
X # Last line of the index file contains offset of last indexed
X # byte + 1.
X return integer(line)
X
Xend
SHAR_EOF
true || echo 'restore of gettext.icn failed'
rm -f _shar_wnt_.tmp
fi
# ============= adjuncts.icn ==============
if test -f 'adjuncts.icn' -a X"$1" != X"-c"; then
echo 'x - skipping adjuncts.icn (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting adjuncts.icn (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'adjuncts.icn' &&
X############################################################################
X#
X# Name: adjuncts.icn
X#
X# Title: adjuncts (adjunct utilities for gettext and idxtext)
X#
X# Author: Richard L. Goerwitz
X#
X# Version: 1.1
X#
X############################################################################
X#
X# Pretty mundane stuff. Basename(), Pathname(), Strip(), and a utility
X# for creating index filenames.
X#
X############################################################################
X#
X# Links: none
X#
X# See also: gettext.icn, idxtext,icn
X#
X############################################################################
X
X
Xprocedure Basename(s)
X
X # global _slash
X s ? {
X while tab(find(_slash)+1)
X return tab(0)
X }
X
Xend
X
X
Xprocedure Pathname(s)
X
X # global _slash
X s2 := ""
X s ? {
X while s2 ||:= tab(find(_slash)+1)
X return s2
X }
X
Xend
X
X
Xprocedure getidxname(FNAME)
X
X #
X # Discard path component. Cut basename down to a small enough
X # size that the OS will be able to handle addition of the ex-
X # tension ".IDX"
X #
X
X # global _slash, _baselen
X return right(Strip(Basename(FNAME,_slash),'.'), _baselen, "x") || ".IDX"
X
Xend
X
X
Xprocedure Strip(s,c)
X
X local s2
X
X s2 := ""
X s ? {
X while s2 ||:= tab(upto(c))
X do tab(many(c))
X s2 ||:= tab(0)
X }
X return s2
X
Xend
SHAR_EOF
true || echo 'restore of adjuncts.icn failed'
rm -f _shar_wnt_.tmp
fi
# ============= README ==============
if test -f 'README' -a X"$1" != X"-c"; then
echo 'x - skipping README (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting README (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'README' &&
X
XThis archive contains gettext() and associated routines. These allow
Xthe user to maintain a file of key/value combinations such that a call
Xto gettext(key, FNAME) will produce value. Fails if no such key
Xexists. Returns an empty string if the key exists, but has no
Xassociated value in the file named in arg 2 (FNAME). Gettext() is
Xintended for use in situations where keys need to be associated with
Xvery large strings (i.e. where hand-inserting these values into hash
Xtables would be unweildy, and would take up a sizable chunk of
Xmemory).
X
XThe file format is simple. Keys belong on separate lines, marked
Xas such by an initial colon+colon (::). Values begin on the line
Xfollowing their respective keys, and extend up to the next
Xcolon+colon-initial line or EOF. E.g.
X
X ::sample.1
X Notice how the key above, sample.1, has :: prepended to mark it
X out as a key. The text you are now reading represents that key's
X value. To retrieve this text, you would call gettext() with the
X name of the key passed as its first argument, and the name of the
X file in which this text is stored as its second argument (as in
X gettext("sample.1","tmp.idx")).
X ::next.key
X etc...
X
XFor faster access, an indexing utility is included, idxtext. Idxtext
Xcreates a separate index for a given text-base file. If an index file
Xexists in the same directory as FNAME.
X
XBoth idxtext.icn and gettext.icn need to be linked with a common set
Xof utilities, ./adjuncts.icn.
X
XThere are lots of things that might be done to gettext/idxtext, such
Xas implement a binary search mechanism in the routine get_offsets(),
Xand compress or pack portions or the index file. Might also be sen-
Xsible to offer regex patterns as an option for key/value retrievals.
XThis is a pretty rough version, as it stands, and I hope someone will
Xsee fit to modify it some time. Note that it's untested under MS-DOS,
Xbut I suppose it could be made to work there. The only big problem
XI foresee is with translation of CR+LF sequences and the consequent
Xdisruption of where() and seek().
X
XFor a list of do's/dont's, see the comments prepended to gettext.icn.
XSend bug reports/fixes, comments, etc. to -
X
XRichard Goerwitz (goer@sophist.uchicago.edu)
SHAR_EOF
true || echo 'restore of README failed'
rm -f _shar_wnt_.tmp
fi
# ============= Makefile.dist ==============
if test -f 'Makefile.dist' -a X"$1" != X"-c"; then
echo 'x - skipping Makefile.dist (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting Makefile.dist (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'Makefile.dist' &&
X# Please edit these to reflect your local file structure & conventions.
XDESTDIR = /usr/local/bin
XOWNER = bin
XGROUP = bin
X
Xidxtext: idxtext.icn
X icont idxtext.icn adjunct.icn
X
X# Pessimistic assumptions regarding the environment (in particular,
X# I don't assume you have the BSD "install" shell script).
Xinstall: idxtext
X @echo "\nInstalling idxtext in $(DESTDIR).\n"
X @sh -c "test -d $(DESTDIR) || (mkdir $(DESTDIR) && chmod 755 $(DESTDIR))"
X cp idxtext $(DESTDIR)/
X chgrp $(GROUP) $(DESTDIR)/idxtext
X chown $(OWNER) $(DESTDIR)/idxtext
X @echo "\nInstallation done.\n"
X
Xclean:
X -rm -f *u? *~
X -rm -f idxtext test
SHAR_EOF
true || echo 'restore of Makefile.dist failed'
rm -f _shar_wnt_.tmp
fi
exit 0
From icon-group-request@arizona.edu Thu Jan 31 00:21:35 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA23580; Thu, 31 Jan 91 00:21:35 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Thu, 31 Jan
1991 00:21 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA13991; Wed, 30 Jan 91
23:17:36 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Thu, 31 Jan 1991 00:21 MST
Date: 31 Jan 91 02:47:32 GMT
From: hsi!mlfarm!ron@uunet.uu.net (Ronald Florence)
Subject: Postscript two-up filter
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <19FD7CCE80805A29@Arizona.edu>
Message-Id: <735@mlfarm.com>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: Maple Lawn Farm, Stonington, CT
Before I reinvent the wheel, has anyone written an Icon filter to
print Postscript pages two-up, e.g., side-by-side in landscape mode?
I've seen filters to do this written in perl. Icon seems perfect for
the task.
--
Ronald Florence ron@mlfarm.com
From S.P.Q.Rahtz@ecs.southampton.ac.uk Thu Jan 31 02:52:23 1991
Resent-From: S.P.Q.Rahtz@ecs.southampton.ac.uk
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA29202; Thu, 31 Jan 91 02:52:23 -0700
Received: from sun2.nsfnet-relay.ac.uk by Arizona.edu with PMDF#10282; Thu, 31
Jan 1991 02:51 MST
Received: from vax.nsfnet-relay.ac.uk by sun2.nsfnet-relay.ac.uk with SMTP
inbound id <2568-5@sun2.nsfnet-relay.ac.uk>; Thu, 31 Jan 1991 09:46:52 +0000
Received: from sun2.nsfnet-relay.ac.uk by vax.NSFnet-Relay.AC.UK via Janet with
NIFTP id aa02812; 31 Jan 91 9:26 GMT
Received: from bright.ecs.soton.ac.uk by hilliard.ecs.soton.ac.uk; Thu, 31 Jan
91 09:42:41 GMT
Received: from vicky.ecs.soton.ac.uk by bright.ecs.soton.ac.uk; Thu, 31 Jan 91
09:39:28 GMT
Resent-Date: Thu, 31 Jan 1991 02:52 MST
Date: Thu, 31 Jan 91 14:40:46 gmt
From: Sebastian Rahtz <S.P.Q.Rahtz@ecs.southampton.ac.uk>
Subject: RE: Postscript two-up filter
In-Reply-To: <735@mlfarm.com>
Resent-To: icon-group@cs.arizona.edu
To: ron <@uunet.uu.net,@hsi:ron@mlfarm>
Cc: icon-group@arizona.edu
Resent-Message-Id: <2F0DE92A10805C97@Arizona.edu>
Message-Id: <15130.9101311440@manutius.ecs.soton.ac.uk>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: ron <@uunet.uu.net,@hsi:ron@mlfarm>
X-Vms-Cc: icon-group@Arizona.edu
Ronald Florence writes:
> Before I reinvent the wheel, has anyone written an Icon filter to
> print Postscript pages two-up, e.g., side-by-side in landscape mode?
> I've seen filters to do this written in perl. Icon seems perfect for
> the task.
there is an even simpler solution, which is to write it in PostScript
itself... thats what I use, an excellent offering by Ross Cartlidge
which does everything you need in the way of n-up.
much as I dote on Icon, I can't help feeling that a) having to have
Icon on every machine from which I print PS, and b) having to load in
the Icon interpreter each time I print is mild overkill.
if anyone wants Ross Cartlidge's code (you just prepend it to your
normal output), I can mail it
sebastian
From ralph Thu Jan 31 10:12:10 1991
Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA15341; Thu, 31 Jan 91 10:12:10 -0700
Date: Thu, 31 Jan 91 10:12:08 MST
From: "Ralph Griswold" <ralph>
Message-Id: <9101311712.AA25007@cheltenham.cs.arizona.edu>
Received: by cheltenham.cs.arizona.edu; Thu, 31 Jan 91 10:12:08 MST
To: icon-group
Subject: UNIX configurations for Version 8 of Icon
Since Version 8 of Icon was released, we've received several new and
improved configurations for UNIX platforms.
We do not plan to update the complete Version 8 distribution for Icon
in the near future, but we've put an updated version of the configuration
subdirectory on our FTP area. This update is available in cpio and
tar format, and replaces the config/unix subdirectory in the original
distribution.
To get this update, do an anonymous FTP to cs.arizona.edu and
cd /icon/v8. The files are named unixconf.cpi and unixconf.tar.
If you have any questions, please send mail to me, not to icon-group.
Ralph Griswold
Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
+1 602 621 6609 ralph@cs.arizona.edu uunet!arizona!ralph
From icon-group-request@arizona.edu Fri Feb 1 08:23:13 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA25356; Fri, 1 Feb 91 08:23:13 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Fri, 1 Feb
1991 08:22 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA25963; Fri, 1 Feb 91 07:08:16
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Fri, 1 Feb 1991 08:22 MST
Date: 1 Feb 91 14:55:11 GMT
From: att!linac!midway!ellis.uchicago.edu!goer@ucbvax.Berkeley.EDU (Richard L.
Goerwitz)
Subject: shooting yourself in the foot
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <26702A2D808067B7@Arizona.edu>
Message-Id: <1991Feb1.145511.9592@midway.uchicago.edu>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: University of Chicago
Howd'ya shoot yourself in the foot in Icon?
You think your are going to shoot your foot, but automatic type
conversion suddenly kicks in, and you find yourself aiming at a
bull's eye. You shoot the bull's eye until the it completely
disintegrates. Backtracking then kicks in, finds the other foot,
shoots it, and then reports your efforts as a failure.
-Richard
From ralph Sat Feb 2 14:31:50 1991
Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA24576; Sat, 2 Feb 91 14:31:50 -0700
Date: Sat, 2 Feb 91 14:31:47 MST
From: "Ralph Griswold" <ralph>
Message-Id: <9102022131.AA18227@cheltenham.cs.arizona.edu>
Received: by cheltenham.cs.arizona.edu; Sat, 2 Feb 91 14:31:47 MST
To: icon-group
Subject: New Company Formed to Provide Commercial Support for Icon
Iconic Software, Inc. (ISI), is a new company founded by a
core group of computer scientists, together with professionals in
computer marketing and technical customer service.
ISI's goal is to become a major supplier of software develop-
ment tools, languages, and high-value applications for the UNIX
system environment. ISI founders have considerable expertise and
experience with Icon and with UNIX-based systems, much of it
gained while working at AT&T Bell Laboratories.
The company will initially focus on high-quality voice pro-
cessing systems. "Voice response systems are applications in
which persons interact with a computer over their touch-tone
phones to access and update databases, hear prerecorded informa-
tion and leave recorded messages, and perform other transactions"
said ISI founder, Jerry Nowlin. "We've already developed special
Icon utilities that will allow us to deliver thoroughly tested
systems in a fraction of the time that would be required if C
were used."
An exciting prospect for ISI is commercial support for the
Icon compiler, which is currently under development at the
University of Arizona. Although the initial UNIX version of the
compiler will be available to the public, ISI will extend and
support a commercial UNIX version. Ken Walker, who designed and
implemented the compiler and is presently completing his PhD, is
joining ISI to work on this project. ISI is also investigating
the feasibility of an MS-DOS implementation. ISI hopes to become
known as the "Icon Compiler Company" and sees a significant
opportunity in bringing Icon to professional developers of com-
mercial software products.
ISI's administrative and marketing offices are currently
located in West Lafayette, Indiana. Development facilities are
located in Plano, Illinois. For more information about ISI's pro-
ducts and services contact Roger Fonorow: (317) 463-9269.
Electronic mail can be sent to ISI at:
isi@isidev.att.com Internet
att!isidev!isi uucp
From icon-group-request@arizona.edu Sat Feb 2 17:20:39 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA28782; Sat, 2 Feb 91 17:20:39 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Sat, 2 Feb
1991 17:19 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA08172; Sat, 2 Feb 91 16:12:25
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Sat, 2 Feb 1991 17:20 MST
Date: 2 Feb 91 18:02:11 GMT
From: hsi!mlfarm!ron@uunet.uu.net (Ronald Florence)
Subject: reply.icn & post.icn
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <3AAC7B8EEAE00504@Arizona.edu>
Message-Id: <741@mlfarm.com>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: Maple Lawn Farm, Stonington, CT
To my surprise, these programs are actually used for mail replies and
news posting at a few Unix and ms-dos sites. I've added some modest
revisions: case-insensitive header parsing, parsing for follow-ups to
newsgroups or "poster", prompts for news distribution, and slightly
more robust syntax in the Icon code. Let me know if you want the
current version of either program by email.
--
Ronald Florence ron@mlfarm.com
From icon-group-request@arizona.edu Mon Feb 4 19:08:15 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Osprey.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA03902; Mon, 4 Feb 91 19:08:15 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Mon, 4 Feb
1991 19:07 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA09578; Mon, 4 Feb 91 17:59:04
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Mon, 4 Feb 1991 19:08 MST
Date: 4 Feb 91 12:54:55 GMT
From: mcsun!cernvax!chx400!hslrswi!naz@uunet.uu.net (Norman H. Azadian)
Subject: IPATH under MKS Toolkit
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <DC0B3BCECAE0113D@Arizona.edu>
Message-Id: <1808@hslrswi.hasler.ascom.ch>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: Hasler AG
Well, I sure screwed up royal when I posted that last gripe about the
Icon linker not being able to use IPATH under the MKS Toolkit. It works
like a champ when one remembers to export the environment variable.
I swear I gotta stop this late night hacking.
NHA
--
PAPER: Norman Azadian; Ascom AG; Belpstrasse 23; 3000 Berne 14; Switzerland
INTERNET: naz%hslrswi.uucp@uunet.uu.net
UUCP: ...{uunet,ukc,mcvax,...}!chx400!hslrswi!naz
VOICE: +41 31 63 2178 BITNET: naz%hslrswi.UUCP@cernvax.BITNET
From goer%sophist@gargoyle.uchicago.edu Thu Feb 7 23:17:23 1991
Resent-From: goer%sophist@gargoyle.uchicago.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA27075; Thu, 7 Feb 91 23:17:23 -0700
Return-Path: goer@sophist.uchicago.edu
Received: from gargoyle.uchicago.edu by Arizona.edu with PMDF#10282; Thu, 7 Feb
1991 23:16 MST
Received: by gargoyle.uchicago.edu from sophist (sophist.uchicago.edu)
(4.0/1.14) id AA04989; Fri, 8 Feb 91 00:16:30 CST
Received: by sophist (4.1/UofC3.1X) id AA25266; Fri, 8 Feb 91 00:19:02 CST
Resent-Date: Thu, 7 Feb 1991 23:17 MST
Date: Fri, 8 Feb 91 00:19:02 CST
From: Richard Goerwitz <goer%sophist@gargoyle.uchicago.edu>
Subject: gettext text-base routines
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <5A558FBFBAE01E14@Arizona.edu>
Message-Id: <9102080619.AA25266@sophist>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
I posted a set of text-base utilities a while back. They have
been somewhat improved since then, and although I really haven't
had as much feedback as I'd like since the initial posting, I
believe the changes are enough to warrant a repost.
Please, if you use these programs - and especially if you find
bugs - drop me a line.
-Richard (goer@sophist.uchicago.edu)
---- Cut Here and feed the following to sh ----
#!/bin/sh
# This is a shell archive (produced by shar 3.49)
# To extract the files from this archive, save it to a file, remove
# everything above the "!/bin/sh" line above, and type "sh file_name".
#
# made 02/08/1991 06:07 UTC by goer@sophist.uchicago.edu
# Source directory /u/richard/Gettext
#
# existing files will NOT be overwritten unless -c is specified
# This format requires very little intelligence at unshar time.
# "if test", "cat", "rm", "echo", "true", and "sed" may be needed.
#
#
#
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 2799 -r--r--r-- idxtext.icn
# 6225 -r--r--r-- gettext.icn
# 1310 -r--r--r-- adjuncts.icn
# 2230 -rw-r--r-- README
# 600 -rw-r--r-- Makefile.dist
#
if test -r _shar_seq_.tmp; then
echo 'Must unpack archives in sequence!'
echo Please unpack part `cat _shar_seq_.tmp` next
exit 1
fi
# ============= idxtext.icn ==============
if test -f 'idxtext.icn' -a X"$1" != X"-c"; then
echo 'x - skipping idxtext.icn (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting idxtext.icn (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'idxtext.icn' &&
X############################################################################
X#
X# Name: idxtext.icn
X#
X# Title: idxtext (index text-base for gettext() routine)
X#
X# Author: Richard L. Goerwitz
X#
X# Version: 1.9
X#
X############################################################################
X#
X# Idxtext turns a file associated with gettext() routine into an
X# indexed text- base. Though gettext() will work fine with files
X# that haven't been indexed via idxtext(), access is faster if the
X# indexing is done if the file is, say, over 10k (on my system the
X# crossover point is actually about 5k).
X#
X# Usage is simply "idxtext file1 [file2 [...]]," where file1,
X# file2, etc are the names of gettext-format files that are to be
X# (re-)indexed.
X#
X# Indexed files have a very simple format: keyname tab offset
X# [tab offset [etc.]]\n. The first line of the index file is a
X# pointer to the last indexed byte of the text-base file it indexes.
X#
X# BUGS: Index files are too large.
X#
X############################################################################
X#
X# Links: ./adjuncts.icn
X#
X# Requires: UNIX or MS-DOS
X#
X# See also: gettext.icn
X#
X############################################################################
X
X
Xglobal _slash, _baselen
X
Xprocedure main(a)
X
X local temp_name, fname, infile, outfile
X initial {
X if find("UNIX", &features) then {
X _slash := "/"
X _baselen := 10
X }
X else if find("MS-DOS", &features) then {
X _slash := "\\"
X _baselen := 8
X }
X else stop("idxtext: OS not supported")
X }
X
X # Check to see if we have any arguments.
X *a = 0 & stop("usage: idxtext file1 [file2 [...]]")
X
X # Start popping filenames off of the argument list.
X while fname := pop(a) do {
X
X # Open input file.
X infile := open(fname) | stop("idxtext: ",fname," not found")
X # Get index file name.
X outfile := open(temp_name := Pathname(fname)||getidxname(fname),"w") |
X stop("idxtext: ",temp_name," not found")
X
X # Write index to index.IDX file.
X write_index(infile, outfile)
X
X every close(infile | outfile)
X
X }
X
Xend
X
X
Xprocedure write_index(in, out)
X
X local key_offset_table, w, line, KEY
X
X # Write to out all keys in file "in," with their byte
X # offsets.
X
X key_offset_table := table()
X
X while (w := where(in), line := read(in)) do {
X line ? {
X if ="::" then {
X KEY := trim(tab(0))
X if not (/key_offset_table[KEY] := KEY || "\t" || w)
X then stop("idxtext: duplicate key, ",KEY)
X }
X }
X }
X
X # First line of index contains the offset of the last
X # indexed byte in write_index, so that we can still
X # search unindexed parts of in.
X write(out, where(in))
X
X # Write sorted KEY\toffset lines.
X if *key_offset_table > 0 then
X every write(out, (!sort(key_offset_table))[2])
X
X return
X
Xend
SHAR_EOF
true || echo 'restore of idxtext.icn failed'
rm -f _shar_wnt_.tmp
fi
# ============= gettext.icn ==============
if test -f 'gettext.icn' -a X"$1" != X"-c"; then
echo 'x - skipping gettext.icn (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gettext.icn (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gettext.icn' &&
X############################################################################
X#
X# Name: gettext.icn
X#
X# Title: gettext (simple text-base routines)
X#
X# Author: Richard L. Goerwitz
X#
X# Version: 1.14
X#
X############################################################################
X#
X# Gettext() and associated routines allow the user to maintain a file
X# of KEY/value combinations such that a call to gettext(KEY, FNAME)
X# will produce value. Gettext() fails if no such KEY exists.
X# Returns an empty string if the key exists, but has no associated
X# value in the file, FNAME.
X#
X# The file format is simple. Keys belong on separate lines, marked
X# as such by an initial colon+colon (::). Values begin on the line
X# following their respective keys, and extend up to the next
X# colon+colon-initial line or EOF. E.g.
X#
X# ::sample.1
X# Notice how the key above, sample.1, has :: prepended to mark it
X# out as a key. The text you are now reading represents that key's
X# value. To retrieve this text, you would call gettext() with the
X# name of the key passed as its first argument, and the name of the
X# file in which this text is stored as its second argument (as in
X# gettext("sample.1","tmp.idx")).
X# ::next.key
X# etc...
X#
X# For faster access, an indexing utility is included, idxtext. Idxtext
X# creates a separate index for a given text-base file. If an index file
X# exists in the same directory as FNAME, gettext() will make use of it.
X# The index becomes worthwhile (at least on my system) after the text-
X# base file becomes longer than 5 kilobytes.
X#
X# Donts:
X# 1) Don't nest gettext text-base files.
X# 2) Don't use spaces and/or tabs in key names.
X# 3) Don't modify indexed files in any way other than to append
X# additional keys/values (unless you want to re-index).
X#
X# This program is intended for situations where keys tend to have
X# very large values, and use of an Icon table structure would be
X# unweildy.
X#
X# BUGS: Gettext() relies on the Icon runtime system and the OS to
X# make sure the last text/index file it opens gets closed.
X#
X# Note: This program is NOT YET TESTED UNDER DOS. In particular,
X# I have no idea whether the indexing mechanism will work, due to
X# translation that has to be done on MS-DOS text files.
X#
X############################################################################
X#
X# Links: ./adjuncts.icn
X#
X# Requires: UNIX (maybe MS-DOS; untested)
X#
X############################################################################
X
X
Xglobal _slash, _baselen
X
Xprocedure gettext(KEY,FNAME)
X
X local line, value
X static last_FNAME, intext, inidx
X initial {
X if find("UNIX", &features) then {
X _slash := "/"
X _baselen := 10
X }
X else if find("MS-DOS", &features) then {
X _slash := "\\"
X _baselen := 8
X }
X else stop("gettext: OS not supported")
X }
X
X (/KEY | /FNAME) & stop("error (gettext): null argument")
X
X if FNAME ~== \last_FNAME then {
X seek(intext, 1)
X seek(\inidx, 1)
X }
X else {
X # We've got a new text-base file. Close the old one.
X every close(\intext | \inidx)
X # Try to open named text-base file.
X intext := open(FNAME) | stop("gettext: ",FNAME," not found")
X # Try to open index file.
X inidx := open(Pathname(FNAME) || getidxname(FNAME))
X }
X last_FNAME := FNAME
X
X # Find offsets for key KEY in index file. If inidx (the index
X # file) is null (which happens when none was found), get_offsets()
X # defaults to 1. Otherwise it returns the offset for KEY in the
X # index file, and then returns the last indexed byte of the file.
X # Returning the last indexed byte lets us seek to the end and do a
X # sequential search of any key/value entries that have been added
X # since the last time idxtext was run.
X
X seek(intext, get_offsets(KEY, inidx))
X
X # Find key. Should be right there, unless the user has appended
X # key/value pairs to the end without re-indexing, or else has not
X # bothered to index in the first place. In this case we're
X # supposed to start a sequential search for KEY upto EOF.
X
X while line := (read(intext) | fail) do {
X line ? {
X if (="::", =KEY, pos(0))
X then break
X }
X }
X
X # Collect all text upto the next colon+colon-initial line (::)
X # or EOF.
X value := ""
X while line := read(intext) do {
X match("::",line) & break
X value ||:= line || "\n"
X }
X
X # Note that a key with an empty value returns an empty string.
X return trim(value, '\n')
X
Xend
X
X
X
Xprocedure get_offsets(KEY, inidx)
X
X local bottom, top, loc, firstpart, offset
X # Use these to store values likely to be reused.
X static old_inidx, firstline, SOF, EOF
X
X # If there's no index file, then just return an offset of 1.
X if /inidx then
X return 1
X
X # First line contains offset of last indexed byte in the main
X # text file. We need this later. Save it. Start the binary
X # search routine at the next byte after this line.
X seek(inidx, 1)
X if not (inidx === \old_inidx) then {
X
X # Get first line.
X firstline := !inidx
X # Set "bottom."
X 1 = (SOF := where(inidx)-1) &
X stop("get_offsets: corrupt .IDX file; reindex")
X # How big is this file?
X seek(inidx, 0)
X EOF := where(inidx)
X
X old_inidx := inidx
X }
X # SOF, EOF constant for a given inidx file.
X bottom := SOF; top := EOF
X
X # If bottom gets bigger than top, there's no such key.
X until bottom > top do {
X
X loc := (top+bottom) / 2
X seek(inidx, loc)
X
X # Move past next newline. If at EOF, break.
X incr := 1
X until reads(inidx) == "\n" do
X incr +:= 1
X if loc+incr = EOF then {
X top := loc-1
X next
X }
X
X # Check to see if the current line contains KEY.
X read(inidx) ? {
X
X # .IDX file line format is KEY\toffset
X firstpart := tab(find("\t"))
X if KEY == firstpart then {
X # return offset
X return (move(1), tab(0))
X }
X # Ah, this is what all binary searches do.
X else {
X if KEY << firstpart
X then top := loc-1
X else bottom := loc + incr + *&subject
X }
X }
X }
X
X # First line of the index file contains offset of last indexed
X # byte + 1. Might be the only line in the file (if it had no
X # keys when it was indexed).
X return firstline
X
Xend
SHAR_EOF
true || echo 'restore of gettext.icn failed'
rm -f _shar_wnt_.tmp
fi
# ============= adjuncts.icn ==============
if test -f 'adjuncts.icn' -a X"$1" != X"-c"; then
echo 'x - skipping adjuncts.icn (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting adjuncts.icn (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'adjuncts.icn' &&
X############################################################################
X#
X# Name: adjuncts.icn
X#
X# Title: adjuncts (adjunct utilities for gettext and idxtext)
X#
X# Author: Richard L. Goerwitz
X#
X# Version: 1.1
X#
X############################################################################
X#
X# Pretty mundane stuff. Basename(), Pathname(), Strip(), and a utility
X# for creating index filenames.
X#
X############################################################################
X#
X# Links: none
X#
X# See also: gettext.icn, idxtext,icn
X#
X############################################################################
X
X
Xprocedure Basename(s)
X
X # global _slash
X s ? {
X while tab(find(_slash)+1)
X return tab(0)
X }
X
Xend
X
X
Xprocedure Pathname(s)
X
X # global _slash
X s2 := ""
X s ? {
X while s2 ||:= tab(find(_slash)+1)
X return s2
X }
X
Xend
X
X
Xprocedure getidxname(FNAME)
X
X #
X # Discard path component. Cut basename down to a small enough
X # size that the OS will be able to handle addition of the ex-
X # tension ".IDX"
X #
X
X # global _slash, _baselen
X return right(Strip(Basename(FNAME,_slash),'.'), _baselen, "x") || ".IDX"
X
Xend
X
X
Xprocedure Strip(s,c)
X
X local s2
X
X s2 := ""
X s ? {
X while s2 ||:= tab(upto(c))
X do tab(many(c))
X s2 ||:= tab(0)
X }
X return s2
X
Xend
SHAR_EOF
true || echo 'restore of adjuncts.icn failed'
rm -f _shar_wnt_.tmp
fi
# ============= README ==============
if test -f 'README' -a X"$1" != X"-c"; then
echo 'x - skipping README (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting README (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'README' &&
X
XThis archive contains gettext() and associated routines. These allow
Xthe user to maintain a file of key/value combinations such that a call
Xto gettext(key, FNAME) will produce value. Fails if no such key
Xexists. Returns an empty string if the key exists, but has no
Xassociated value in the file named in arg 2 (FNAME). Gettext() is
Xintended for use in situations where keys need to be associated with
Xvery large strings (i.e. where hand-inserting these values into hash
Xtables would be unweildy, and would take up a sizable chunk of
Xmemory).
X
XThe file format is simple. Keys belong on separate lines, marked
Xas such by an initial colon+colon (::). Values begin on the line
Xfollowing their respective keys, and extend up to the next
Xcolon+colon-initial line or EOF. E.g.
X
X ::sample.1
X Notice how the key above, sample.1, has :: prepended to mark it
X out as a key. The text you are now reading represents that key's
X value. To retrieve this text, you would call gettext() with the
X name of the key passed as its first argument, and the name of the
X file in which this text is stored as its second argument (as in
X gettext("sample.1","tmp.idx")).
X ::next.key
X etc...
X
XFor faster access, an indexing utility is included, idxtext. Idxtext
Xcreates a separate index for a given text-base file. If an index file
Xexists in the same directory as FNAME, gettext() will make use of it.
XOtherwise, it just does a sequential search of the entire file (this
Xworks fine for smaller files). Please don't change a file, once you've
Xrun idxtext on it, except to append key/value entries to it. If you
Xalter the indexed portion of the file in any way, you must reindex.
X
XBoth idxtext.icn and gettext.icn need to be linked with a common set
Xof utilities, ./adjuncts.icn.
X
XFor a list of do/dont's, see the comments prepended to gettext.icn.
XNote that these routines are, thus far, tested only under UNIX, and
Xhave not yet been used on a system for which seek() gets skewed by
Xline-end translations done on text files (e.g. MS-DOS). I would ex-
Xpect them to work under DOS, though I cannot say how robust they
Xwould prove to be.
X
XSend bug reports/fixes, comments, etc. to -
X
XRichard Goerwitz (goer@sophist.uchicago.edu)
SHAR_EOF
true || echo 'restore of README failed'
rm -f _shar_wnt_.tmp
fi
# ============= Makefile.dist ==============
if test -f 'Makefile.dist' -a X"$1" != X"-c"; then
echo 'x - skipping Makefile.dist (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting Makefile.dist (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'Makefile.dist' &&
X# Please edit these to reflect your local file structure & conventions.
XDESTDIR = /usr/local/bin
XOWNER = bin
XGROUP = bin
X
Xidxtext:
X icont idxtext.icn adjuncts.icn
X
X# Pessimistic assumptions regarding the environment (in particular,
X# I don't assume you have the BSD "install" shell script).
Xinstall: idxtext
X @echo "\nInstalling idxtext in $(DESTDIR).\n"
X @sh -c "test -d $(DESTDIR) || (mkdir $(DESTDIR) && chmod 755 $(DESTDIR))"
X cp idxtext $(DESTDIR)/
X chgrp $(GROUP) $(DESTDIR)/idxtext
X chown $(OWNER) $(DESTDIR)/idxtext
X @echo "\nInstallation done.\n"
X
Xclean:
X -rm -f *u? *~
X -rm -f idxtext test
SHAR_EOF
true || echo 'restore of Makefile.dist failed'
rm -f _shar_wnt_.tmp
fi
exit 0
From ralph Thu Feb 14 14:03:03 1991
Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA25824; Thu, 14 Feb 91 14:03:03 -0700
Date: Thu, 14 Feb 91 14:03:01 MST
From: "Ralph Griswold" <ralph>
Message-Id: <9102142103.AA03800@cheltenham.cs.arizona.edu>
Received: by cheltenham.cs.arizona.edu; Thu, 14 Feb 91 14:03:01 MST
To: icon-group
Subject: Icon compiler status report
We've successfully installed the Icon compiler at our site
on the following UNIX platforms, using the default C compiler in
each case:
DECstation 3100 Ultrix
HP 9000/300 HP/UX
Intel 386 System V
Iris 4d System V + BSD extensions
NeXT Mach
Sequent Symmetry Dynix
Sun 3 SunOS
Sun 4 SunOS
VAX 8650 4.3BSD
We've started beta testing on other platforms at other sites.
We hope to have a preliminary version of the Icon compiler in
executable form for these platforms in a few weeks. We'll
make source code available later.
Please direct any questions to me, not icon-group.
Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
+1 602 621 6609 ralph@cs.arizona.edu uunet!arizona!ralph
From ralph Thu Feb 14 15:21:49 1991
Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA28553; Thu, 14 Feb 91 15:21:49 -0700
Date: Thu, 14 Feb 91 15:21:47 MST
From: "Ralph Griswold" <ralph>
Message-Id: <9102142221.AA07054@cheltenham.cs.arizona.edu>
Received: by cheltenham.cs.arizona.edu; Thu, 14 Feb 91 15:21:47 MST
To: icon-group
Subject: Icon compiler clarification
When we use the term "Icon compiler", we're referring to the new
optimizing compiler for Icon, done by Ken Walker, not the Icon
interpreter, which has been around for many years.
Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
+1 602 621 6609 ralph@cs.arizona.edu uunet!arizona!ralph
From ralph Thu Feb 14 15:44:49 1991
Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA29346; Thu, 14 Feb 91 15:44:49 -0700
Date: Thu, 14 Feb 91 15:44:47 MST
From: "Ralph Griswold" <ralph>
Message-Id: <9102142244.AA07798@cheltenham.cs.arizona.edu>
Received: by cheltenham.cs.arizona.edu; Thu, 14 Feb 91 15:44:47 MST
To: icon-group
Subject: Beta testing for the Icon compiler
As noted in a recent posting, we're in the process of beta testing for
the Icon compiler.
We're looking for individuals to do beta testing on the following UNIX
platforms:
AT&T 3B4000
AViiON workstation
Convex
Cray 2
Apollo workstation
Elxsi
Macintosh under A/UX
Encore
PS/2 under AIX
Pyramid
IBM RS6000 workstation
VAX-11 under System V
VAX-11 under Ultrix
If you're interested, send me e-mail and I'll tell you what's involved
and what the conditions are.
We only have the resources to support one beta-test site for each of the
above platforms, so we'll accept qualified persons on a first-come,
first served basis.
For the same reason, we won't be able to handle beta testing for other
platforms at present, but if you're interested in beta testing for a system
that's different from the ones above and the ones listed in the previous
message, let us know and we'll get back to you later.
Please send mail to me, not icon-group.
Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
+1 602 621 6609 ralph@cs.arizona.edu uunet!arizona!ralph
From jeff@aiai.edinburgh.ac.uk Fri Feb 15 10:34:10 1991
Received: from sun2.nsfnet-relay.ac.uk by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA03641; Fri, 15 Feb 91 10:34:10 -0700
Received: from aiai.edinburgh.ac.uk by sun2.nsfnet-relay.ac.uk via JANET
with NIFTP id <18129-0@sun2.nsfnet-relay.ac.uk>;
Fri, 15 Feb 1991 17:20:14 +0000
Date: Fri, 15 Feb 91 17:19:32 GMT
Message-Id: <6367.9102151719@subnode.aiai.ed.ac.uk>
From: Jeff Dalton <jeff@aiai.edinburgh.ac.uk>
Subject: Re: Icon compiler status report
To: Ralph Griswold <ralph@cs.arizona.edu>, icon-group@cs.arizona.edu
In-Reply-To: Ralph Griswold's message of Thu, 14 Feb 91 14:03:01 MST
> We hope to have a preliminary version of the Icon compiler in
> executable form for these platforms in a few weeks. We'll
> make source code available later.
One reason I have seldom used Icon is that it is (was?) not interactive
like Lisp or ML. Any hope of this changing (or has it already)?
-- jeff
From mlfarm!ron@hsi.hsi.com Tue Feb 19 05:48:49 1991
Received: from hsi.hsi.com by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA02698; Tue, 19 Feb 91 05:48:49 -0700
Received: by hsi.hsi.com (5.61+++/1.34)
id AA25930; Tue, 19 Feb 91 07:46:25 -0500
Received: by mlfarm.com (smail2.5)
id AA11809; 19 Feb 91 06:46:53 EST (Tue)
To: icon-group@cs.arizona.edu
Subject: getopt
Message-Id: <9102190646.AA11809@mlfarm.com>
Date: 19 Feb 91 06:46:53 EST (Tue)
From: mlfarm!ron@hsi.hsi.com (Ronald Florence)
Has anyone written a getopt-style command-line parser in Icon?
--
Ronald Florence ron@mlfarm.com
From ralph Tue Feb 19 06:11:46 1991
Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA03313; Tue, 19 Feb 91 06:11:46 -0700
Date: Tue, 19 Feb 91 06:11:44 MST
From: "Ralph Griswold" <ralph>
Message-Id: <9102191311.AA19001@cheltenham.cs.arizona.edu>
Received: by cheltenham.cs.arizona.edu; Tue, 19 Feb 91 06:11:44 MST
To: mlfarm!ron@hsi.hsi.com
Subject: Re: getopt
Cc: icon-group
There's one in the Icon program library (called "options", since it's
slightly different from getopt).
Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
+1 602 621 6609 ralph@cs.arizona.edu uunet!arizona!ralph
From THEODORE@UAFSYSB.UARK.EDU Tue Feb 19 13:55:47 1991
Message-Id: <9102192055.AA21742@megaron.cs.arizona.edu>
Received: from UAFSYSB.UARK.EDU by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA21742; Tue, 19 Feb 91 13:55:47 -0700
Received: from UAFSYSB.UARK.EDU by UAFSYSB.UARK.EDU (IBM VM SMTP R1.2.2MX) with BSMTP id 4508; Tue, 19 Feb 91 14:54:16 CST
Received: from UAFSYSB (THEODORE) by UAFSYSB.UARK.EDU (Mailer R2.07) with BSMTP
id 7979; Tue, 19 Feb 91 14:54:14 CST
Date: Tue, 19 Feb 91 14:34:54 CST
From: TED PEDERSEN <THEODORE@UAFSYSB.UARK.EDU>
Subject: MACHINE TRANSLATION
To: ICON-GROUP@cs.arizona.edu
X-Acknowledge-To: <THEODORE@UAFSYSB>
Is anyone doing any work with machine translation of "human" languages using
ICON? (By machine translation I mean taking text and translating it
into another language. English to Arabic or Russian to German would be
examples.)
I am considering embarking on this sort of project and any experiences that
others have had would be of great value to me. If your experiences are only
loosely connected with either machine translation or ICON (maybe some
more general work in natural language processing etc) I would still like
to establish contact.
Thanks,
Ted Pedersen
Univ. of Arkansas
From icon-group-request@arizona.edu Thu Feb 21 04:45:28 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA06818; Thu, 21 Feb 91 04:45:28 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Thu, 21 Feb
1991 04:44 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA12782; Thu, 21 Feb 91
03:42:52 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Thu, 21 Feb 1991 04:45 MST
Date: 20 Feb 91 22:56:22 GMT
From: mintaka!think.com!zaphod.mps.ohio-state.edu!usc!isi.edu!ata.isi.edu!paulp@bloom-beacon.mit.edu
(Paul Postel)
Subject: support for UDFs in compiler?
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <BF542B75E6600D0F@Arizona.edu>
Message-Id: <16842@venera.isi.edu>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: USC-Information Sciences Institute
The icon compiler sounds like just what I need to avoid
optimizing some slow icon software I've written. However
my software depends on some functions added to a personalized
interpreter. Will the compiler support user defined functions?
Paul Postel paulp@isi.edu
USC/Information Sciences Institute
From kwalker Thu Feb 21 13:02:25 1991
Received: from gacham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA24903; Thu, 21 Feb 91 13:02:25 -0700
Date: Thu, 21 Feb 91 13:02:22 MST
From: "Kenneth Walker" <kwalker>
Message-Id: <9102212002.AA08638@gacham.cs.arizona.edu>
Received: by gacham.cs.arizona.edu; Thu, 21 Feb 91 13:02:22 MST
In-Reply-To: <16842@venera.isi.edu>
To: icon-group
Subject: Re: support for UDFs in compiler?
> Date: 20 Feb 91 22:56:22 GMT
>
> Paul Postel paulp@isi.edu:
> The icon compiler sounds like just what I need to avoid
> optimizing some slow icon software I've written. However
> my software depends on some functions added to a personalized
> interpreter. Will the compiler support user defined functions?
The compiler supports user defined functions. However, interpereter
functions must be rewritten for use with the compiler.
Ken Walker / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
+1 602 621-4252 kwalker@cs.arizona.edu {uunet|allegra|noao}!arizona!kwalker
From R.J.Hare@edinburgh.ac.uk Mon Feb 25 10:08:11 1991
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA17831; Mon, 25 Feb 91 10:08:11 -0700
Received: from UKACRL.BITNET (MAILER@UKACRL) by Arizona.edu with PMDF#10282;
Mon, 25 Feb 1991 10:07 MST
Received: from RL.IB by UKACRL.BITNET (Mailer R2.07) with BSMTP id 8633; Mon,
25 Feb 91 16:56:42 GMT
Received: from RL.IB by UK.AC.RL.IB (Mailer R2.07) with BSMTP id 6247; Mon, 25
Feb 91 16:55:47 GMT
Date: 25 Feb 91 16:53:26 gmt
From: R.J.Hare@edinburgh.ac.uk
Subject: Case statement and string scanning
To: icon-group@cs.arizona.edu
Message-Id: <25 Feb 91 16:53:26 gmt 060303@EMAS-A>
X-Envelope-To: icon-group@cs.arizona.edu
Via: UK.AC.ED.EMAS-A; 25 FEB 91 16:53:18 GMT
I have a program in which I repetitively read in a string. According to what
the string contains, I do a variety of things - set up an option, display a
file, execute a system command, etc.
I would like to do this (fairly obviously) in a case statement, but the test I
am carrying out are so varied that I can't quite see how to fit them into a
case statement, for example, I will be doing:
if match("!",string) then...
if match(";",string) then...
if find("*",string) then...
if type(string) == "integer" then...
...some default action...
Any ideas on how I may set this up in a case statement please? Note that
because a string starts with "!", this does not preclude the possibility of it
also including a "*" elsewhere, so I guess a series of simple if statements
won't do the job as in such a circumstance, 2 of the blocks of code would be
executed...
I guess that there is a ridiculously simple answer, but I don't see it yet!
Thanks.
Roger Hare.
From wgg@cs.washington.edu Mon Feb 25 10:52:05 1991
Received: from june.cs.washington.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA19206; Mon, 25 Feb 91 10:52:05 -0700
Received: by june.cs.washington.edu (5.64/7.0jh)
id AA08120; Mon, 25 Feb 91 09:46:17 -0800
Date: Mon, 25 Feb 91 09:46:17 -0800
From: wgg@cs.washington.edu (William Griswold)
Return-Path: <wgg@cs.washington.edu>
Message-Id: <9102251746.AA08120@june.cs.washington.edu>
To: R.J.Hare@edinburgh.ac.uk, icon-group@cs.arizona.edu
Subject: Re: Case statement and string scanning
To handle more general test/action alternatives, I would put the tests and
actions in procedures, store them in pairs in a list, and then iterate over
the tests in the list until success:
record pair(test,action)
...
procedure bangmatch(str)
return match("!",str)
end
...
procedure main(arglist)
case_list := [pair(bangmatch,bangaction),....]
...
if (pr := !case_list).test(string) then
pr.action(string)
...
end
I'm sure there are more elegant solutions, but you get the idea.
bill
From icon-group-request@arizona.edu Tue Feb 26 05:14:48 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA22594; Tue, 26 Feb 91 05:14:48 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Tue, 26 Feb
1991 05:14 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA18264; Tue, 26 Feb 91
04:12:23 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Tue, 26 Feb 1991 05:14 MST
Date: 26 Feb 91 08:26:10 GMT
From: mcsun!cernvax!chx400!chx400!hslrswi!naz@uunet.uu.net (Norman H. Azadian)
Subject: string indexing peculiarity
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <B14113B45A6018B2@Arizona.edu>
Message-Id: <1871@hslrswi.hasler.ascom.ch>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: Hasler AG
Recently I found out the hard way about something I consider to be
an anomaly in string indexing. I consider it an anomaly because
it was, at least for me, totally unexpected. To wit:
s := "-D"
x := (s[3:0] | "default")
"Obviously" accessing the 3rd character in a 2-character string
should fail and x would get the string "default". It turns out,
non-intuitively enough, that I get an empty string, exactly as
if I had tried s[1:1].
Thinking about it, I have to admit that it makes a certain amount
of sense. In fact, it makes a lot of sense when I think about it.
However it was totally unexpected and so I thought I'd mention it
to perhaps help some other hapless soul from falling into the same
pit.
NHA
--
PAPER: Norman Azadian; Ascom AG; Belpstrasse 23; 3000 Berne 14; Switzerland
INTERNET: naz%hslrswi.uucp@uunet.uu.net
UUCP: ...{uunet,ukc,mcvax,...}!chx400!hslrswi!naz
VOICE: +41 31 63 2178 BITNET: naz%hslrswi.UUCP@cernvax.BITNET
From goer%sophist@gargoyle.uchicago.edu Tue Feb 26 08:49:36 1991
Resent-From: goer%sophist@gargoyle.uchicago.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA06727; Tue, 26 Feb 91 08:49:36 -0700
Return-Path: goer@sophist.uchicago.edu
Received: from gargoyle.uchicago.edu by Arizona.edu with PMDF#10282; Tue, 26
Feb 1991 08:47 MST
Received: by gargoyle.uchicago.edu from sophist (sophist.uchicago.edu)
(4.0/1.14) id AA14715; Tue, 26 Feb 91 09:47:44 CST
Received: by sophist (4.1/UofC3.1X) id AA09774; Tue, 26 Feb 91 09:50:05 CST
Resent-Date: Tue, 26 Feb 1991 08:48 MST
Date: Tue, 26 Feb 91 09:50:05 CST
From: Richard Goerwitz <goer%sophist@gargoyle.uchicago.edu>
Subject: RE: string indexing peculiarity
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <CF1714D62A601ABC@Arizona.edu>
Message-Id: <9102261550.AA09774@sophist>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Recently I found out the hard way about something I consider to be
an anomaly in string indexing. I consider it an anomaly because
it was, at least for me, totally unexpected. To wit:
s := "-D"
x := (s[3:0] | "default")
"Obviously" accessing the 3rd character in a 2-character string
should fail and x would get the string "default". It turns out,
non-intuitively enough, that I get an empty string, exactly as
if I had tried s[1:1].
Icon's string indexing methods are definitely non-intuitive for people
who acquire it as a second, third, etc. language (which means virtually
everyone). I guess the idea that people need to catch on to is that
subscripts deal with string positions, and not the index of characters
within strings. What throws people off is that s[3] would work as in
some other languages (producing the third character in s). In reality,
though, this is shorthand in Icon for s[3+:1], i.e. s[3:4].
Of course, if we want to talk about unintuitive schemes, let's not for-
get languages where s[0] indexes the _first_ array element in s.
s := "-D"
s ? { x := move(3) | "default" }
s := "-D"
s ? { x := (tab(-3), tab(0)) | "default" }
s := "-D"
x := ("" ~== s[3:0]) | "default"
-Richard (goer@sophist.uchicago.edu)
From R.J.Hare@edinburgh.ac.uk Tue Feb 26 11:39:03 1991
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA12783; Tue, 26 Feb 91 11:39:03 -0700
Received: from UKACRL.BITNET (MAILER@UKACRL) by Arizona.edu with PMDF#10282;
Tue, 26 Feb 1991 11:37 MST
Received: from RL.IB by UKACRL.BITNET (Mailer R2.07) with BSMTP id 6819; Tue,
26 Feb 91 12:24:31 GMT
Received: from RL.IB by UK.AC.RL.IB (Mailer R2.07) with BSMTP id 2731; Tue, 26
Feb 91 12:24:31 GMT
Date: 26 Feb 91 12:24:40 gmt
From: R.J.Hare@edinburgh.ac.uk
Subject: Case statements and string scanning
To: icon-group@cs.arizona.edu
Message-Id: <26 Feb 91 12:24:40 gmt 060488@EMAS-A>
X-Envelope-To: icon-group@cs.arizona.edu
Via: UK.AC.ED.EMAS-A; 26 FEB 91 12:24:28 GMT
Thanks to those who replied.
The method involving paired tests and operations seems an intersting idea, I
shall certainly try it out when I get a chance.
RGs comments on the use of if statements highlight the 'problem'. If I do
if expr1 then ...
if expr2 then ...
if expr3 then ...
obviously with varied 'expr's, I could have more than one block of code being
executed when I only want one. The alternative:
if expr1
then ...
else if expr2
then ...
else if expr3
then ...
else ...
is fine but awful hard to read (which is the part I am unhappy about). What is
really needed is something like the Fortran ELSEIF construct:
IF (test1) THEN
.
ELSEIF (test2) THEN
.
ELSEIF (test3) THEN
.
ELSE
.
ENDIF
which is only a case statement with a different hat on.
Is there such a thing in Icon (ie: have I missed it?). Should there be?
Roger Hare.
From wgg@cs.washington.edu Tue Feb 26 12:14:07 1991
Received: from june.cs.washington.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA14080; Tue, 26 Feb 91 12:14:07 -0700
Received: by june.cs.washington.edu (5.64/7.0jh)
id AA04472; Tue, 26 Feb 91 11:11:27 -0800
Date: Tue, 26 Feb 91 11:11:27 -0800
From: wgg@cs.washington.edu (William Griswold)
Return-Path: <wgg@cs.washington.edu>
Message-Id: <9102261911.AA04472@june.cs.washington.edu>
To: R.J.Hare@edinburgh.ac.uk, icon-group@cs.arizona.edu
Subject: Re: Case statements and string scanning
No, there is no ELSEIF in Icon. However, I indent my IF THEN ELSE's
differently to allow a more tabular appearance:
if t1 then
e1
else if t2 then
e2
else if t3 then
e3
else
e4
I don't find this confusing to interpret at all.
bill
From @um.cc.umich.edu:Paul_Abrahams@MTS.cc.Wayne.edu Tue Feb 26 13:41:31 1991
Received: from umich.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA16808; Tue, 26 Feb 91 13:41:31 -0700
Received: from um.cc.umich.edu by umich.edu (5.61/1123-1.0)
id AA15072; Tue, 26 Feb 91 15:40:08 -0500
Received: from MTS.cc.Wayne.edu by um.cc.umich.edu via MTS-Net; Tue, 26 Feb 91 15:37:36 EST
Date: Tue, 26 Feb 91 15:37:36 EST
From: Paul_Abrahams@MTS.cc.Wayne.edu
To: icon-group@cs.arizona.edu
Message-Id: <301677@MTS.cc.Wayne.edu>
Subject: String indexing
In my design of SPLASH I've used the Icon approach to string indexing
virtually unchanged. Imitation is the sincerest form of flattery.
Paul Abrahams
From icon-group-request@arizona.edu Fri Mar 1 16:07:52 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA08978; Fri, 1 Mar 91 16:07:52 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Fri, 1 Mar
1991 16:07 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA26804; Fri, 1 Mar 91 14:57:01
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Fri, 1 Mar 1991 16:07 MST
Date: 1 Mar 91 21:56:12 GMT
From: meaddata!pulse@uunet.uu.net (Tom Hesley)
Subject: Computer Language Books FOR SALE ! ! !
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <67FB79C6D2603215@Arizona.edu>
Message-Id: <3118@meaddata.meaddata.com>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: Mead Data Central, Dayton OH
Got some computer language books for sale. They are:
SCRIBE Pocket Reference UnuLogic $1
Programming in Prolog W. F. Clocksin
C. S. Mellish $15
PostScript Language Reference Adobe Systems Inc. $15
Manual
(Includes detailed programming information on the Laserwriter)
PostScript Language Tutorial and Cookbook $15
Adobe Systems Inc.
PostScript Language Program Design $15
Adobe Systems Inc.
Modula 2 Discipline and Design Arthur Sale $10
Icon Programming Language Ralph Griswold $10
Madge T. Griswold
Ada -- An Advanced Introduction Narain Gehani $10
Structured FORTRAN 77 for Engineers and Scientists $10
D. M. Etter
FORTRAN 77 Loren P. Meissner $5
Elliot I. Organick
Computer Organization and Programming for the VAX-11 $10
(VAX Assembler) Souhail El-Asfouri
Olin Johnson
Willis K. King
VAX-11 Assembly Language Programming $10
Sarah Baase
An Introduction to Numerical Methods with Pascal $10
L. V. Atkinson
P. J. Harley
Will listen to package deals. You pay shipping and COD charges.
Will only ship COD.
--
Tom Hesley Opinions expressed within (513) 865-7053
Mead Data Central are my own and not Systems Development
P.O. Box 933 necessarily those of pulse@meaddata.com
Dayton, Ohio 45401 Mead Data Central ...!uunet!meaddata!pulse
From uunet!men2a!aquin!luvthang!talmage Fri Mar 1 16:39:50 1991
Received: from univers.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA09912; Fri, 1 Mar 91 16:39:50 -0700
Received: from uunet.UUCP by univers.cs.arizona.edu; Fri, 1 Mar 91 16:39:48 MST
Received: from men2a.UUCP by uunet.UU.NET with UUCP
(5.61/UUNET-primary-gateway) id AA29953; Wed, 27 Feb 91 13:06:09 -0500
Received: by men2a.ori-cal.com (smail2.5)
id AA01645; 27 Feb 91 12:09:53 EST (Wed)
Received: by aquin.uucp (smail2.5)
id AA18151; 27 Feb 91 13:01:54 EST (Wed)
Received: by luvthang.aquin.ori-cal.com (1.05D/Amiga)
id AA01743; Wed, 27 Feb 91 07:47:12 EST
Date: Wed, 27 Feb 91 07:47:12 EST
Message-Id: <9102271247.AA01743@luvthang.aquin.ori-cal.com>
From: uunet!luvthang.aquin.ori-cal.com!talmage (David W. Talmage)
To: arizona!icon-group
Subject: Re: Case statements and string scanning
:is fine but awful hard to read (which is the part I am unhappy about). What is
:really needed is something like the Fortran ELSEIF construct:
:
:IF (test1) THEN
: .
:ELSEIF (test2) THEN
: .
:ELSEIF (test3) THEN
: .
:ELSE
: .
:ENDIF
:
:which is only a case statement with a different hat on.
How about using ipp, the Icon Pre-Processor that comes with the Icon
Program Library? You could do something like this:
$define IF(x) if x
$define THEN {
$define ELSEIF(x) } else if (x) {
$define ELSE } {
$define ENDIF }
IF (test1) THEN
.
ELSEIF (test2) THEN
.
ELSEIF (test3) THEN
.
ELSE
.
ENDIF
-----------------------------------------------------------------------------
David W. Talmage (talmage@luvthang.aquin.ori-cal.com)
"I need fifty dollars to make you hollar. I get paid to run this luvthang."
From icon-group-request@arizona.edu Sat Mar 2 17:02:42 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA24724; Sat, 2 Mar 91 17:02:42 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Sat, 2 Mar
1991 17:02 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA07046; Sat, 2 Mar 91 15:55:42
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Sat, 2 Mar 1991 17:02 MST
Date: 2 Mar 91 17:50:36 GMT
From: pyramid!tekbspa!yost@hplabs.hpl.hp.com (Dave Yost)
Subject: ideas from the icon language applied to scheme
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <38CDC78D4260351A@Arizona.edu>
Message-Id: <1991Mar2.175036.24463@tss.com>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: Teknekron Software Systems, Inc.
Has anyone implemented any of icon's great features in scheme?
Seems to me to be a reasonable idea.
--dave yost
From icon-group-request@arizona.edu Sat Mar 2 21:02:37 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA00236; Sat, 2 Mar 91 21:02:37 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Sat, 2 Mar
1991 21:02 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA16467; Sat, 2 Mar 91 19:51:22
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Sat, 2 Mar 1991 21:02 MST
Date: 3 Mar 91 01:39:12 GMT
From: midway!ellis.uchicago.edu!goer@handies.ucar.edu (Richard L. Goerwitz)
Subject: RE: ideas from the icon language applied to scheme
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <5A5413453260272C@Arizona.edu>
Message-Id: <1991Mar3.013912.14857@midway.uchicago.edu>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: University of Chicago
References: <1991Mar2.175036.24463@tss.com>
Regarding Dave Yost's question about implementing Iconish features in
Scheme:
It's hard to respond to such a question without knowing what you have
in mind. For instance, if you are interested in backtracking,
then I doubt you could move the Icon mechanisms to Scheme, with all
its limitation expressions, goal-directed evaluation, and what not.
String scanning is a bit less difficult. At some point, though, I'd
begin to wonder whether it was easier just to cut Icon code.
What is it about Scheme in particular that make it a more attractive
basis for your intended application? Just curious.
-Richard
From icon-group-request@arizona.edu Sat Mar 2 22:18:04 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA02027; Sat, 2 Mar 91 22:18:04 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Sat, 2 Mar
1991 22:17 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA17819; Sat, 2 Mar 91 21:05:25
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Sat, 2 Mar 1991 22:17 MST
Date: 3 Mar 91 04:44:47 GMT
From: magnus.ircc.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!cs.utexas.edu!ut-emx!ccwf.cc.utexas.edu@tut.cis.ohio-state.edu (David Boles)
Subject: MIT scheme on Silicon Graphics
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <64DAB9228260343D@Arizona.edu>
Message-Id: <44998@ut-emx.uucp>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: The University of Texas at Austin
References: <1991Mar2.175036.24463@tss.com>,
<1991Mar3.013912.14857@midway.uchicago.edu>
Has anyone out there put MIT Scheme on a Silicon Graphics machine (4D)?
I just got a 4D/310 and it will be my prime computing resource for
the next year or so; I'm interested in putting the environment on it.
Any help is welcome.
Note: I haven't tried it yet, but the distribution doesn't mention
SGI machines at all.
David Boles
apas611@hermes.chpc.utexas.edu
--
-------------------------------------------------------------------------------
David Boles Applied Research Laboratories
dboles@ccwf.cc.utexas.edu DOS is severely brain-damaged,
apas611@chpc.utexas.edu so just pull the plug and let it DIE.
-------------------------------------------------------------------------------
From icon-group-request@arizona.edu Mon Mar 4 15:07:04 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA18662; Mon, 4 Mar 91 15:07:04 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Mon, 4 Mar
1991 15:06 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA10200; Mon, 4 Mar 91 13:58:57
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Mon, 4 Mar 1991 15:06 MST
Date: 4 Mar 91 18:58:19 GMT
From: tekbspa!tss.com!yost@uunet.uu.net (Dave Yost)
Subject: RE: ideas from the icon language applied to scheme
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <BAFC46AF6260372E@Arizona.edu>
Message-Id: <1991Mar4.185819.19587@tss.com>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: Teknekron Software Systems, Inc.
References: <1991Mar2.175036.24463@tss.com>,
<1991Mar3.013912.14857@midway.uchicago.edu>
In article <1991Mar3.013912.14857@midway.uchicago.edu>, goer@ellis.uchicago.edu (Richard L. Goerwitz) writes:
|> What is it about Scheme in particular that make it a more attractive
|> basis for your intended application? Just curious.
* The fact that it can execute a string containing source code.
* The fact there are scheme implementations that seem to be more
easily assimilated into a C environment.
Also, I'm learning scheme partly just because I'm interested in it
and because I'm reading the Abelson & Sussman(s) book.
I'd rather use Icon-style expression evaluation, and it seemed
that scheme could easily accomodate that.
--dave yost
From icon-group-request@arizona.edu Mon Mar 4 16:40:21 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA22239; Mon, 4 Mar 91 16:40:21 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Mon, 4 Mar
1991 16:39 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA12920; Mon, 4 Mar 91 15:31:51
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Mon, 4 Mar 1991 16:40 MST
Date: 4 Mar 91 22:57:07 GMT
From: sdd.hp.com!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!midway!ellis.uchicago.edu!goer@ucsd.edu (Richard
L. Goerwitz)
Subject: RE: ideas from the icon language applied to scheme
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <C8057EFE426035C3@Arizona.edu>
Message-Id: <1991Mar4.225707.12864@midway.uchicago.edu>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: University of Chicago
References: <1991Mar2.175036.24463@tss.com>,
<1991Mar3.013912.14857@midway.uchicago.edu>, <1991Mar4.185819.19587@tss.com>
In article <1991Mar4.185819.19587@tss.com> yost@tss.COM writes:
>|> What is it about Scheme in particular that make it a more attractive
>|> basis for your intended application? Just curious.
>
>* The fact that it can execute a string containing source code.
>* The fact there are scheme implementations that seem to be more
> easily assimilated into a C environment.
The fact that Icon isn't interpreted per se does get in the way of
Icon code executing code. Everything has to be compiled, either
into an icode file (geared for a virtual machine implemented by an
interpreter) or else into C code (as with Ken Walker's compiler).
As if the Icon Project didn't have enough to do already, it might
be nice to have an Icon interpreter (in the interactive, rather
than "virtual machine" sense).
I guess, though, that the fundamental code/data unity of Lisp and
Prolog really isn't part of the Icon paradigm (although you can
get some of the same functionality by judicious application of the
IPL codeobj procedure).
The C <-> Icon interoperability issue is interesting. You can create
personalized interpreters and translators, if you simply want addi-
tional built-in functions. If it's access to C functions that you
want, you can use the callout() function, which lets you call C
functions from Icon. With the compiler, it's even easier to call
C code, although I don't think the technical document explaining
precisely how has been put online yet.
I'd say that the major disadvantage to using Icon code is that the
programmer is completely hamstrung when it comes to low-level inter-
action with the operating system. Icon is meant to be very, very
portable, and it's counter to the spirit of its implementation to,
say, give you, a fork(), wait(), and exec(). You can get these
via callout(), I guess. But it would not be elegant. The compiler
should rectify this, though, since it allows you to add C code in-
line.
If you knew about all of this callout() (interpreter) and inline
(compiler) stuff, then I apologize. I figure there are others out
there asking the same sorts of questions, though, and that it is
worth posting a reply. It's also worth reminding people about some
of the many gems included in the IPL (the adjunct library that
comes with the full Icon distribution). Codeobj is one of them.
-Richard
From cjeffery Mon Mar 4 17:16:35 1991
Resent-From: "Clinton Jeffery" <cjeffery>
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA23771; Mon, 4 Mar 91 17:16:35 -0700
Received: from megaron.cs.arizona.edu (128.196.128.118) by Arizona.edu with
PMDF#10282; Mon, 4 Mar 1991 17:16 MST
Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15)
via SMTP id AA23750; Mon, 4 Mar 91 17:16:01 -0700
Received: by cheltenham.cs.arizona.edu; Mon, 4 Mar 91 17:15:59 MST
Resent-Date: Mon, 4 Mar 1991 17:16 MST
Date: Mon, 4 Mar 91 17:15:59 MST
From: Clinton Jeffery <cjeffery@cs.arizona.edu>
Subject: ideas from the icon language applied to scheme
In-Reply-To: Richard L. Goerwitz's message of 4 Mar 91 22:57:07 GMT
<1991Mar4.225707.12864@midway.uchicago.edu>
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <CD1617DB526035A9@Arizona.edu>
Message-Id: <9103050015.AA21315@cheltenham.cs.arizona.edu>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
>In response to people comparing Scheme and Icon, Richard notes that:
>The fact that Icon isn't interpreted per se does get in the way of
>Icon code executing code.
Icon's virtual machine architecture does not rule out a true
interpreter. For instance, most implementations of the SmallTalk
language use a virtual machine, but the SmallTalk environment comes
with an interpreter. A SmallTalk guru could provide some useful
suggestions in this discussion, I think.
A by-product of my own research this year is a "multi-program interpreter",
a version of iconx that allows mulitple icon programs to be loaded into a
single execution of the virtual machine. This would allow further
improvements to the kind of "Icon interpreter written in Icon" programs
that were posted last year by various members of this group.
From DSMOLARSKI@SCUACC.SCU.EDU Mon Mar 4 18:05:02 1991
Received: from SCUACC.SCU.EDU by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA25361; Mon, 4 Mar 91 18:05:02 -0700
Date: Mon, 4 Mar 1991 17:02 PST
From: "Dennis C. Smolarski, S.J." <DSMOLARSKI@SCUACC.SCU.EDU>
Subject: icon on VMS 5.4
To: icon-group@cs.arizona.edu
Message-Id: <CB30F5C080004161@SCU.BITNET>
X-Envelope-To: icon-group@cs.arizona.edu
X-Vms-To: IN%"icon-group@cs.arizona.edu"
Has anyone installed the VMS backup version of ICON on a VAX running
VMS 5.4?
The scripts for correcting an FTP'd file don't quite work with VMS 5.4.
Thanks for any suggestions.
Dennis Smolarski
Santa Clara University
Dept. of Mathematics
Santa Clara CA
DSMOLARSKI@SCU.BITNET
From gmt Mon Mar 4 18:55:09 1991
Received: from owl.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA26889; Mon, 4 Mar 91 18:55:09 -0700
Date: Mon, 4 Mar 91 18:55:05 MST
From: "Gregg Townsend" <gmt>
Message-Id: <9103050155.AA14246@owl.cs.arizona.edu>
Received: by owl.cs.arizona.edu; Mon, 4 Mar 91 18:55:05 MST
To: icon-group
Subject: Re: icon on VMS 5.4
As far as I know the VMSFIX script works under VMS 5.4, though until very
recently the comments were misleading and implied that it wouldn't.
Did you actually try it, or did you just believe what it told you :-) ?
It does need a big file quota, bigger than I have at the moment, so when I
retested it just now (VMS V5.4-1) I had to test with a different BACKUP file.
Gregg Townsend / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
+1 602 621 4325 gmt@cs.arizona.edu 110 57 16 W / 32 13 45 N / +758m
From TENAGLIA@mis3.mis.mcw.edu Tue Mar 5 17:51:42 1991
Received: from mis3.mis.mcw.edu ([141.106.64.13]) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA21376; Tue, 5 Mar 91 17:51:42 -0700
Date: Tue, 5 Mar 1991 18:51 CST
From: Chris Tenaglia - 257-8765 <TENAGLIA@mis3.mis.mcw.edu>
Subject: Re: icon on VMS 5.4
To: DSMOLARSKI@SCUACC.SCU.EDU
Cc: icon-group@cs.arizona.edu
Message-Id: <A39A02D1C0602DC2@mis3.mis.mcw.edu>
X-Organization: Medical College of Wisconsin MIS Department (Milwaukee, WI)
X-Vms-To: IN%"DSMOLARSKI@SCUACC.SCU.EDU"
X-Vms-Cc: IN%"icon-group@cs.arizona.edu"
Regarding: icon on VMS 5.4
> Has anyone installed the VMS backup version of ICON on a VAX running
> VMS 5.4?
> The scripts for correcting an FTP'd file don't quite work with VMS 5.4.
> Thanks for any suggestions.
> Dennis Smolarski
> Santa Clara University
> Dept. of Mathematics
> Santa Clara CA
> DSMOLARSKI@SCU.BITNET
I have icon running quite well under VMS 5.4 on a microvax 3100. I happen
to have it on mag tape. For FTPing the saveset, a lot depends on the TCP/IP
package running under VMS. We have CMU/TEK and TGV MULTINET and the FTP
has a file type command used to pass VMS specific information. I believe
the command is TYPE IMAGE (MULTINET) or SET TYPE IMAGE (CMU/TEK) will work
from the FTP> prompt. I haven't actually tried the ICON saveset, but I've
used it successfully between my hosts.
Chris Tenaglia (System Manager) | Medical College of Wisconsin
8701 W. Watertown Plank Rd. | Milwaukee, WI 53226
(414)257-8765 | tenaglia@mis.mcw.edu, mcwmis!tenaglia
From icon-group-request@arizona.edu Wed Mar 6 08:22:33 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA17602; Wed, 6 Mar 91 08:22:33 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Wed, 6 Mar
1991 08:21 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA28369; Wed, 6 Mar 91 07:12:05
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Wed, 6 Mar 1991 08:22 MST
Date: 5 Mar 91 12:32:24 GMT
From: mcsun!ukc!mucs!m1!bevan@uunet.uu.net (Stephen J Bevan)
Subject: Which to use :- Perl, Python, Icon, ... ?
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <14CCAB6C4260463E@Arizona.edu>
Message-Id: <BEVAN.91Mar5123224@tiger.cs.man.ac.uk>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: Department of Computer Science, University of Manchester
In the past I've written various programs to extract information from
files. To do this I've used :- Common Lisp, Emacs Lisp, awk, sh, ksh
and csh. As this is a bit of nightmare as regards maintenance, I'd
like to move to a single language for doing these sort of tasks. The
likely contenders for this seem to be Perl, Python and Icon.
Rather than FTP all of them and wade through the documentation, I was
wondering if anybody has experiences with them that they'd like to
share?
I'm particularly interested in comments from people who have used (or
at least looked at) more than one of them.
As a guide to the sort of things I'm interested in :-
+ Does the language have any arbitrary limits? e.g. the length of a
line ... etc.
+ How fast is it? This can be compared to whatever you like, but each
other preferably. I'm not really interested if XXX is only, X%
quicker than YYY on average (whatever that maybe).
+ Does it give `reasonable' error messages? i.e. something better
than the equivalent of `awk bailing out on line X'.
+ Does it have a debugger? If not, are there any extra facilities
for debuggging above and beyond simply inserting `printf' (change
as appropriate) statements.
+ Does it allow conditional interpretation/compilation? i.e.
anything like +FEATURE in Lisp or #ifdef FEATURE/#endif in C.
Some other points to note :-
+ The scripts won't be distributed, so arguments about XXX is
installed on more machines than YYY aren't relevant.
+ The fact that Perl has a C like syntax is NOT an advantage in my
book. (I'm not saying its a disadvantage either, I just don't
think it's important either way).
email/post as you think is appropriate (note the followup to
comp.lang.misc). I will summarize email replies after a suitable period.
Thanks in advance,
Stephen J. Bevan bevan@cs.man.ac.uk
From icon-group-request@arizona.edu Thu Mar 7 09:31:55 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA00600; Thu, 7 Mar 91 09:31:55 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Thu, 7 Mar
1991 09:31 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA08815; Thu, 7 Mar 91 08:24:18
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Thu, 7 Mar 1991 09:31 MST
Date: 7 Mar 91 15:47:13 GMT
From: acf5!mitsolid@nyu.edu (Thanasis Mitsolides)
Subject: A
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <E7A8EB5CB2604B3E@Arizona.edu>
Message-Id: <1532@acf5.NYU.EDU>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: New York University
A
--
-------------------------------------------------------------------------------
Internet: mitsolid@cs.nyu.edu (mitsolid%cs.nyu.edu@relay.cs.net)
UUCP : ...!uunet!cmcl2!cs!mitsolid
-------------------------------------------------------------------------------
From icon-group-request@arizona.edu Thu Mar 7 09:32:10 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA00619; Thu, 7 Mar 91 09:32:10 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Thu, 7 Mar
1991 09:31 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA08826; Thu, 7 Mar 91 08:24:33
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Thu, 7 Mar 1991 09:31 MST
Date: 7 Mar 91 15:54:45 GMT
From: acf5!mitsolid@nyu.edu (Thanasis Mitsolides)
Subject: A
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <E7B2742872603B3F@Arizona.edu>
Message-Id: <1535@acf5.NYU.EDU>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: New York University
cd
--
-------------------------------------------------------------------------------
Internet: mitsolid@cs.nyu.edu (mitsolid%cs.nyu.edu@relay.cs.net)
UUCP : ...!uunet!cmcl2!cs!mitsolid
-------------------------------------------------------------------------------
From icon-group-request@arizona.edu Thu Mar 7 18:18:18 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA28844; Thu, 7 Mar 91 18:18:18 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Thu, 7 Mar
1991 18:16 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA25123; Thu, 7 Mar 91 17:04:40
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Thu, 7 Mar 1991 18:17 MST
Date: 8 Mar 91 00:58:52 GMT
From: iris!williamh@ucdavis.ucdavis.edu (Heather Blanchard)
Subject: RE: ideas from the icon language applied to scheme
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <3127F7E392604513@Arizona.edu>
Message-Id: <8507@ucdavis.ucdavis.edu>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: U.C. Davis - Dept. of Electrical Engineering and Computer Science
In article <1991Mar4.225707.12864@midway.uchicago.edu> goer@ellis.uchicago.edu
(Richard L. Goerwitz) writes:
>As if the Icon Project didn't have enough to do already, it might
>be nice to have an Icon interpreter (in the interactive, rather
>than "virtual machine" sense).
Just thought I would let you know:
An interactive Icon interpreter is what I am currently working on for
my Master's Thesis. I am merging the source code for the translator
and executor, icont & iconx, into a single program, iconi, which will
translate, link, and execute single Icon expressions interactively. I
have already done some of the work, but have quite a bit left.
If anyone is interested in the interpreter, please let me know and I
will let you know when I have finished my work.
Heather
From icon-group-request@arizona.edu Fri Mar 8 19:51:03 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA20689; Fri, 8 Mar 91 19:51:03 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Fri, 8 Mar
1991 19:50 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA02473; Fri, 8 Mar 91 18:40:29
-0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Fri, 8 Mar 1991 19:50 MST
Date: 7 Mar 91 15:24:55 GMT
From: mvb.saic.com!ncr-sd!ncrcae!hubcap!fpst@ucsd.edu (Thanasis Mitsolides)
Subject: ALLOY: parallel and higher level.
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <0753B90A52604910@Arizona.edu>
Message-Id: <1991Mar7.202850.27650@hubcap.clemson.edu>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: New York University
This is to announce the availability of
the interpreter, manual and examples for the programming language ALLOY.
ALLOY is high level, parallel, flexible and more than reasonably efficient.
ALLOY combines serial/parallel ev., eager/lazy ev., single/multiple solutions
and parallel object oriented programming in a remarkably simple framework.
Example programs ready for execution include:
1) factorial, partition sort, FP (highly parallel)
2) fibonacci sequence, prime numbers (eager or lazy)
3) systolic sort, hamming network (clear flow of data)
4) list member, tree leave, list permutation, n queens (multiple solutions)
5) queue, stack, faa, semaphores, dinning philosophers (objects)
6) prolog package, prolog/parlog programming styles (flexibility)
Part of ALLOY is explained in:
[MH90] Thanasis Mitsolides and Malcolm Harrison. Generators and the
replicator control structure in the parallel environment of ALLOY.
In ACM SIGPLAN '90 Conference on Programming Language Design and
Implementation, pages 189--196, White Plains, New York, June 1990.
The abstract of the ALLOY manual is appended at the end of this message.
The sources, manual, example programs and benchmarks of ALLOY are available
for anonymous FTP from cs.nyu.edu (128.122.140.24)
I hope you will find ALLOY interesting.
I will be glad to answer your comments!
Thank you,
Thanasis
===============================================================================
ABSTRACT
ALLOY is a higher level parallel programming language appropriate
for programming massively parallel computing systems. It is based
on a combination of ideas from functional, object oriented and
logic programming languages.
The result being a language that can directly support functional,
object oriented and logic programming styles in a unified and
controlled framework. Evaluating modes support serial or parallel
execution, eager or lazy evaluation, non-determinism or multiple
solutions etc. ALLOY is simple as it only requires 31 primitives
in all (half of which for Object Oriented Programming support).
This article, starts with a formal definition of the small ALLOY
kernel proceeds with the definition of some useful libraries and
concludes with examples which demonstrate its expressiveness and
clarity.
Programming language ALLOY is located on system spunky.cs.nyu.edu
directory ~mitsolid/alloy. This article can be found in dvi and
ascii form on subdirectory doc, The examples presented can be
found in subdirectory progs. The interpreter is executable file
alloy. All the above and the sources of the ALLOY interpreter are
available for anonymous ftp on system cs.nyu.edu directory
pub/local/alloy.
-------------------------------------------------------------------------------
Internet: mitsolid@cs.nyu.edu (mitsolid%cs.nyu.edu@relay.cs.net)
UUCP : ...!uunet!cmcl2!cs!mitsolid
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
Internet: mitsolid@cs.nyu.edu (mitsolid%cs.nyu.edu@relay.cs.net)
UUCP : ...!uunet!cmcl2!cs!mitsolid
-------------------------------------------------------------------------------
--
-------------------------------------------------------------------------------
Internet: mitsolid@cs.nyu.edu (mitsolid%cs.nyu.edu@relay.cs.net)
UUCP : ...!uunet!cmcl2!cs!mitsolid
-------------------------------------------------------------------------------
--
=========================== MODERATOR ==============================
Steve Stevenson {steve,fpst}@hubcap.clemson.edu
Department of Computer Science, comp.parallel
Clemson University, Clemson, SC 29634-1906 (803)656-5880.mabell
From jyelon@cs.uiuc.edu Sun Mar 10 13:52:16 1991
Received: from herodotus.cs.uiuc.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA28436; Sun, 10 Mar 91 13:52:16 -0700
Received: by herodotus.cs.uiuc.edu
(5.62+/IDA-1.2.8) id AA14599; Sun, 10 Mar 91 14:51:46 -0600
Date: Sun, 10 Mar 91 14:51:46 -0600
From: Josh Yelon <jyelon@cs.uiuc.edu>
Message-Id: <9103102051.AA14599@herodotus.cs.uiuc.edu>
To: icon-group@cs.arizona.edu
Subject: C-Icon interface
I'm using the new Icon compiler, but 'callout' doesn't seem to be
present. I need to be able to call the unix system libraries (to do
some hairy network protocol stuff). I'm willing to learn the format
of "rt.db" and add my own code to "rt.a", if necessary.
Any ideas? - Josh
From icon-group-request@arizona.edu Thu Mar 14 09:57:10 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu ([128.196.128.231]) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA07815; Thu, 14 Mar 91 09:57:10 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Thu, 14 Mar
1991 09:56 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA01573; Thu, 14 Mar 91
08:43:14 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Thu, 14 Mar 1991 09:56 MST
Date: 12 Mar 91 14:25:47 GMT
From: mcsun!cernvax!chx400!chx400!hslrswi!naz@uunet.uu.net (Norman H. Azadian)
Subject: alternation surprise
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <6B58F583FC6013A9@Arizona.edu>
Message-Id: <1899@hslrswi.hasler.ascom.ch>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: Hasler AG
I know my postings are starting to sound like an idiot's tour
of Icon. Anyway, here's another "gotcha" I stumbled over.
procedure main()
local flag, x
flag := 1
(\flag) | (x := runerr(500))
(\flag) | x := runerr(500)
end
This dies on line 5, which I did not expect. I guess alternation
has lower priority than assignment. Pardon me while I go out and
stock up on parenthesis.
NHA
--
PAPER: Norman Azadian; Ascom AG; Belpstrasse 23; 3000 Berne 14; Switzerland
INTERNET: naz%hslrswi.uucp@uunet.uu.net
UUCP: ...{uunet,ukc,mcvax,...}!chx400!hslrswi!naz
VOICE: +41 31 63 2178 BITNET: naz%hslrswi.UUCP@cernvax.BITNET
From icon-group-request@arizona.edu Thu Mar 14 10:44:58 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu ([128.196.128.231]) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA09033; Thu, 14 Mar 91 10:44:58 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Thu, 14 Mar
1991 10:44 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA04220; Thu, 14 Mar 91
09:34:25 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Thu, 14 Mar 1991 10:44 MST
Date: 12 Mar 91 23:55:58 GMT
From: midway!quads.uchicago.edu!goer@uunet.uu.net (Richard L. Goerwitz)
Subject: RE: alternation surprise
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <7207D251EC60151A@Arizona.edu>
Message-Id: <1991Mar12.235558.1542@midway.uchicago.edu>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: University of Chicago
References: <1899@hslrswi.hasler.ascom.ch>
Na@hslrswi.hasler.ascom.ch (Norman H. Azadian) writes:
>I know my postings are starting to sound like an idiot's tour
>of Icon.
If you want a real laugh, try taking a look at icon-group traffic
from, say, three years or so ago (when I was still just learning the
language). The archives are on cs.arizona.edu (much to my chagrin
:-).
>
> procedure main()
> local flag, x
> flag := 1
> (\flag) | (x := runerr(500))
> (\flag) | x := runerr(500)
> end
>
>This dies on line 5, which I did not expect. I guess alternation
>has lower priority than assignment. Pardon me while I go out and
>stock up on parenthesis.
My golden rule, for a long time , was "conjunction has the lowest prece-
of any infix operation." Everything else I parenthesized.
You may find that the precedence of alternation makes more sense if you
think of the very common idiom -
intext :=open(\filename) | &input
-Richard
From icon-group-request@arizona.edu Thu Mar 14 13:42:32 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu ([128.196.128.231]) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA12449; Thu, 14 Mar 91 13:42:32 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Thu, 14 Mar
1991 13:41 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA12230; Thu, 14 Mar 91
12:26:47 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Thu, 14 Mar 1991 13:42 MST
Date: 12 Mar 91 20:04:03 GMT
From: hsi!mlfarm!ron@uunet.uu.net (Ronald Florence)
Subject: pipe opens
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <8ACF86F7AC600E35@Arizona.edu>
Message-Id: <772@mlfarm.com>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: Maple Lawn Farm, Stonington, CT
I can't get this bit of code to work:
procedure main()
write(pipe("bogus-command", "nonsense", "logname"))
end
procedure pipe(cmd[])
until inf := open(pop(cmd), "pr")
got := !inf
close(inf)
return got
end
The idea is to try opening a pipe to a series of commands until one
succeeds. It doesn't work (at least here), because instead of the
open() failing on "bogus-command" and "nonsense", the shell reports
that the command wasn't found.
Any idea how to do what I want to do?
--
Ronald Florence ron@mlfarm.com
From icon-group-request@arizona.edu Thu Mar 14 19:30:15 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA19629; Thu, 14 Mar 91 19:30:15 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Thu, 14 Mar
1991 19:29 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA28569; Thu, 14 Mar 91
18:22:32 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Thu, 14 Mar 1991 19:29 MST
Date: 13 Mar 91 14:44:00 GMT
From: sam.cs.olemiss.edu!hcc@cs.duke.edu (Conrad Cunningham)
Subject: Use of Icon in Support of Coursework??
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <BB681B05DC601810@Arizona.edu>
Message-Id: <1991Mar13.144400.20767@cs.olemiss.edu>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: University of Mississippi, Dept. of Computer Science
A question for academics who use Icon in support of undergraduate- or
graduate-level courses: In what kinds of courses, at what levels, and
in what ways is Icon used in support of teaching--particularly in
computing science? What are the advantages/disadvantages to use of
Icon in comparison to other languages? What are the available
textbooks?
Motivation for question: most of the coursework in my department uses
Pascal, C, or Ada for laboratory exercises. Since joining this
department two years ago I have been looking for appropriate ways to
broaden our students "exposure" to different styles, paradigms, and
approaches to programming. For example, I've developed or am
developing elective courses in program derivation, functional
programming (lazy), and concurrent programming. I was just wondering
what place Icon has in existing or potentially new courses.
Thanks,
-------------------------------------------------------------------------------
H. Conrad Cunningham | Dept. of Computer & Info. Sci., Univ. of Mississippi
Tel: (601) 232-5358 | 302 Weir Hall, University, MS 38677 U.S.A.
Fax: (601) 232-7010 | Email: cunningham@cs.olemiss.edu
-------------------------------------------------------------------------------
From icon-group-request@arizona.edu Thu Mar 14 22:51:54 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA26733; Thu, 14 Mar 91 22:51:54 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Thu, 14 Mar
1991 22:51 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA07825; Thu, 14 Mar 91
21:36:13 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Thu, 14 Mar 1991 22:51 MST
Date: 13 Mar 91 19:53:53 GMT
From: csus.edu!wuarchive!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!midway!quads.uchicago.edu!goer@ucdavis.ucdavis.edu (Richard
L. Goerwitz)
Subject: RE: Use of Icon in Support of Coursework??
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <D794C129EC601405@Arizona.edu>
Message-Id: <1991Mar13.195353.15075@midway.uchicago.edu>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: University of Chicago
References: <1991Mar13.144400.20767@cs.olemiss.edu>
Hcc@cs.olemiss.edu (Conrad Cunningham) writes:
>A question for academics who use Icon in support of undergraduate- or
>graduate-level courses: In what kinds of courses, at what levels, and
>in what ways is Icon used in support of teaching--particularly in
>computing science? What are the advantages/disadvantages to use of
>Icon in comparison to other languages? What are the available
>textbooks?
>
>Motivation for question: most of the coursework in my department uses
>Pascal, C, or Ada for laboratory exercises. Since joining this
>department two years ago I have been looking for appropriate ways to
>broaden our students "exposure" to different styles, paradigms, and
>approaches to programming.
The problem with Icon - and it's only a problem under certain cir-
comstances - is that people who've learned an Algol-family language
before learning Icon have a very hard time thinking of Icon in its
own terms. They'll tend to pick up things like string scanning and
goal-directed evaluation very late in the game - when in fact they
are some of Icon's major advantages, and ought to be picked up right
away.
Icon is a totally different paradigm in a familiar guise. This
can be very useful, but also very deceptive.
I'd think Icon would be a nice steppingstone to a lecture or two
on Prolog, which has similar backtracking mechanisms (not to say
that the languages in other respects are much the same). Icon's
string scanning would also serve as a good introduction to the
grand old Snobol tradition - which students at this stage would
probably not want to invest a lot of time in (but which they
ought to know exists).
For people doing nonnumeric computing, I'd think it would be
an ideal first language. For those in more traditional com-
puting courses (I'm just guessing here, since I've never taken
a programming course), I'd think it would be an instructive
paradigm shift which might, if done with care, provide a nice
bridge between Algol-family languages and the rest of the
programming languages that are out there.
Actually, I wonder (now that I'm thinking about it) why any-
one would bother with Pascal. Pascal is annoying in that
the core language definition was originally so sparse that
everyone extended it in all kinds of ways just to get it
to work.
-Richard
From icon-group-request@arizona.edu Fri Mar 15 08:29:49 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA17555; Fri, 15 Mar 91 08:29:49 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Fri, 15 Mar
1991 08:29 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA05989; Fri, 15 Mar 91
07:26:10 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Fri, 15 Mar 1991 08:29 MST
Date: 13 Mar 91 18:05:36 GMT
From: mcsun!ukc!cam-cl!news@uunet.uu.net (Brian Brunswick)
Subject: Multiple value assignment in icon???
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <284FC6751C60153A@Arizona.edu>
Message-Id: <1991Mar13.180536.22613@cl.cam.ac.uk>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: U of Cambridge Comp Lab, UK
I am fairly new to icon, but am considering thr pros and cons of
writing a medium size project using it. I came up with a language feature
that I have found useful in the past, namely returning a fixed small
number of distinct values from a procedure and assigning them to separate
variables, and wondered what the particular idiom might be.
That was where the trouble began.
Something like every (x|y):=f() is no good, of course.
I fiddled about, and eventually came up with using this:
every z:=:y:=:x:=:r123()
where r123 would do
suspend ![1|2|3]
and ends up with x=1, y=2, z=3
Note the reversed order of xyz.
Now this is a horrible cludge, it seems to me. Am I missing something,
or does this irritation spoil an otherwise pretty language?
Brian.Brunswick@uk.ac.cam.cl Disclaimer. Short sig rules!
From isidev!nowlin@uunet.UU.NET Fri Mar 15 09:56:25 1991
Received: from uunet.UU.NET by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA19923; Fri, 15 Mar 91 09:56:25 -0700
Received: from isidev.UUCP by uunet.UU.NET with UUCP
(5.61/UUNET-primary-gateway) id AA02775; Fri, 15 Mar 91 11:56:20 -0500
Date: Fri, 15 Mar 91 11:56:20 -0500
From: isidev!nowlin@uunet.uu.net
Message-Id: <9103151656.AA02775@uunet.UU.NET>
To: uunet!cs.arizona.edu!icon-group@uunet.UU.NET
Subject: Re: pipe opens
> I can't get this bit of code to work:
>
> procedure main()
> write(pipe("bogus-command", "nonsense", "logname"))
> end
>
> procedure pipe(cmd[])
> until inf := open(pop(cmd), "pr")
> got := !inf
> close(inf)
> return got
> end
>
> The idea is to try opening a pipe to a series of commands until one
> succeeds. It doesn't work (at least here), because instead of the
> open() failing on "bogus-command" and "nonsense", the shell reports
> that the command wasn't found.
>
> Any idea how to do what I want to do?
> --
>
> Ronald Florence ron@mlfarm.com
The problem is that the pipe-read in Icon invokes the command in a
sub-shell and the open of the sub-shell almost never fails. That's why the
first bogus command in your list terminates the program. The main reason
to test the success or failure of the open in this program is in case the
pop() fails.
The real way to test the success or failure of a command invoked with the
pipe-read is to check the return value from the close of the pipe. This is
where the exit code of the command is returned. For standard UNIX this
exit code should be zero if the command succeeded.
The second problem is that the "not found" error comes from the sub-shell
instead of the command being tested. There's no (easy) way to redirect
that error output without invoking the command in a separate sub-shell.
The following program works that way. I included three sets of test data
since the possibility of an infinite loop, if there's no command that
succeeds, should be tested:
procedure main()
write(pipe("bogus-command","nonsense","logname","more-junk"))
write(pipe("bogus-command","nonsense","lognothing","more-junk"))
write(pipe("logname","bogus-command","nonsense","more-junk"))
end
procedure pipe(cmd[])
repeat {
inf := open("(" || pop(cmd) || ") 2>&1","pr") | fail
got := !inf
if close(inf) = 0 then return got
}
end
This version of pipe() follows the basic algorithm you used. I know the
order of precedence of the expression containing the open() is not obvious
here but once a procedure fails it fails. It doesn't make any difference
if it's trying to assign the result of failure to a variable.
The following version of the pipe() procedure uses goal directed evaluation
instead of iteration. I like this one better:
procedure pipe(cmd[])
if inf := open("(" || !cmd || ") 2>&1","pr") &
got := !inf &
close(inf) = 0 then
return got
else fail
end
+-------------------------------------------------------------------------+
| --- --- |
| | S | Iconic Software, Inc. - Jerry Nowlin - uunet!isidev!nowlin |
| --- --- |
+-------------------------------------------------------------------------+
From wunder@hpsdel.sde.hp.com Fri Mar 15 14:35:14 1991
Resent-From: wunder@hpsdel.sde.hp.com
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA27094; Fri, 15 Mar 91 14:35:14 -0700
Received: from relay.hp.com by Arizona.edu with PMDF#10282; Fri, 15 Mar 1991
14:34 MST
Received: from orac.sde.hp.com by relay.hp.com with SMTP (16.5/15.5+IOS 3.13)
id AA22435; Fri, 15 Mar 91 13:34:26 -0800
Received: by hpsdel.sde.hp.com (15.7/SES42.42) id AA06684; Fri, 15 Mar 91
13:34:12 pst
Resent-Date: Fri, 15 Mar 1991 14:34 MST
Date: Fri, 15 Mar 91 13:34:12 pst
From: Walter Underwood <wunder@hpsdel.sde.hp.com>
Subject: Use of Icon in Support of Coursework??
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <5B5AFDFA1C601A3E@Arizona.edu>
Message-Id: <9103152134.AA06684@hpsdel.sde.hp.com>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
For those in more traditional computing courses (I'm just guessing
here, since I've never taken a programming course), I'd think it would
be an instructive paradigm shift which might, ...
My intro to programming course taught apl and PL/C (a cut-down PL/1).
Learning two very different paradigms was not that hard, and was very
valuable. It fostered a "right tool for the job" attitude, and
steered people away from language bigotry. We also learned how to
change typeballs on Selectric terminals.
Rice now uses Pascal on Macs, which eliminates most of the
edit-compile-debug hassle (a big plus), but I think there was also
something lost in the switch.
wunder
From icon-group-request@arizona.edu Sun Mar 17 22:19:12 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA10694; Sun, 17 Mar 91 22:19:12 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Sun, 17 Mar
1991 22:18 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA18137; Sun, 17 Mar 91
21:10:16 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Sun, 17 Mar 1991 22:18 MST
Date: 18 Mar 91 04:39:48 GMT
From: zaphod.mps.ohio-state.edu!ceres.physics.uiowa.edu!news.iastate.edu!ux1.cso.uiuc.edu!midway!ellis.uchicago.edu!goer@tut.cis.ohio-state.edu
(Richard L. Goerwitz)
Subject: terrible code
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <2E839197AC6020A5@Arizona.edu>
Message-Id: <1991Mar18.043948.11527@midway.uchicago.edu>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: University of Chicago
I wrote the following code because I figured that using sets or
lists alone to accomplish what it does would be inefficient. It
turns out that, even though the code below produces a determinis-
tic automaton (with some small cheating in one spot), it's about
a third as fast as just using a set or list all by itself to do
the same thing.
If there are any wizards online, who feel like bending their minds
over some obscure code, I wouldn't mind a bit if they'd comment
on how this might be done more efficiently. Non-wizards beware
:-).
-Richard
------------------------------------------------------------------
procedure anystr(l,s,i,j)
static done_tbl
initial done_tbl := table()
#
# Make defaults work like those for built-in string-handling
# functions.
#
/s := &subject
if \i then {
if i < 1 then
i := *s + (i+1)
}
else i := \&pos | 1
if \j then {
if j < 1 then
j := *s + (j+1)
}
else j := *s+1
#
# Create table to sort and hold characters for list l (if it
# does not already exist. Then return the position in s of
# the longest string in l that matches at position i.
#
/done_tbl[l] := table(sort(set(l)))
return (i-1) + (s[i:j] ? walk_table(done_tbl[l]))
# NB: longest possible match approach!
end
procedure walk_table(t)
local val, chr, ntbl, nlst, empty_string_present
while val := t[move(1)] do {
case type(val) of {
"table" : {
if "" == key(val) then {
POS := &pos
return (walk_table(val) | POS)
}
else return walk_table(val)
}
"list" : {
case *val of {
0 : fail
1 : if (move(-1),=val[1]) then return .&pos else fail
default: {
nkey := "impossible key"
while pop(val) ? {
empty_string_present := pos(0)
chr := move(1) | ""
if nkey ~==:= chr then {
nlst := list()
ntbl := table(nlst)
insert(t, nkey, ntbl)
}
put(nlst, tab(0))
}
move(-1)
if \empty_string_present then {
POS := &pos
return (walk_table(t) | POS)
}
else return walk_table(t)
}
}
}
}
}
end
From icon-group-request@arizona.edu Mon Mar 18 00:50:38 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA12908; Mon, 18 Mar 91 00:50:38 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Mon, 18 Mar
1991 00:49 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA21142; Sun, 17 Mar 91
23:45:10 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Mon, 18 Mar 1991 00:50 MST
Date: 16 Mar 91 14:27:26 GMT
From: mcsun!ukc!cam-cl!news@uunet.uu.net (Brian Brunswick)
Subject: RE: Multiple value assignment in icon???
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <43A76328FC601EB3@Arizona.edu>
Message-Id: <1991Mar16.142726.5947@cl.cam.ac.uk>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: U of Cambridge Comp Lab, UK
References: <1991Mar13.180536.22613@cl.cam.ac.uk>,
<1991Mar15.013415.1499@midway.uchicago.edu>
In article <1991Mar15.013415.1499@midway.uchicago.edu> goer@quads.uchicago.edu (Richard L. Goerwitz) writes:
>Bdb@cl.cam.ac.uk (Brian Brunswick) writes (with regard to the problem
>of assigning a series of results to a series of variables):
>>
>>Something like every (x|y):=f() is no good, of course.
>>
>
>This is sooo close to working.... [explanation of what goes wrong]
>
>Aha! We've suddenly run into one very good use for coexpressions.
>Here's what to do:
>
> val := create f()
> every (x|y) := @val
Yup, I'd spotted that this was possible, but was put off by the extra
temporary variable needed - I'd really like something on one line.
One can't even do things like ...@(val := create f()), since rhs
evaluated multiple times when lhs is resumed. I did experiment with
putting inteligence in a wrapper function, but it doesn't have enough
information to work safely enough to withstand mistakes.
>Now here's an excercize to see if you fully grasp how Icon de-
>references variables. Why will the following NOT work the way you
>want it to?
>
> var := create (x|y)
> every val := f() do
> var := val
Urble ... create makes its own copy of local variables ... but would
they even survive undereferenced (ug!) to be (pointlessly) used? I
suppose globals would work.
>Referring to a solution offered (but not quoted here):
Which was using a wrapper of ![...] around the procedure return values
to turn them into anonymous variables, which enables the calling line
to use a multiple swapping assignment to do rotation amongst several
variables and accumulate results that way. ( every z:=:y:=:x:=:f() )
>
>> Am I missing something, or does this irritation spoil an otherwise
>> pretty language?
>
>Your solution isn't particularly idiomatic. You clearly sensed this.
>Hence your posting. Your question was really very good, though, be-
>cause you've clearly grasped precisely the sort of situation that makes
>coexpressions useful and elegant additions to the language. You aren't
>missing a thing, but rather demonstrating an understanding of the sort
>of logic that led to the implementation of coexpressions....
>
>I hope this helps.
>
>-Richard Goerwitz (goer@sophist.uchicago.edu)
Hmm... I'm not so sure that I don't prefer my cludge to having to
introduce an extra intermediate variable. Of course, its only good so
long as its clearly recognised as an idiom by the reader, otherwise
its needless obfuscation.
Also, I hesitated somewhat at creating a co expression just to do
something that short that I'm likely to use quite a lot. Isn't that
likely to be quite expensive in terms of garbage produced? Or would
reusing the same temporary to hold it mean that reference counting or
something rescues things?
Brian.Brunswick@uk.ac.cam.cl Disclaimer. Short sig rules!
From isidev!nowlin@uunet.UU.NET Mon Mar 18 08:58:28 1991
Received: from uunet.uu.net by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA25661; Mon, 18 Mar 91 08:58:28 -0700
Received: from isidev.UUCP by uunet.uu.net with UUCP
(5.61/UUNET-primary-gateway) id AA20381; Mon, 18 Mar 91 10:58:24 -0500
Date: Mon, 18 Mar 91 10:58:24 -0500
From: isidev!nowlin@uunet.uu.net
Message-Id: <9103181558.AA20381@uunet.uu.net>
To: uunet!cs.arizona.edu!icon-group@uunet.UU.NET
Subject: Re: terrible code
You're right. Terrible code :-) I'm not a wizard so could you please
stick an illustrative main procedure on there so we non-wizards can figure
out what this program is supposed to do in the first place? It looks like
it scans a string for the longest match on any one of a list of strings but
I got nowhere trying to make that work. If that's really what is going on
I have some ideas.
Thanks.
+-------------------------------------------------------------------------+
| --- --- |
| | S | Iconic Software, Inc. - Jerry Nowlin - uunet!isidev!nowlin |
| --- --- |
+-------------------------------------------------------------------------+
From isidev!nowlin@uunet.UU.NET Mon Mar 18 08:58:29 1991
Received: from uunet.uu.net by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA25664; Mon, 18 Mar 91 08:58:29 -0700
Received: from isidev.UUCP by uunet.uu.net with UUCP
(5.61/UUNET-primary-gateway) id AA20389; Mon, 18 Mar 91 10:58:25 -0500
Date: Mon, 18 Mar 91 10:58:25 -0500
From: isidev!nowlin@uunet.uu.net
Message-Id: <9103181558.AA20389@uunet.uu.net>
To: uunet!cs.arizona.edu!icon-group@uunet.UU.NET
Subject: Re: terrible code (2)
I figured out what I was doing wrong and got the program originally posted
to work. I came up with a solution that got the same answer for my test
data. Is this a possible solution to what you were trying to do? Notice I
just borrowed the argument processing code from the original anystr()
procedure for my longstr() procedure:
procedure main(args)
l := ["th","that ","not close","tha","that b","t"]
s := "that begins this string"
#write(anystr(l,s))
write(longstr(l,s))
end
procedure longstr(l,s,i,j)
##### borrowed #####
/s := &subject
if \i then {
if i < 1 then
i := *s + (i+1)
}
else i := \&pos | 1
if \j then {
if j < 1 then
j := *s + (j+1)
}
else j := *s+1
##### borrowed #####
m := 0
while *(p := (s ? =!l)) > m do m := *p
return m + 1
end
I didn't include the original posted code here but you can add it to this
program and test the two solutions together. I haven't a clue which is
faster but this one is somewhat shorter.
+-------------------------------------------------------------------------+
| --- --- |
| | S | Iconic Software, Inc. - Jerry Nowlin - uunet!isidev!nowlin |
| --- --- |
+-------------------------------------------------------------------------+
From isidev!nowlin@uunet.UU.NET Mon Mar 18 09:58:13 1991
Received: from uunet.uu.net by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA27135; Mon, 18 Mar 91 09:58:13 -0700
Received: from isidev.UUCP by uunet.uu.net with UUCP
(5.61/UUNET-primary-gateway) id AA05469; Mon, 18 Mar 91 11:58:07 -0500
Date: Mon, 18 Mar 91 11:58:07 -0500
From: isidev!nowlin@uunet.uu.net
Message-Id: <9103181658.AA05469@uunet.uu.net>
To: uunet!cs.arizona.edu!icon-group@uunet.UU.NET
Subject: Re: terrible code (3)
Last time...promise. I just forgot to use the 'i' and 'j' arguments in my
solution and thought as long as I'm posting it again why not comment it
some since it is a little cryptic:
procedure main(args)
s := "that begins this string"
l := ["th","that beg","not close","","tha","begins t","that b","t"]
write(longstr(l,s)) | write("nomatch")
write(longstr(l,s,6)) | write("nomatch")
write(longstr(l,s,6,12)) | write("nomatch")
l := ["th","that beg","not close","tha","begins t","that b","t"]
write(longstr(l,s)) | write("nomatch")
write(longstr(l,s,6)) | write("nomatch")
write(longstr(l,s,6,12)) | write("nomatch")
end
procedure longstr(l,s,i,j)
##### borrowed #####
/s := &subject
if \i then {
if i < 1 then
i := *s + (i+1)
}
else i := \&pos | 1
if \j then {
if j < 1 then
j := *s + (j+1)
}
else j := *s+1
##### borrowed #####
# initialize the match length
m := 0
# while there is a pattern 'p' in list 'l' that matches string 's[i:j]'
# and that pattern 'p' is longer than the current match length 'm' reset
# the match length 'm' to the length of pattern 'p' -- goal directed
# evaluation in the 'while' expression is the key here
while *(p := (s[i:j] ? =!l)) > m do m := *p
# if no pattern matched fail
if /p then fail
# if a pattern matched return the position in 's' past the pattern
else return i + m
end
+-------------------------------------------------------------------------+
| --- --- |
| | S | Iconic Software, Inc. - Jerry Nowlin - uunet!isidev!nowlin |
| --- --- |
+-------------------------------------------------------------------------+
From icon-group-request@arizona.edu Mon Mar 18 10:07:13 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA27362; Mon, 18 Mar 91 10:07:13 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Mon, 18 Mar
1991 10:06 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA29542; Mon, 18 Mar 91
09:02:57 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Mon, 18 Mar 1991 10:06 MST
Date: 18 Mar 91 15:08:38 GMT
From: agate!bionet!uwm.edu!ux1.cso.uiuc.edu!midway!ellis.uchicago.edu!goer@ucbvax.Berkeley.EDU (Richard
L. Goerwitz)
Subject: RE: Multiple value assignment in icon???
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <916B68B65C602198@Arizona.edu>
Message-Id: <1991Mar18.150838.24597@midway.uchicago.edu>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: University of Chicago
References: <1991Mar13.180536.22613@cl.cam.ac.uk>,
<1991Mar15.013415.1499@midway.uchicago.edu>,
<1991Mar16.142726.5947@cl.cam.ac.uk>
Bdb@cl.cam.ac.uk (Brian Brunswick) writes:
>>
>> val := create f()
>> every (x|y) := @val
>
>Yup, I'd spotted that this was possible, but was put off by the extra
>temporary variable needed - I'd really like something on one line....
You know, I've never understood peoples' resistence to side-effects of
this kind in Icon. All your garbage gets collected for you, and you are
not going to have any problems with pointers. The variables, if declared
explicitly local, aren't going to conflict with anything else. If they
make the code clear and idiomatic, then my own vote is to use them!
>Hmm... I'm not so sure that I don't prefer my cludge to having to
>introduce an extra intermediate variable. Of course, its only good so
>long as its clearly recognised as an idiom by the reader, otherwise
>its needless obfuscation.
I guess that's what I was trying to say.
>Also, I hesitated somewhat at creating a co-expression just to do
>something that short that I'm likely to use quite a lot. Isn't that
>likely to be quite expensive in terms of garbage produced? Or would
>reusing the same temporary to hold it mean that reference counting or
>something rescues things?
You know, I really don't know. Co-expressions involve less overhead
than a procedure call, as I understand them, and are a bit faster. If
storage and garbage collection is a problem, you could try writing two
versions of the program, and then check out the IPL program empg.icn.
It's a tool that's ideal for just this kind of profiling.
You could also write a little shell script to turn on memory monitoring,
and then use the IPL routine memsum to get a summary of the results.
I'm thinking of, say,
#!/bin/sh
if
test $# = 0
then
echo 'usage: memmon icon-program [arguments]'
exit 1
else
export MEMMON
MEMMON=tablc.mon
$*
# unset MEMMON
/usr/local/bin/memsum < tablc.mon > tablc.sum
/bin/cat tablc.sum | egrep -v '0.000$' 1>&2
/bin/rm tablc.mon tablc.sum
fi
I'll be curious to hear what you eventually settle on.
-Richard (goer@sophist.uchicago.edu)
From icon-group-request@arizona.edu Mon Mar 18 12:26:15 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA01036; Mon, 18 Mar 91 12:26:15 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Mon, 18 Mar
1991 12:25 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA03997; Mon, 18 Mar 91
11:07:22 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Mon, 18 Mar 1991 12:26 MST
Date: 18 Mar 91 17:19:46 GMT
From: sdd.hp.com!zaphod.mps.ohio-state.edu!maverick.ksu.ksu.edu!ux1.cso.uiuc.edu!midway!ellis.uchicago.edu!goer@ucsd.edu
(Richard L. Goerwitz)
Subject: RE: terrible code (2)
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <A4D7B6DE5C601CBC@Arizona.edu>
Message-Id: <1991Mar18.171946.28280@midway.uchicago.edu>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: University of Chicago
References: <9103181558.AA20389@uunet.uu.net>
In article <9103181558.AA20389@uunet.uu.net> nowlin@isidev.UUCP writes:
> m := 0
> while *(p := (s ? =!l)) > m do m := *p
> return m + 1
Very clever. Try matching each member of l, keeping a record of the
length of the match. The longest match wins.
This sort of code does exactly what my code does. Here's the problem.
Solution of the type exemplified above involve mindless interation
through the entire list, l. I decided that it would be sensible to
write a little program that made this process deterministic. I used
tables of tables to accomplish this. Read a char, then see if the
char is in the lookup table. Whatever strings begin with that char
become possible matches. Then read another char. Of the strings con-
sidered possible matches before, only those whose 2nd character matches
the one just read are possible matches, etc.
I added a cheat. If at any time we run into "" (some string runs out
of chars), we remember that spot, and continue with the remaining
strings. If nothing else matches beyond this point, we backtrack to
it and return the position we were at when we ran out of characters in
on of the strings.
Anyway, this is pretty much a deterministic process (with that one
cheat described immediately above). It's slow as mud, though. And
so your code, Jerry, while seemingly "dumb but elegant" turns out
better than mine!
There must be a way to do the kinds of things we're talking about here
in Icon, and do it with somewhat greater speed than the =!l approach.
-Richard
From isidev!nowlin@uunet.UU.NET Mon Mar 18 19:45:19 1991
Received: from uunet.uu.net by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA14218; Mon, 18 Mar 91 19:45:19 -0700
Received: from isidev.UUCP by uunet.uu.net with UUCP
(5.61/UUNET-primary-gateway) id AA11982; Mon, 18 Mar 91 21:45:15 -0500
Date: Mon, 18 Mar 91 21:45:15 -0500
From: isidev!nowlin@uunet.uu.net
Message-Id: <9103190245.AA11982@uunet.uu.net>
To: uunet!cs.arizona.edu!icon-group@uunet.UU.NET
Subject: Re: RE: terrible code
>From article <1991Mar18.171946.28280@midway.uchicago.edu> (Richard L. Goerwitz)
> In article <9103181558.AA20389@uunet.uu.net> nowlin@isidev.UUCP writes:
> >
> > m := 0
> > while *(p := (s ? =!l)) > m do m := *p
> > return m + 1
>
> Very clever. Try matching each member of l, keeping a record of the
> length of the match. The longest match wins.
>
> This sort of code does exactly what my code does. Here's the problem.
> Solution of the type exemplified above involve mindless interation
> through the entire list, l. I decided that it would be sensible to
> ...
> There must be a way to do the kinds of things we're talking about here
> in Icon, and do it with somewhat greater speed than the =!l approach.
I've included the source from a subsequent reposting of the piece of code
being discussed since it was modified to follow the original program more
closely:
m := 0
while *(p := (s[i:j] ? =!l)) > m do m := *p
if /p then fail
else return i + m
The key to this is that it's not a "mindless iteration through the entire
list". It's an iteration, but in any language but Icon you'd have to
explicitly do a lot more to control this iteration than in the simple
expression above. Simple is in the eyes of the beholder :-)
Any expression that follows the 'while' control structure must try to
succeed due to goal directed evaluation. That means if the expression
contains a generator, in this case the !l, results are generated until the
generator is exhausted or the expression succeeds in the context of one of
the results. If the expression succeeds the result is used to modify the
expression. Eventually none of the generator's results will cause the
expression to succeed and the loop is exited.
This Icon stuff is pretty slick. I fail to see why a few of dozen lines of
admittedly "terrible" code make a better solution than these four lines.
I could do a matching table in C that would blow this away in terms of
speed but this is Icon. It should be done Iconishly.
+-------------------------------------------------------------------------+
| --- --- |
| | S | Iconic Software, Inc. - Jerry Nowlin - uunet!isidev!nowlin |
| --- --- |
+-------------------------------------------------------------------------+
From sbw@turing.cse.nau.edu Mon Mar 18 19:57:16 1991
Received: from turing.cse.nau.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA14513; Mon, 18 Mar 91 19:57:16 -0700
Received: by turing.cse.nau.edu (5.64/1.34)
id AA10874; Mon, 18 Mar 91 19:57:02 -0700
Message-Id: <9103190257.AA10874@turing.cse.nau.edu>
From: sbw@turing.cse.nau.edu (Steve Wampler)
Date: Mon, 18 Mar 1991 19:57:02 MST
In-Reply-To: isidev!nowlin@uunet.uu.net's mail message of Mar 18, 19:47.
X-Mailer: Mail User's Shell (7.2.0 10/31/90)
To: icon-group@cs.arizona.edu
Subject: Re: RE: terrible code
On Mar 18 at 19:47, isidev!nowlin@uunet.uu.net writes:
}
} m := 0
} while *(p := (s[i:j] ? =!l)) > m do m := *p
} if /p then fail
} else return i + m
}
Out of curiousity (and because I like bizarre code), couldn't
the above be written:
m := 0
while m >:= *(s[i:j] ? =!l)
return i + (0 ~= m)
instead? (No, I haven't tried it, but it seems the same to me...)
--
Steve Wampler
{....!arizona!naucse!sbw}
{sbw@turing.cse.nau.edu}
From sbw@turing.cse.nau.edu Mon Mar 18 20:01:05 1991
Received: from turing.cse.nau.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA14645; Mon, 18 Mar 91 20:01:05 -0700
Received: by turing.cse.nau.edu (5.64/1.34)
id AA10894; Mon, 18 Mar 91 20:00:46 -0700
Message-Id: <9103190300.AA10894@turing.cse.nau.edu>
From: sbw@turing.cse.nau.edu (Steve Wampler)
Date: Mon, 18 Mar 1991 20:00:46 MST
In-Reply-To: Steve Wampler's mail message of Mar 18, 19:58.
X-Mailer: Mail User's Shell (7.2.0 10/31/90)
To: icon-group@cs.arizona.edu
Subject: Re: RE: terrible code
On Mar 18 at 19:58, Steve Wampler writes:
} On Mar 18 at 19:47, isidev!nowlin@uunet.uu.net writes:
} }
} } m := 0
} } while *(p := (s[i:j] ? =!l)) > m do m := *p
} } if /p then fail
} } else return i + m
} }
}
} Out of curiousity (and because I like bizarre code), couldn't
} the above be written:
}
} m := 0
} while m >:= *(s[i:j] ? =!l)
} return i + (0 ~= m)
}
} instead? (No, I haven't tried it, but it seems the same to me...)
Sigh. Make that a <:=, not >:=.
--
Steve Wampler
{....!arizona!naucse!sbw}
{sbw@turing.cse.nau.edu}
From icon-group-request@arizona.edu Mon Mar 18 22:09:23 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA17558; Mon, 18 Mar 91 22:09:23 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Mon, 18 Mar
1991 22:08 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA22191; Mon, 18 Mar 91
20:59:10 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Mon, 18 Mar 1991 22:09 MST
Date: 19 Mar 91 04:26:11 GMT
From: magnus.acs.ohio-state.edu!zaphod.mps.ohio-state.edu!maverick.ksu.ksu.edu!ux1.cso.uiuc.edu!midway!ellis.uchicago.edu!goer@tut.cis.ohio-state.edu (Richard L.
Goerwitz)
Subject: RE: RE: terrible code
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <F64F2F1CDC6025C0@Arizona.edu>
Message-Id: <1991Mar19.042611.18718@midway.uchicago.edu>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: University of Chicago
References: <9103190245.AA11982@uunet.uu.net>
In article <9103190245.AA11982@uunet.uu.net> nowlin@isidev.UUCP writes:
>
> m := 0
> while *(p := (s[i:j] ? =!l)) > m do m := *p
> if /p then fail
> else return i + m
>
>The key to this is that it's not a "mindless iteration through the entire
>list". It's an iteration, but in any language but Icon you'd have to
>explicitly do a lot more to control this iteration than in the simple
>expression above. Simple is in the eyes of the beholder :-)
You know, reading over my last posting, you could take the word "mindless"
to refer to the programmer, and not to the =!l method of looking for mat-
ches. That's not what I indended, of course. I should really try to be
a bit more gracious. The overall solution was really very clean.
Anyway, elegance of expression is certainly a plus with Icon. So it its
economy. The question is whether this economy doesn't sometimes involve
some serious, serious performance penalties. In the case of my "terrible
code" (self-admitted), I was trying to use two Icon features (hash tables
and sets) to coax more performance out of a routine than the backtrack-
ing mechanisms, unhindered, allowed.
>This Icon stuff is pretty slick. I fail to see why a few of dozen lines of
>admittedly "terrible" code make a better solution than these four lines.
>I could do a matching table in C that would blow this away in terms of
>speed but this is Icon. It should be done Iconishly.
Well, that again is in the eyes of the beholder. Does "Iconishly" mean
"in an extremely compact and elegant, but computationally clumsy and inef-
ficient, manner"? Perhaps in many cases, yes. In this case, I had hoped
no. My attempt at doing things more deterministically, though, failed.
So in the end I was left with something both slow and inelegant.
I guess one could argue that this sort of thing should be done in C, and
that the easiest way to do things would be just to use the regexp rou-
tines. Often, though, I work on larger-scale projects mainly in Icon,
and am very, very reluctant to hack in C code, either through extcall/
callout, or, worse yet, via shell scripts and pipes. Unix isn't the only
platform I operate on, and there is something esthetically displeasing
about having to hack every interpreter I want to run software on.
I guess the big question is this: How easy will inline C code be able
to be incorporated into compiled Icon code??
(Jerry, thanks for responding; I'll probably end up using your code, a
la Steve Wampler's modifications.)
-Richard (goer@sophist.uchicago.edu)
From cjeffery Mon Mar 18 23:05:42 1991
Resent-From: "Clinton Jeffery" <cjeffery>
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA18690; Mon, 18 Mar 91 23:05:42 -0700
Received: from megaron.cs.arizona.edu (128.196.128.118) by Arizona.edu with
PMDF#10282; Mon, 18 Mar 1991 23:05 MST
Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15)
via SMTP id AA18679; Mon, 18 Mar 91 23:05:11 -0700
Received: by cheltenham.cs.arizona.edu; Mon, 18 Mar 91 23:05:09 MST
Resent-Date: Mon, 18 Mar 1991 23:05 MST
Date: Mon, 18 Mar 91 23:05:09 MST
From: Clinton Jeffery <cjeffery@cs.arizona.edu>
Subject: Multiple value assignment in icon???
In-Reply-To: Richard L. Goerwitz's message of 18 Mar 91 15:08:38 GMT
<1991Mar18.150838.24597@midway.uchicago.edu>
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <FE2DEB351C60220B@Arizona.edu>
Message-Id: <9103190605.AA25040@cheltenham.cs.arizona.edu>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
>>Also, I hesitated somewhat at creating a co-expression just to do
>>something that short that I'm likely to use quite a lot. Isn't that
>>likely to be quite expensive in terms of garbage produced? Or would
>>reusing the same temporary to hold it mean that reference counting or
>>something rescues things?
>You know, I really don't know. Co-expressions involve less overhead
>than a procedure call, as I understand them, and are a bit faster.
Basically everyone is right.
Co-expression >activation< involves less overhead and is a bit faster
than procedure call. Co-expression >creation< does involve some work
setting up stacks and copying variables. In many of these situations
there is some magic "average number of results" beyond which co-expressions
are cost-effective. But of course, Icon is focused on programmer
time more than on execution time. If you are a busy person and you
are in the habit of avoiding co-expressions for performance reasons,
not only will you miss out on a lot of fun, you will spend a lot more
time writing and debugging, and often you will not gain enough to
have justified it.
Clint
P.S. I have been guilty of avoiding co-expressions before! Its very
understandable and really is justified, AFTER the program is finished
and you are tuning it. Why not write it in two lines with a co-expression
first, and write yourself a comment to look at it again later...
From isidev!nowlin@uunet.UU.NET Tue Mar 19 04:56:13 1991
Received: from uunet.uu.net by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA28474; Tue, 19 Mar 91 04:56:13 -0700
Received: from isidev.UUCP by uunet.uu.net with UUCP
(5.61/UUNET-primary-gateway) id AA24294; Tue, 19 Mar 91 06:56:08 -0500
Date: Tue, 19 Mar 91 06:56:08 -0500
From: isidev!nowlin@uunet.uu.net
Message-Id: <9103191156.AA24294@uunet.uu.net>
To: uunet!cs.arizona.edu!icon-group@uunet.UU.NET
Subject: Re: RE: terrible code
In message <9103190300.AA10894@turing.cse.nau.edu> From: (Steve Wampler)
> } Out of curiousity (and because I like bizarre code), couldn't
> } the above be written:
> }
> } m := 0
> } while m >:= *(s[i:j] ? =!l)
> } return i + (0 ~= m)
> }
> } instead? (No, I haven't tried it, but it seems the same to me...)
>
> Sigh. Make that a <:=, not >:=.
Good reduction. The only problem with this is that if someone were to
include an empty string in the list they're matching this solution would
fail even if it matched the empty string. (I know...who cares!) A simple
modification fixes that though. I added enough to test this. Look at an
earlier posting to see comments:
procedure main(args)
s := "that begins this string"
l := ["th","that beg","not close","","tha","begins t","that b","t"]
write(longstr(l,s,6,12)) | write("nomatch")
l := ["th","that beg","not close","tha","begins t","that b","t"]
write(longstr(l,s,6,12)) | write("nomatch")
end
procedure longstr(l,s,i,j)
##### borrowed #####
/s := &subject
if \i then {
if i < 1 then
i := *s + (i+1)
}
else i := \&pos | 1
if \j then {
if j < 1 then
j := *s + (j+1)
}
else j := *s+1
##### borrowed #####
m := 0
while m <:= *(p := (s[i:j] ? =!l))
if /p then fail
else return i + m
end
+-------------------------------------------------------------------------+
| --- --- |
| | S | Iconic Software, Inc. - Jerry Nowlin - uunet!isidev!nowlin |
| --- --- |
+-------------------------------------------------------------------------+
From sbw@turing.cse.nau.edu Tue Mar 19 06:44:24 1991
Received: from turing.cse.nau.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA01804; Tue, 19 Mar 91 06:44:24 -0700
Received: by turing.cse.nau.edu (5.64/1.34)
id AA11777; Tue, 19 Mar 91 06:44:09 -0700
Message-Id: <9103191344.AA11777@turing.cse.nau.edu>
From: sbw@turing.cse.nau.edu (Steve Wampler)
Date: Tue, 19 Mar 1991 06:44:08 MST
X-Mailer: Mail User's Shell (7.2.0 10/31/90)
To: icon-group@cs.arizona.edu
Subject: Re: RE: terible code
Oh right, empty strings. I think I would care about that - I'm pretty
fond of empty strings. Just for grins, here's yam (yet another
modification:
m := -1
while m <:= *(s[i:j] ? =!l)
return i+(-1 ~= m)
--
Steve Wampler
{....!arizona!naucse!sbw}
{sbw@turing.cse.nau.edu}
From icon-group-request@arizona.edu Tue Mar 19 10:58:56 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA08037; Tue, 19 Mar 91 10:58:56 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Tue, 19 Mar
1991 10:57 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA09157; Tue, 19 Mar 91
09:43:39 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Tue, 19 Mar 1991 10:58 MST
Date: 19 Mar 91 16:05:29 GMT
From: midway!ellis.uchicago.edu!goer@handies.ucar.edu (Richard L. Goerwitz)
Subject: longstr.icn
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <61CD2EA81C6023C2@Arizona.edu>
Message-Id: <1991Mar19.160529.4734@midway.uchicago.edu>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: University of Chicago
Here's what I finally settled on. Thanks, everyone.
-Richard
############################################################################
#
# Name: longstr.icn
#
# Title: match longest string in a list or set of strings
#
# Author: Jerry Nowlin, Steve Wampler, and Richard Goerwitz
#
# Version: 1.1
#
############################################################################
#
# Anystr(l,s,i,j) works like any(), except that instead of taking a
# cset as its first argument, it takes instead a list or set of
# strings (l). Returns i + *x, where x is the longest string in l
# for which match(x,s,i,j) succeeds. Fails if no match occurs.
#
# Defaults:
# s &subject
# i &pos if s is defaulted, otherwise 1
# j 0
#
# Errors:
# The only manual error-checking that is done is to test l to
# be sure it is, in fact, a list or set. Errors such as non-
# string members in l, and non-integer i/j parameters, are
# caught by the normal Icon built-in string processing and sub-
# scripting mechanisms.
#
############################################################################
#
# Links: none
#
############################################################################
procedure longstr(l,s,i,j)
local m
#
# Is l a list or set?
#
type(l) == ("list"|"set") |
stop("longstr: list or set expected (arg 1)")
#
# Set up s and i variables just as in built-in string-handling
# functions.
#
if /s := &subject then {
if \i then {
if i < 1 then
i := *s + (i+1)
}
else i := &pos
}
else i := 1
#
# Set up j.
#
if \j then {
if j < 1 then
j := *s + (j+1)
}
else j := *s+1
#
# Find longest match()-ing string in l. Initialize m to -1 so
# as to detect cases where "" is the only match that succeeds.
#
m := -1 # Attempt to match() each member in l (=!l).
while m <:= *(s[i:j] ? =!l) # Produce the length of each match that suc-
# ceeds, and store its value in m iff it is
# greater than m's current value.
#
# Return i + the length of the longest match. Fail if there was
# no match (i.e. m still has its original value).
#
return i + (-1 ~= m)
end
From icon-group-request@arizona.edu Tue Mar 19 15:29:18 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA16012; Tue, 19 Mar 91 15:29:18 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Tue, 19 Mar
1991 15:28 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA18189; Tue, 19 Mar 91
14:19:26 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Tue, 19 Mar 1991 15:28 MST
Date: 19 Mar 91 21:31:34 GMT
From: agate!bionet!uwm.edu!ux1.cso.uiuc.edu!midway!ellis.uchicago.edu!goer@ucbvax.Berkeley.EDU (Richard
L. Goerwitz)
Subject: longstr; naturally an oops
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <8786208B2C6027B2@Arizona.edu>
Message-Id: <1991Mar19.213134.15017@midway.uchicago.edu>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: University of Chicago
So you say I should actually test programs before posting them?
Looks like the while/every mistake eluded more people than just
me,though. It took a confused (or rather not-so-confused) note
from Ken Walker.
-Richard
-------
############################################################################
#
# Name: longstr.icn
#
# Title: match longest string in a list or set of strings
#
# Author: Jerry Nowlin, Steve Wampler, and Richard Goerwitz
#
# Version: 1.3
#
############################################################################
#
# longstr(l,s,i,j) works like any(), except that instead of taking a
# cset as its first argument, it takes instead a list or set of
# strings (l). Returns i + *x, where x is the longest string in l
# for which match(x,s,i,j) succeeds. Fails if no match occurs.
#
# Defaults:
# s &subject
# i &pos if s is defaulted, otherwise 1
# j 0
#
# Errors:
# The only manual error-checking that is done is to test l to
# be sure it is, in fact, a list or set. Errors such as non-
# string members in l, and non-integer i/j parameters, are
# caught by the normal Icon built-in string processing and sub-
# scripting mechanisms.
#
############################################################################
#
# Links: none
#
############################################################################
procedure longstr(l,s,i,j)
local m
#
# Is l a list or set?
#
type(l) == ("list"|"set") |
stop("longstr: list or set expected (arg 1)")
#
# Set up s and i variables just as in built-in string-handling
# functions.
#
if /s := &subject then
/i := &pos
if \i then {
if i < 1 then
i := *s + (i+1)
}
else i := 1
#
# Set up j.
#
if \j then {
if j < 1 then
j := *s + (j+1)
}
else j := *s+1
#
# Find longest match()-ing string in l. Initialize m to -1 so
# as to detect cases where "" is the only match that succeeds.
#
m := -1 # Attempt to match() each member in l (=!l).
every m <:= *(s[i:j] ? =!l) # Produce the length of each match that suc-
# ceeds, and store its value in m iff it is
# greater than m's current value.
#
# Return i + the length of the longest match. Fail if there was
# no match (i.e. m still has its original value).
#
return i + (-1 ~= m)
end
From alex@laguna.Metaphor.COM Tue Mar 19 17:28:53 1991
Received: from relay.metaphor.com by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA20897; Tue, 19 Mar 91 17:28:53 -0700
Received: from laguna.Metaphor.COM by relay.metaphor.com (4.1/SMI-4.1)
id AA05155; Tue, 19 Mar 91 16:24:19 PST
Received: by laguna.Metaphor.COM (4.0/SMI-4.0)
id AA02704; Tue, 19 Mar 91 16:28:02 PST
Date: Tue, 19 Mar 91 16:28:02 PST
From: alex@laguna.Metaphor.COM (Bob Alexander)
Message-Id: <9103200028.AA02704@laguna.Metaphor.COM>
To: icon-group@cs.arizona.edu
Subject: Comment on longstr.icn
Gee, this is fun. I have a couple of comments to throw into the frey.
1) Perhaps instead of the stop() if there is a problem with the
arguments, a runerr() would be more consistent with the builtin
string-analysis procedures -- "115: list, set, or table expected" would
be reasonably appropriate, since the algorithm could work with tables
too (records, too, for that matter, but that's probably a bit much).
2) Things could be simplified quite a bit by not messing with defaults
for s, i, and j and letting Icon do the work by eliminating the string
scanning. In this version, the m := -1 initial value can revert back
to 0, since matching an empty string returns 1.
So here's my entry in the series of suggestions. Somehow I can't help
but wonder if I've missed something obvious -- but if not, do I get my
name in the growing list of credits? :-)
procedure longstr(l,s,i,j)
local m
#
# Is l a list, set, table?
#
type(l) == ("list" | "set" | "table") |
runerr(115,l)
#
# Find longest match()-ing string in l.
#
m := 0 # Attempt to match() each member in l (=!l).
every m <:= match(!l,s,i,j) # Produce the length of each match that suc-
# ceeds, and store its value in m iff it is
# greater than m's current value.
#
# Return i + the length of the longest match. Fail if there was
# no match (i.e. m still has its original value).
#
return 0 ~= m
end
-- Bob Alexander
Metaphor Computer Systems (415) 961-3600 x751 alex@metaphor.com
====^=== Mountain View, CA ...{uunet}!{decwrl,apple}!metaphor!alex
From isidev!nowlin@uunet.UU.NET Tue Mar 19 19:33:10 1991
Received: from uunet.UU.NET by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA26567; Tue, 19 Mar 91 19:33:10 -0700
Received: from isidev.UUCP by uunet.UU.NET with UUCP
(5.61/UUNET-primary-gateway) id AA07937; Tue, 19 Mar 91 21:33:06 -0500
Date: Tue, 19 Mar 91 21:33:06 -0500
From: isidev!nowlin@uunet.uu.net
Message-Id: <9103200233.AA07937@uunet.UU.NET>
To: uunet!cs.arizona.edu!icon-group@uunet.UU.NET
Subject: Re: longstr oops
From-Id: <1991Mar19.213134.15017@midway.uchicago.edu>
> So you say I should actually test programs before posting them?
> Looks like the while/every mistake eluded more people than just
> me, though. It took a confused (or rather not-so-confused) note
> from Ken Walker.
>
> # Find longest match()-ing string in l. Initialize m to -1 so
> # as to detect cases where "" is the only match that succeeds.
> #
> m := -1 # Attempt to match() each member in l (=!l).
> every m <:= *(s[i:j] ? =!l) # Produce the length of each match that suc-
> # ceeds, and store its value in m if it is
> # greater than m's current value.
> #
> # Return i + the length of the longest match. Fail if there was
> # no match (i.e. m still has its original value).
> #
> return i + (-1 ~= m)
The 'while' was not a mistake. The program I posted with test data and a
main procedure in it worked just fine with a 'while' instead of an
'every'. I wasn't looking for iteration here. I was looking for GOAL
DIRECTED EVALUATION. The 'while' forces the expression:
m <:= *(s[i:j] ? =!l)
to do everything it can to succeed. Since there's a generator in this
expression (!l) all the strings in 'l' are generated every time through the
loop until one of the strings is matched and it's longer than the last
string that was matched. GOAL DIRECTED EVALUATION forces the generator to
generate so you don't need an 'every'. When there are no more strings in
'l' that will match and that are longer than the last match the loop
terminates.
The 'every' works, but for a different reason. The 'every' is probably
faster since it only iterates through the list once. It's important to
understand why both work for different reasons. They both work though.
+-------------------------------------------------------------------------+
| --- --- |
| | S | Iconic Software, Inc. - Jerry Nowlin - uunet!isidev!nowlin |
| --- --- |
+-------------------------------------------------------------------------+
From sbw@turing.cse.nau.edu Tue Mar 19 19:44:16 1991
Received: from turing.cse.nau.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA26810; Tue, 19 Mar 91 19:44:16 -0700
Received: by turing.cse.nau.edu (5.64/1.34)
id AA15863; Tue, 19 Mar 91 19:44:01 -0700
Message-Id: <9103200244.AA15863@turing.cse.nau.edu>
From: sbw@turing.cse.nau.edu (Steve Wampler)
Date: Tue, 19 Mar 1991 19:44:00 MST
In-Reply-To: isidev!nowlin@uunet.uu.net's mail message of Mar 19, 19:35.
X-Mailer: Mail User's Shell (7.2.0 10/31/90)
To: icon-group@cs.arizona.edu
Subject: Re: longstr oops
On Mar 19 at 19:35, isidev!nowlin@uunet.uu.net writes:
}
} The 'while' was not a mistake. The program I posted with test data and a
} main procedure in it worked just fine with a 'while' instead of an
} 'every'. I wasn't looking for iteration here. I was looking for GOAL
} DIRECTED EVALUATION. The 'while' forces the expression:
}
} m <:= *(s[i:j] ? =!l)
}
} to do everything it can to succeed. Since there's a generator in this
} expression (!l) all the strings in 'l' are generated every time through the
} loop until one of the strings is matched and it's longer than the last
} string that was matched. GOAL DIRECTED EVALUATION forces the generator to
} generate so you don't need an 'every'. When there are no more strings in
} 'l' that will match and that are longer than the last match the loop
} terminates.
}
} The 'every' works, but for a different reason. The 'every' is probably
} faster since it only iterates through the list once. It's important to
} understand why both work for different reasons. They both work though.
Along the same lines, if the list were sorted by length of strings
(longest first), you can eliminate the 'while' and the 'every' and
let's GDE do it's thing. It just doesn't seem worth it do so...
And anyway, I definitely like Bob Alexander's solution more.
--
Steve Wampler
{....!arizona!naucse!sbw}
{sbw@turing.cse.nau.edu}
From kwalker Tue Mar 19 21:22:43 1991
Received: from gacham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA29427; Tue, 19 Mar 91 21:22:43 -0700
Date: Tue, 19 Mar 91 21:22:41 MST
From: "Kenneth Walker" <kwalker>
Message-Id: <9103200422.AA03634@gacham.cs.arizona.edu>
Received: by gacham.cs.arizona.edu; Tue, 19 Mar 91 21:22:41 MST
In-Reply-To: <9103200233.AA07937@uunet.UU.NET>
To: icon-group
Subject: Re: longstr oops
> Date: Tue, 19 Mar 91 21:33:06 -0500
> From: isidev!nowlin@uunet.uu.net
>
> The 'while' was not a mistake. The program I posted with test data and a
> main procedure in it worked just fine with a 'while' instead of an
> 'every'. I wasn't looking for iteration here. I was looking for GOAL
> DIRECTED EVALUATION. The 'while' forces the expression:
>
> m <:= *(s[i:j] ? =!l)
>
> to do everything it can to succeed. Since there's a generator in this
> expression (!l) all the strings in 'l' are generated every time through the
> loop until one of the strings is matched and it's longer than the last
> string that was matched. GOAL DIRECTED EVALUATION forces the generator to
> generate so you don't need an 'every'. When there are no more strings in
> 'l' that will match and that are longer than the last match the loop
> terminates.
>
> The 'every' works, but for a different reason. The 'every' is probably
> faster since it only iterates through the list once. It's important to
> understand why both work for different reasons. They both work though.
I agree that both work. However, I don't feel the reason is that much
different. In both cases, goal directed evaluation occurs within
the expression to satisefy the <:= operator. When it succeeds within
the while expression, evaluation starts over from the begining of the
list and continues till it finds the next value that satisefies the
operator. The process is potentially quadratic in the size of the list
[1 + 2 + 3 + ... + n = n*(n+1)/2]. When the expression succeeds in the
every expression it is resumed and goal-directed evaluation continues
the search where it left off - a linear process.
I suspect there are some properties of a list that cannot be computed
with one linear pass but can be computed with the "while" approach
though I haven't come up with one after a few minutes of thought.
Ken Walker / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
+1 602 621-4252 kwalker@cs.arizona.edu {uunet|allegra|noao}!arizona!kwalker
From icon-group-request@arizona.edu Wed Mar 20 12:53:41 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA27344; Wed, 20 Mar 91 12:53:41 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Wed, 20 Mar
1991 12:53 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA28187; Wed, 20 Mar 91
11:37:30 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Wed, 20 Mar 1991 12:53 MST
Date: 20 Mar 91 17:10:35 GMT
From: usc!sdd.hp.com!news.cs.indiana.edu!ux1.cso.uiuc.edu!midway!ellis.uchicago.edu!goer@ucsd.edu
(Richard L. Goerwitz)
Subject: RE: Comment on longstr.icn (will this thread die?)
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <3AFF72310C6028A5@Arizona.edu>
Message-Id: <1991Mar20.171035.14579@midway.uchicago.edu>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: University of Chicago
References: <9103200028.AA02704@laguna.Metaphor.COM>
alex@LAGUNA.METAPHOR.COM (Bob Alexander) writes:
>Gee, this is fun.
Sure is.
>So here's my entry in the series of suggestions. Somehow I can't help
>but wonder if I've missed something obvious -- but if not, do I get my
>name in the growing list of credits? :-)
The credits don't fit onto one line anymore :-).
Jerry Nowlin gave this procedure its name, and started the whole dis-
cussion of whether backtracking though a list was not better than my
original (terrible) solution. Steve Wampler made the code somewhat
terser and more elegant. Ken Walker suggested turning while into
every, to make it possible to go through the list only once. Bob
Alexander pointed out that explicit handling of offsets i/j was not
necessary, as long as we were using match().
In this most recent post, I've created a static structure to hold re-
verse-sorted versions of arg 1 (l). Under normal circumstances, each in-
vocation will not contain a completely different first argument. In
most cases, the same l will be used at least two or three times. On
my machine, the magic number of re-uses for a five or six-element l,
with strings of 3-8 characters, is about 3. With three or more invo-
cations of longstr(l, s, i, j) with the same first arg, it becomes
worthwhile to sort l in reverse order, and store this list for later
use.
The worst-case scenario for this version would be if it were called
repeatedly, with different first arguments, each of which was a list
with elements of the same length. The performance, even in this case,
however, is close enough to Bob Alexander's version that it's worth
using it.
-Richard
############################################################################
#
# Name: longstr.icn
#
# Title: match longest string in a list or set of strings
#
# Authors: Jerry Nowlin, Steve Wampler, Kenneth Walker, Bob
# Alexander, and Richard Goerwitz
#
# Version: 1.8
#
############################################################################
#
# longstr(l,s,i,j) works like any(), except that instead of taking a
# cset as its first argument, it takes instead a list or set of
# strings (l). Returns i + *x, where x is the longest string in l
# for which match(x,s,i,j) succeeds. Fails if no match occurs.
#
# Defaults:
# s &subject
# i &pos if s is defaulted, otherwise 1
# j 0
#
# Errors:
# The only manual error-checking that is done is to test l to
# be sure it is, in fact, a list or set. Errors such as non-
# string members in l, and non-integer i/j parameters, are
# caught by the normal Icon built-in string processing and sub-
# scripting mechanisms.
#
############################################################################
#
# Links: none
#
############################################################################
procedure longstr(l,s,i,j)
local elem, tmp_table
static l_table
initial l_table := table()
#
# No-arg invocation wipes out all static structures, and forces an
# immediate garbage collection.
#
if (/l, /s) then {
l_table := table()
collect() # do it NOW
return # return &null
}
#
# Is l a list, set, or table?
#
type(l) == ("list"|"set"|"table") |
stop("longstr: list, table, or set expected (arg 1)")
#
# Sort l longest-to-shortest, and keep a copy of the resulting
# structure in l_table[l] for later use.
#
if /l_table[l] := [] then {
tmp_table := table()
# keys = lengths of elements, values = elements
every elem := !l do {
/tmp_table[*elem] := []
put(tmp_table[*elem], elem)
}
# sort by key; stuff values, in reverse order, into a list
every put(l_table[l], !sort(tmp_table,3)[*tmp_table*2 to 2 by -2])
}
#
# First element in l_table[l] to match is the longest match (it's
# sorted longest-to-shortest, remember?).
#
return match(!l_table[l],s,i,j)
end
From ralph Thu Mar 21 14:30:32 1991
Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA07095; Thu, 21 Mar 91 14:30:32 -0700
Date: Thu, 21 Mar 91 14:30:30 MST
From: "Ralph Griswold" <ralph>
Message-Id: <9103212130.AA13645@cheltenham.cs.arizona.edu>
Received: by cheltenham.cs.arizona.edu; Thu, 21 Mar 91 14:30:30 MST
To: icon-group
Subject: An Optimizing Compiler for Icon
Icon Compiler for UNIX Platforms
A preliminary release of the optimizing compiler for the Icon programming
language is now available. This compiler generates stand-alone executable
files unlike the Icon interpreter. The compilation process itself is slow
compared with the interpreter, but the resulting executable files run
much faster than interpreted ones.
The Icon compiler produces C code, so you'll need a C compiler to use it.
The preliminary release corresponds approximately to Version 7.6 of Icon
and does not have all Version 8 features. Version 8 of the compiler will
be released later.
The preliminary release is now available via FTP for several UNIX platforms.
The presently available platforms are:
DECstation 3100 running Ultrix
HP 9000/330 running HP/UX
Iris 4D running IRIX
NeXT running Mach
Sequent Symmetry running DYNIX
Sun 3 Workstation running SunOS
Sun 4 Workstation running SunOS
VAX running 4.3 BSD
Implementations for other platforms will be added as they are completed.
The present release is in object format. Complete source code for the
compiler will be released later.
To get a copy of the Icon compiler, do an anonymous FTP to cs.arizona.edu.
Then cd to /icon/v8/Compiler. There are two subdirectories, Docs and
Packages.
The subdirectory Docs contains PostScript for an installation manual (IPD165)
and a user's guide (IPD157). You should print and read these documents before
getting a copy of the compiler.
The subdirectory Packages contains several additional subdirectories,
one for each presently supported platform. The subdirectory names identify
the platforms.
See the READ.ME files in the various directories for additional information.
Please direct any questions to me, not icon-group.
Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
+1 602 621 6609 ralph@cs.arizona.edu uunet!arizona!ralph
From ralph Thu Mar 21 17:20:12 1991
Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA11895; Thu, 21 Mar 91 17:20:12 -0700
Date: Thu, 21 Mar 91 17:20:11 MST
From: "Ralph Griswold" <ralph>
Message-Id: <9103220020.AA20593@cheltenham.cs.arizona.edu>
Received: by cheltenham.cs.arizona.edu; Thu, 21 Mar 91 17:20:11 MST
To: icon-group
Subject: Icon compiler
If you have troubles running the Icon compiler on your system, first
check the information in the READ.ME file in our FTP area for your
platform. If, for example, you're running a different version of
the operating system and related software from the one on which the
object files of the compiler are based, you may have difficulties.
We can't hope to provide variants for different versions of software.
If you can't run our object distribution, please be patient -- we'll
have source code available later.
Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
+1 602 621 6609 ralph@cs.arizona.edu uunet!arizona!ralph
From mailrus.cc.umich.edu!ames!amdcad!netcom!pbewig@hellgate.utah.edu Fri Mar 22 10:15:54 1991
Received: from univers.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA08183; Fri, 22 Mar 91 10:15:54 -0700
Received: from hellgate.utah.edu by univers.cs.arizona.edu; Fri, 22 Mar 91 10:15:52 MST
Received: from mailrus.cc.umich.edu by hellgate.utah.edu (5.65/utah-2.16s-cs)
id AA12951; Fri, 22 Mar 91 10:15:38 -0700
Received: from ames.arc.nasa.gov by mailrus.cc.umich.edu (5.61/1123-1.0)
id AA11495; Fri, 22 Mar 91 12:13:19 -0500
Received: by ames.arc.nasa.gov (5.64/1.2); Fri, 22 Mar 91 09:15:31 -0800
Received: from netcom.UUCP by AMD.COM (4.1/SMI-4.1-AMD-90.12.27)
id AA08351; Fri, 22 Mar 91 08:53:25 PST
Received: by netcom.netcom.com (/\==/\ Smail3.1.20.1 #20.4)
id <m0jJpFY-000CQyC@netcom.netcom.com>; Fri, 22 Mar 91 08:46 PST
Message-Id: <m0jJpFY-000CQyC@netcom.netcom.com>
Date: Fri, 22 Mar 91 08:46 PST
From: mailrus.cc.umich.edu!ames!amdcad!netcom.com!pbewig@hellgate.utah.edu (Phil Bewig)
X-Mailer: Mail User's Shell (7.2.0 10/31/90)
To: icon-group@cs.arizona.edu
Subject: dBASE procedures
Does anyone have available a library of procedures for maintaining
a dBASE database?
Thanks for any help.
Phil Bewig .. pbewig@netcom.com
From icon-group-request@arizona.edu Fri Mar 22 10:37:22 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA08650; Fri, 22 Mar 91 10:37:22 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Fri, 22 Mar
1991 10:36 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA07723; Fri, 22 Mar 91
09:34:20 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Fri, 22 Mar 1991 10:37 MST
Date: 22 Mar 91 16:39:13 GMT
From: pacific.mps.ohio-state.edu!linac!midway!ellis.uchicago.edu!goer@tut.cis.ohio-state.edu (Richard L.
Goerwitz)
Subject: snapshot; readability
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <BA4AE0466C602F1C@Arizona.edu>
Message-Id: <1991Mar22.163913.27902@midway.uchicago.edu>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: University of Chicago
I'm not claiming that this is particularly elegant, or even correct.
I just hacked it together this morning because I have a doc in which
90% of the strings don't fit on my terminal, and which snapshot(),
as it is in the IPL, produces an unreadable display.
Does anyone, in principle, have any objection to snapshot having a
notion of display length?
-Richard
----------
procedure snapshot(title,len)
local bar1, bar2, bar3, is, is0, prefix, titlel, placement, POS
/title := ""
prefix := "&subject = "
is := image(&subject)
is0 := *image(&subject[1:&pos]) | fail # quick exit if bogus
#
# Set up top and bottom bars (not exceeding len width, if
# len is nonnull). Fit title into top bar (bar1).
#
bar1 := bar3 := repl("-", *is + *prefix + 4)[1:\len-4|0]
# in *is + *prefix + 4, the 4 is for two vbars/two spaces
titlel := (*title > *bar3-4) | *title[1:\len-4|0]
bar1[3+:titlel] := title[1+:titlel]
#
# Write bar1, then a spacer (bar2). Then write out len-size chunks
# of &subject, with the | pointer-line, where appropriate. Finally,
# write out bar3.
#
write(bar1)
write(bar2 := ("|" || repl(" ", *bar1 - 2) || "|"),"\n",bar2)
placement := *prefix + is0
(prefix || is) ? {
until pos(0) do {
POS := &pos - 1
write("| ", move(*bar3-4) | left(tab(0), *bar3-4), " |")
if POS < placement <= &pos then {
writes("| ")
writes(left(repl(" ", placement - POS) || "|", *bar3-4))
write(" |\n",bar2)
}
else write(bar2,"\n",bar2)
}
}
write(bar3)
return # nothing to return
end
From icon-group-request@arizona.edu Tue Mar 26 18:21:53 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA27321; Tue, 26 Mar 91 18:21:53 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Tue, 26 Mar
1991 18:21 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA25268; Tue, 26 Mar 91
17:00:08 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Tue, 26 Mar 1991 18:21 MST
Date: 26 Mar 91 23:46:39 GMT
From: midway!ellis.uchicago.edu!goer@handies.ucar.edu (Richard L. Goerwitz)
Subject: text-base utility
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <1FD63D74EC6039BC@Arizona.edu>
Message-Id: <1991Mar26.234639.27285@midway.uchicago.edu>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: University of Chicago
Sometimes it's not convenient to insert numerous and/or large blocks
of text into hash tables at run-time. Some time ago I posted some
simple routines which make it possible to perform table-like operations
on files containing key/value combinations. I've updated these rou-
tines a bit, and expanded them slightly. Instead of reposting, I've
decided to mail them out individually to anyone who asks.
-Richard
------------
From the README file:
This archive contains gettext() and associated routines. Gettext()
allows the user to maintain a file of key/value combinations such that
a call to gettext(key, FNAME) will produce value. Fails if no such
key exists. Returns an empty string if the key exists, but has no
associated value in the file named in arg 2 (FNAME). Gettext() is
intended for use in situations where keys need to be associated with
very large strings (i.e. where hand-inserting these values into hash
tables would be unwieldy, and would take up a sizable chunk of
memory).
The file format is simple. Keys belong on separate lines, marked as
such by an initial colon+colon (::). Values begin on the line
following their respective keys, and extend up to the next
colon+colon-initial line or EOF. E.g.
::sample.1
Notice how the key above, sample.1, has :: prepended to mark it
out as a key. The text you are now reading represents that key's
value. To retrieve this text, you would call gettext() with the
name of the key passed as its first argument, and the name of the
file in which this text is stored as its second argument (as in
gettext("sample.1","tmp.idx")).
::next.key
etc...
For faster access, an indexing utility is included, idxtext. Idxtext
creates a separate index for a given text-base file. If an index file
exists in the same directory as FNAME, gettext() will make use of it.
Otherwise, it just does a sequential search of the entire file (this
works fine for smaller files). Please don't change a file, once
you've run idxtext on it, except to append key/value entries to it.
If you alter the indexed portion of the file in any way, you must
reindex.
If you want a list of all the keys in FNAME, call getkeys(FNAME).
Getkeys (as one might expect) resides in the file getkeys.icn. I
guess an in-core regexp pattern search could be implemented by
stuffing all keys for a given text-base file into a list, and then
using findre.icn to match patterns agains the keys (hits could
then be retrieved via calls to gettext()).
--
-Richard L. Goerwitz goer%sophist@uchicago.bitnet
goer@sophist.uchicago.edu rutgers!oddjob!gide!sophist!goer
From icon-group-request@arizona.edu Sat Mar 30 06:33:51 1991
Resent-From: icon-group-request@arizona.edu
Received: from Arizona.edu (Merlin.Telcom.Arizona.EDU) by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA18704; Sat, 30 Mar 91 06:33:51 -0700
Received: from ucbvax.Berkeley.EDU by Arizona.edu with PMDF#10282; Sat, 30 Mar
1991 06:33 MST
Received: by ucbvax.Berkeley.EDU (5.63/1.42) id AA20646; Sat, 30 Mar 91
05:28:33 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews for
icon-group@arizona.edu (icon-group@arizona.edu) (contact
usenet@ucbvax.Berkeley.EDU if you have questions)
Resent-Date: Sat, 30 Mar 1991 06:33 MST
Date: 29 Mar 91 16:22:11 GMT
From: eru!kth.se!sunic!mcsun!ukc!mucs!m1!bevan@bloom-beacon.mit.edu (Stephen J
Bevan)
Subject: Survey Results : Perl vs Icon vs .... (> 500 lines)
Sender: icon-group-request@arizona.edu
Resent-To: icon-group@cs.arizona.edu
To: icon-group@arizona.edu
Resent-Message-Id: <E198C3D4FC6051A9@Arizona.edu>
Message-Id: <BEVAN.91Mar29162211@panda.cs.man.ac.uk>
X-Envelope-To: icon-group@CS.Arizona.EDU
X-Vms-To: icon-group@Arizona.edu
Organization: Department of Computer Science, University of Manchester
[Note I've crossposted to all the groups I send my original message
to. This was at the request of some of the respondents (sp?)]
Here are the results of my question regarding which language to use for
writing programs to extract information from files, generate reports
... etc. I initially suggested languages like Perl, Icon, Python ...
As part of my original message I said :-
> Rather than FTP all of them and wade through the documentation, I was
> wondering if anybody has experiences with them that they'd like to
> share?
I would like to thank the following people for replying :-
Dan Bernstein - brnstnd@kramden.acf.nyu.edu
Tom Christiansen - tchrist@convex.COM
Chris Eich - chrise@hpnmdla.hp.com
Richard L. Goerwitz - goer@midway.uchicago.edu
Clinton Jeffery - cjeffery@cs.arizona.edu
Guido van Rossum - guido@cwi.nl
Randal L. Schwartz - merlyn@iWarp.intel.com
Peter da Silva - peter@ficc.ferranti.com
Alan Thew - QQ11@LIVERPOOL.AC.UK
Edward Vielmetti - emv@ox.com
?? - russell@ccu1.aukuni.ac.nz
Most of the replies were about Perl, so I didn't learn much about the
other languages I suggested (other than very general things).
Even though I was originally hoping not to have to ftp any stuff, I
ended up getting the source to Python, GAWK, TCL, Icon and the texinfo
manual for Perl.
To save you going through my list of good and bad points of the
languages I looked at, here is the summary of what I see the languages
as :-
TCL - an embedded language i.e. an extension language for large
programs (IMHO only if you haven't got, or don't
like, Scheme based ones like ELK).
Perl - the de facto UNIX scripting language. You name it, and you
can probably cobble a solution together in Perl.
Beyond the fact that a lot of people use it, I can see nothing
to recommend it. It's a bit like C in that respect.
Python - Good prototyping language with a consistent design. It might
not have all the low level UNIX stuff built in, but by using
modules, its easy to add the necessary things in an ordered way.
Icon - the `nearly' language. Well designed language, that never seemed
to make it into general use. Seems to cover the ground all the
way from AWK type applications to Prolog/Lisp ones.
If I wasn't already happy with Scheme, I'd use this for more
general programming.
I would recommend people at least look at this language.
GAWK - simple scripting language. Definitely better than `old' awk.
I would only use it if the job were really simple or if
something like Python or TCL were not available.
Note I wouldn't expect anybody to make a choice on what I say. I
suggest you get the source/manuals yourself and have a good long look
at the language/implementation before you decide.
For the types of things _I_ want to do, it would be a tie between Icon
and Python. Having said that, given that I'd have to extend both to
cover the sort of things I want to do, I'll probably use Scheme
instead (ELK in particular). The reason I didn't just use Scheme in
the first place is that I was hoping one of the languages would have
all the facilities I want without me having to extend them myself.
Before, the summary of the languages themselves, I thought I'd try and
list some of the things I was looking for. (Actually, I showed an
earlier version of this summary to somebody and they didn't understand
some of the terms I was using, so this is my attempt at an
explanation). Note that most of the things are to do with structuring
the code and alike. This is not the sort of thing you usually worry
about when writing small scripts, but I plan to convert and write a
number of tools, some of which are around the 1000 LOC mark. For
example, I'd like to convert a particular lex/yacc/C program I have
into the chosen language.
You can skip ahead to the actual summary by searching for SUMMARY.
(Well I can do this in GNUS, I don't know about other news readers
like rn)
Packages/Modules
----------------
These are a mechanism for splitting up the name space so that function
name clashes are reduced. Most systems work by declaring a package
and then all functions listed from then on are members of that
package. You then access the functions using the package prefix, or
import the whole package so that you don't have to use the prefix.
The following is an example in CommonLisp :-
;;; foo.lsp ;;; bar.lsp
(in-package 'foo) (in-package 'bar)
(export '(bob)) (export '(bob))
(defun bob (a b) ...) (defun bob (x) ...)
;;; main.lsp
(foo:bob 10 20)
(bar:bob 3)
Packages are not perfect, but they do help. You can get the same
effect by declaring implicit package prefixes :-
;;; foo.lsp ;; bar.lsp
(defun foo-bob (a b) ...) (defun bar-bob (x) ...)
;; main.lsp
(foo-bob 10 30)
(bar-bob 4)
The advantage of packages over this is that you don't have to use a
package prefix in the package itself when you want to call a function.
This can be a saving if you have lots of functions in a package, and
only a few are exported.
Exception Handling
------------------
This is useful for dealing with error that shouldn't happen. e.g.
reaching the end of the file when you were looking for some valid
data. For example, in CommonLisp :-
(defun foo (x y)
...
(if (catch 'some-unexpexted-error (bar x y) nil)
(handle-the-exception ...)
(define bar (a b)
...
(if (something-wrong) (throw 'some-unexpected-error t))
...)
Here the function `foo' calls `bar', and if any error occurs whilst
processing, it is handled by the exception handler. (The example is a
bit primitive as I'm trying to save space).
The advantage of this is that you don't have to explicitly pass back
all sorts of error codes from your functions to handle unusual errors.
It also usually means you won't have so many nested `if's to handle
the special cases, therefore, making your code clearer.
Records/Tuples/Aggregates/Structs
---------------------------------
It's handy to be to define objects that contain certain number of
elements. You can then pass these objects around and access the
individual bits. For example in CommonLisp :-
(defstruct point x y)
This declares `point' as a type containing two items called `x' and
`y'. Some languages don't name the items, they rely on position
instead. I see these as equivalent (assuming you have some sort of
pattern matching)
Provide/Require
---------------
This is a primitive facility for declaring that one package depends on
another one. For example in CommonLisp :-
;;; foo.lsp
(defun bob (a b) ...)
(provide 'foo)
;;; main.lsp
(require 'foo)
(bob 10 3)
The above declares that the file `foo' provides the function `bob' and
that the file `main' requires `foo' to be loaded for it to work.
So when you load in `main' and `foo' hasn't been loaded, it is
automatically loaded by the system.
C Interface
-----------
How easy is it to call C from the language.
Is there a dynamic loading facility i.e. do I have to recompile the
program to use some arbitrary C code, or can it load in a .o file at
runtime?
Arbitrary Restrictions
----------------------
This really applies to the implementations rather than the languages.
However, as there is only one implementation for most of the languages
I'm looking at, they tend to be synonymous
If there is one thing I hate about an [implementation of] a languages
its arbitrary restrictions. For example, `the length of the input
line must not exceed 80 characters', or "strings must be less than 255
characters long". I can except some initial restrictions if :-
1) they are documented.
2) they will be removed in future versions.
Note. I realise that some restrictions are not arbitrary, or at least
not under the control of the language implementor e.g. the number of
open files under UNIX.
SUMMARY
-------
If you want to know more about the languages, there follows a brief
description of the languages, how to get an implementation and some
good and bad points as I see them. Each point is preceded by a
character indicating the type of point :-
+ good point
- bad point
* just a point to note
! subjective point
Other than the `*' items, I guess it is all subjective, however, I've
tried to put things that are generally good/bad in `+'/`-' and limit
really subjective statements to `!'.
TCL - version 4.0 patch level 1
-------------------------------
TCL (Tool Command Language) was developed by John Ousterhout at Berkeley.
It started out as a small language that could be embedded in
applications. It has now been extended by some people at hackercorp
into more of a general purpose shell type programming language.
It is described by Peter Da Silva (one of the people who extended it)
as :-
> TCL is like a text-oriented Lisp, but lets you write algebraic
> expressions for simplicity and to avoid scaring people away.
The language itself for some reason reminds me of csh even though I
can only point to two things (the use of `set' and `$') which a
definitely like csh.
Unless you have other ideas about what an extension language should
look like (e.g. IMO it should be Scheme), then I'd definitely
recommend this. It's small, and integrates easily with other C
programs (you can even have multiple TCL interpreters in an
application!)
Version 5.0 is available by anonymous ftp from sprite.berkeley.edu as
tk.tar.Z (its part of an X toolkit called Tk). Note, although it has
a higher number than the one above, does not include the extensions
mentioned above. These will apparently be integrated soon.
Version 4.0 pl1 is available by anonymous ftp from
media-lab.ai.mit.edu (sorry can't remember the exact path)
+ exceptions.
+ packages, called libraries
However there is only one name-space. The libraries are used as a
way of storing single versions of code rather than as a solution to
the name space pollution problem.
+ provide/require
+ C interface is excellent. You can easily go TCL->C and C->TCL.
- No dynamic loading ability that I'm aware of.
- Arbitrary line length limit on `gets' and `scan'. i.e. the commands
that read lines from files/strings. I would guess this will go
away in the next version.
- No records. The main data types are strings/lists/associative arrays
+ extensive test suite included.
! doesn't look to have been tested on many systems. The above
version actually failed to link on a SPARCstation running SunOS 4.1
as the source refers to `strerror'. This has apparently been fixed
in patch level 2.
+ lots of example code included in distribution.
+ extensive documentation (all in nroff)
+ Can trace execution.
! To make arguments evaluate, you must enclose them in {} or []
This shouldn't be a problem, except that being used to Lisp like
languages I expect to quote constants.
! The extensions though useful, are not seamless. e.g. some string
facilities are in the core language and some in the extensions.
This might happen when the hackercorp extensions are officially
merged with the Berkeley core language and released by Berkeley.
+ As part of the extensions, you get tclsh. This is a shell which you
can type command directly into.
+ scan contexts. This is sort of regular expressions on files rather
than strings.
Python - version 0.9.1
----------------------
Available by anonymous ftp from wuarchive.wustl.edu as
pub/python0.9.1.tar.Z or for Europeans via the info server at
hp4nl.nluug.nl
I couldn't think of a good way to describe this, so I'm blatantly
copying the following from the Python tutorial :-
Python is a simple, yet powerful programming language that bridges
the gap between C and shell programming, and is thus ideally
suited for rapid prototyping. Its syntax is put together from
constructs borrowed from a variety of other languages; most
prominent are influences from ABC, C, Modula-3 and Icon
So far so good, here's some more from the tutorial :-
Because of its more general data types Python is applicable to a
much larger problem domain that Awk or even Perl, yet most simple
things are at least as easy in Python as in those languages.
i.e. Python seems to be designed for larger tasks than you would
undertake using the shell/awk/perl.
+ packages.
+ exceptions (based on Modula 2/3 modules)
+ records (actually tuples. I'm not sure they do everything I want
as the documentation is a bit vague in this area)
Other main types are lists, sets, tables (associative arrays)
+ C interface is good. No dynamic linking that I am aware of.
- Arbitrary Restrictions
line length limit on readline.
This has been fixed and I would guess will appear in the next release.
+ lots of example python programs included.
There is even a TCL (version 2ish) interpreter!
+ Object oriented features.
Based on Modula 3 i.e. classes with methods, all of which are
virtual (to use a C++ term).
* any un caught errors produce a stack trace.
+ disassembler included
+ can inspect stack frames via traceback module
- no single step or breakpoint facility
(maybe in the next release)
+ functions can return multiple values.
* The default output command `print' inserts a space between each
field output.
! I don't like the above, or rather I would like the option of not
having it done.
* Documentation includes tutorial and library reference as TeX files.
Both are incomplete, but there is enough in them to be able to
write Python code. The reference manual is not yet finished, and
is not currently distributed with the source.
+ Python mode for Emacs.
(Its primitive, but its a start)
Icon - version 8
----------------
To quote from one of the Icon books :-
Icon is a high-level, general purpose programming language that
contains many features for processing nonnumeric data,
particularly for textual material consisting of string of
characters.
Available :-
In USA :- ??, consult `archie'.
In UK :- I picked up a copy form the sources archive at Imperial College.
The JANET address is 00000510200001
- no packages. Everything is in one namespace. However ...
- no exceptions.
+ Object oriented features.
An extension to the language called Idol is included.
This converts Idol into standard Icon.
Idol itself looks (to me) like Smalltalk.
+ has records. Other types include :- sets, lists, strings, tables
+ unlimited line length when reading
(Note. the newline is discarded)
! The only language that has enough facilities to be able to re-write
some of my Lex/Yacc code.
+ stack trace on error.
+ C interface is good. Can extend the language by building `personal
interpreter'. No dynamic linking.
+ extensive documentation
9 technical reports in all (PostScript and ASCII)
- Unix interface is quite primitive.
If you just want to use a command, you can use `callout', anything
more complicated requires building a personal interpreter (not as
difficult as it may sound)
+ extensive test suite
+ Usenet group exists specifically for it - comp.lang.icon
- Unless you use Idol, all procedures are at the same level
i.e. one scope.
- regular expressions not supported.
However, in many cases, you can use an Icon functions `find',
`match', `many' and `upto' instead.
+ Can trace execution.
* Pascal/C like syntax
i.e. uses {} but has a few more keywords than C.
+ lots of example programs included.
+ can define your own iterators
i.e. your own procedures for iterating through arbitrary structures.
+ co-expressions. Powerful tool, hard to explain briefly. See
chapter 13 of the Icon Programming Language.
- co-expressions haven't been implemented on Sun 4s (the type of
machine I use)
+ has an `initial' section in procedures that is only ever executed
once and allows you to initialise C like static variables with the
result of other functions (unlike C).
+ arbitrary precision integers.
As well as the excellent documentation included in the source, there
are two books on Icon available (I skimmed through both of them) :-
The Icon Programmming Language
Ralph E. Griswold and Madge T. Griswold
Prentice Hall 1983
The Implementation of the Icon Programmming Language
Ralph E. Griswold and Madge T. Griswold
Princeton University Press 1986
The second one is particularly useful if you are considering
extending Icon yourself. Appendix E of this book also contains a list
of projects that could be undertaken to extend and improve Icon.
Here are some projects, that if implemented, would greatly improve the
usefulness of Icon :-
E.2.4 Add a regular expression data type. Modify the functions find
and match to perate appropriately when their first argument is a
regular expression.
E.2.5 \ All of these suggest extending
E.5.4 | the string scanning facilities to
E.5.5 / cope with files and strings in a uniform way.
E.12.1 Provide a way to load functions (written in C) at runtime
Perl
----
Available :-
USA :- ??, consult `archie'
UK :- Imperial sources archive
I received more responses about Perl than anything else, so I that
most people already know a lot about the language.
Here are some edited highlights from a message I received from Tom
Christiansen :-
First some good words from Tom :-
> ... I shall now reveal my true colors as perl disciple
> and perhaps not infrequent evangelist. Perl is without question the
> greatest single program to appear to the UNIX community (although it runs
> elsewhere too) in the last 10 years. It makes progamming fun again. It's
> simple enough to get a quick start on, but rich enough for some very
> complex tasks.
> ... perl is a strict superset of sed and awk, so much so that s2p and
> a2p translators exist for these utilities. You can do anything in
> perl that you can do in the shell, although perl is not strictly
> speaking a command interpreter. It's more of a programming language.
and now some of the low points of Perl. [Note this is only a small
part of a long post, that explained a lot of good things about Perl.
As most people seem to use/like Perl, I thought I'd highlight some of
the things wrong with the language, and what better place to get
information than from the designer of the language. Note also that
this is from a message dated June 90, so some of it may be out of date.]
Larry Wall :-
> The basic problem with Perl is that it's not about complex data structures.
> Just as spreadsheet programs take a single data structure and try to
> cram the whole world into it, so too Perl takes a few simple data structures
> and drives them into the ground. This is both a strength and a weakness,
> depending on the complexity and structure of the problem.
>
> The basic underlying fault of Perl is that there isn't a real good way
> of building composite structures, or to make one variable refer to a piece
> of another variable, without giving an operational definition of it.
>
> ... In a sense, the problem with Perl is not that it is too
> complicated or hard to learn, but that perhaps it is not expressive
> enough for the effort you put into learning it. Then again, maybe it
> is. Your call. Some people are excited about Perl because, despite
> its obvious faults, it lets them get creative.
>
> There are many things I'd do differently if I were designing Perl from
> scratch. It would probably be a little more object oriented. Filehandles
> and their associated magical variables would probably be abstract types
> of some sort. I don't like the way the use of $`, $&, $' and $<digit>
> impact the efficiency of the language. I'd probably consider some kind
> of copy-on-write semantics like many versions of BASIC use. The subroutine
> linkage is currently somewhat problematical in how efficiently it can
> be implemented. And of course there are historical artifacts that wouldn't
> be there.
I think the above is a vary fair summary of the low points of the
language. At one point it says `... perhaps it is not expressive
enought for the effort you put into learning it. Then again maybe it
is. Your call'. Well _my_ call is that it is not.
Note I didn't actually pick up the source to this, just the manual.
Consequently I haven't been able to check all the points listed below.
+ packages.
! Note in the examples that I've seen in comp.lang.perl, people don't
seem to use the facility, instead they put everything directly in
`main' (i.e. the top level scope) rather than in the local scope.
+ exceptions
+ provide/require
* C Interface ?? I couldn't find this in the documentation I had.
+ No arbitrary restrictions
+ has a source level debugger
+ Well integrated with Unix (nearly all system calls are built in !)
! However, like Unix, only one name space seems to be used (see above)
* C like syntax
+ source contains texinfo manual.
You can always buy the (Camel) book for more information.
- no records. Other types lists, strings, tables (associative arrays)
* some types have distinct scopes.
! You prefix the name with `@', '$', '%' to indicate which type
you want. This is one of the ugliest things I've ever seen.
! Uses lots of short strings to contain often used things e.g. `$_'
is the current input, `$.' is current line number. I guess some
people must like this, but I prefer names like `input' and
`line-number' myself.
+ includes programs to convert existing awk, find and sed scripts into
Perl.
+ Usenet news group - comp.lang.perl
+ Perl mode for Emacs.
GAWK
----
Available :-
USA :- prep.ai.mit.edu, probably other places as well. Consult `archie'
UK :- Imperial sources archive.
A few points about GNU awk as it seems to fix some of the problems
with `old' awk.
- no packages
- no exceptions
- no C interface
- no records
+ allows user defined functions
+ can read and write to arbitrary files
+ much more informative error messages than the old awk.
From ralph Sat Mar 30 07:47:16 1991
Received: from cheltenham.cs.arizona.edu by megaron.cs.arizona.edu (5.61/15) via SMTP
id AA19362; Sat, 30 Mar 91 07:47:16 -0700
Date: Sat, 30 Mar 91 07:47:14 MST
From: "Ralph Griswold" <ralph>
Message-Id: <9103301447.AA11191@cheltenham.cs.arizona.edu>
Received: by cheltenham.cs.arizona.edu; Sat, 30 Mar 91 07:47:14 MST
To: icon-group
Subject: Icon compiler
The Icon compiler is now available for five more UNIX platforms:
Intel 386 running System V
Macintosh running AU/X
PS/2 running AIX
UNIX PC (3B1)
VAX-11 running Ultrix
To get a copy of the compiler, do an anonymous FTP to cs.arizona.edu,
cd /icon/v8/Compiler/Packages, and see what's there. Documentation for
the compiler is in /icon/v8/Compiler/Docs.
Please check the READ.MEs for the specific implementations in Packages --
since the Icon compiler presently is distributed in object form, operating
system and related software must be compatible. For example, some sites
have been unable to run the Sun 4 implemenation of the Icon compiler because
they are using a version of the system software that is earlier than the
version needed by the Icon compiler.
If you are successful in getting the Icon compiler to run on a different
configuration than listed in a READ.ME, please let us know so that we
can add that information for other users.
Ralph Griswold / Dept of Computer Science / Univ of Arizona / Tucson, AZ 85721
+1 602 621 6609 ralph@cs.arizona.edu uunet!arizona!ralph