The Icon language [was: Re: PEP 285: Adding a bool type]
Steve Holden
sholden at holdenweb.com
Fri Apr 5 16:50:17 EST 2002
"Alex Martelli" <aleax at aleax.it> wrote in message
news:QPoq8.44596$pT1.1256392 at news1.tin.it...
> Chris Barker wrote:
> ...
> > do think that that is how it should be in the ideal language. The
> > concept of True or False is distinct from the concept of a number, and
> > I'd like to see it stay that way in the language.
>
> Have a look at Icon (or Snobol, but that was goto-based... Icon's
> much nicer). It CENTERS on this concept.
>
[...]
>
> If you want "booleans" given the respect you seem to think they
> deserve, you may actually be happier with Icon than with Python.
> Me, I think that Python's decision regarding "concrete nothings",
> although less pure, was more pragmatically useful than Icon's
> purity in distinguishing "something or nothing" from any actual
> kind of "somethings", and contributed to Python's greater success.
> But - study Icon, try it out on some concrete programming task,
> and make up your own mind.
>
Or take a look at this old program. Note especially the "/owid := 72" idiom,
used to default a variable, and the "every" construct, which forces a
context in which all values oif an expression are used. Icon was very
advanced for its time, but I don't think it really took the object-oriented
paradigm on board. Certainly the standard OO system was klugey, and never
became part of the language.
regards
Steve
#
# classify.icn: read a mail file and produce a subject-sorted
# list of mail items and replies, or an index to
# the mail file.
#
# (c) Copyright Steve Holden 1991
#
# Identification: @(#)classify.icn 1.2
# SCCS source: /export/home/steve/dev/tools/src/SCCS/s.classify.icn
# Last change: 10:37:32 92/09/14
# Retrieved on: 20:46:13 94/02/15
#
# Bugs: Sort is case-sensitive.
# Craps out on overlength index lines.
# (Possibly elsewhere) subjects are not always
# well-trimmed.
#
#
link mlib # mail i/o library
procedure main(arg)
while arg[1][1] == "-" do # handle arguments
case (o :=pop(arg))[2] of {
"i": indexrun := ""
default: stop("Unrecognised classify option: ",o)
}
if *arg = 0 then arg := [ "-" ]
if *arg > 1 then stop("Bug: can only handle one file at a time. Sorry.")
ttls := table([])
refs := table([])
msg := []
while filename := pop(arg) do {
ifn := OpenMail(filename) | stop("Cannot open file ",filename)
while put(msg,ReadMail(ifn))
}
every m := 1 to *msg do {
trim( \(msg[m].headers["Subject"][1]) | "** Untitled Mail" ) ?
if (="Re:" & tab(upto(~':\t ')))
then refs[ms := tab(0)] |||:= [m]
else ttls[ms := tab(0)] |||:= [m]
}
tlst := sort(ttls)
rlst := sort(refs)
while (*tlst > 0) | (*rlst > 0) do { # for each subject...
# write("## ",*tlst,"+",*rlst)
if (rlst[1][1] << tlst[1][1]) | (*tlst = 0)
then { # orphaned reference
subject := rlst[1][1]
refs := pop(rlst)[2]
ttls := []
} else { # message
subject := tlst[1][1]
ttls := pop(tlst)[2]
if subject == rlst[1][1] # handle references, if any
then refs := pop(rlst)[2]
else refs := []
}
if \indexrun then {
present(subject,ttls,refs)
} else
every WriteMail(msg[!ttls | !refs])
}
end
procedure present(s, t, r, owid)
local ts # temp string for message numbers
/owid := 72
ts := ""
if *t > 0 then {
every i := 1 to *t-1 do ts ||:= t[i] || ", "
ts ||:= t[-1]
} else ts := "-"
if *r > 0 then {
ts ||:= "; "
every i := 1 to *r-1 do ts ||:= r[i] || ", "
ts ||:= r[-1]
}
s ||:= repl(" ",3-(*s % 3))
write(s,right(ts,owid-*s,".. "))
return
end
More information about the Python-list
mailing list