|Pronouns in programming language? email@example.com (John Fremlin) (2000-02-27)|
|Re: Pronouns in programming language? firstname.lastname@example.org (Axel Schairer) (2000-02-28)|
|Re: Pronouns in programming language? email@example.com (2000-02-28)|
|Re: Pronouns in programming language? firstname.lastname@example.org (2000-02-28)|
|Re: Pronouns in programming language? email@example.com (2000-02-28)|
|Re: Pronouns in programming language? firstname.lastname@example.org (Lieven Marchand) (2000-02-28)|
|Re: Pronouns in programming language? email@example.com (Hamish Atkinson) (2000-02-28)|
|Re: Pronouns in programming language? firstname.lastname@example.org (2000-02-28)|
|Re: Pronouns in programming language? email@example.com (H. Ellenberger) (2000-02-28)|
|Re: Pronouns in programming language? firstname.lastname@example.org (2000-03-03)|
|[12 later articles]|
|Date:||28 Feb 2000 02:59:05 -0500|
|Organization:||Deja.com - Before you buy.|
John Fremlin <email@example.com> wrote:
> Has any programming language/compiler implemented pronoun like
Shell languages (like bash, tcsh, etc), have "!" notation to refer to
previously typed in commands. For example, "!!" is the previous
command, "!33" is command number 33 in the saved history of commands,
and "!?foo" is the most recent command containing the string "foo".
See the man page for more examples.
The (old traditional) unix "bc" command provides a calculator, where
"." refers to the previous result. I think of seen variants of that
facility in other math packages, such as Maple.
The "Perl" programming language has a default "scalar" variable, "$_"
which is used when none are specified (and a separate list version
"@_"). Many Perl expressions will refer to one of these two variables
unless explicitly overridden. Many looping constructs will use the
"$_" scalar variable as the index variable by default. Arguments to
procedures are passed in the "@_" list variable. Find a good Intro to
Perl book for more details.
My concern with your example is with the "modifiability" of programs
using your pronouns or elisions. When lines of code start getting
added between the line producing the value and the line consuming it,
the human reading the code can get more and more confused. Since you
use the word "pronoun", I get the feeling that you want the program to
be able to refer to the results of *particular* other parts of the
program by position or adjacency. And my complaint is that adjacency,
at least, can get arbitrarily fuzzy as code gets added.
The Shell "!" notation is geared towards referring to the text of
typed in commands.
The bc "." notation is geared towards a "current result", or perhaps
the top of a stack of results in a stack machine.
The Perl "_" variables are special "current result" variables,
modified implicitly by most commands. All the commands modify the
same implied variable. So one thing that needs to be understood in
order to read Perl programs is how and when these implied variables
get modified. It might sound complicated, but I haven't had any
confusion in practice.
Perl string pattern matching can be a different story. There you us
what are called "regular expressions" to match strings, possibly
saving pieces of the matched string. The pieces are stored in
numbered variables -- the first piece in "$1", the second in "$2", and
so forth. The problem is that if you execute another command that
modifies these variables, all the original values are lost. After
getting burned my this a couple times while "evolving" Perl programs,
I learned just to assign all the numbered variables to named variables
(for example, "$tag = $1 ; $value = $2 ;" etc.). And hence my
nervousness about adjacency rules a couple paragraphs back.
Perl's got the most interesting and useful notion of implied variables
that I know of, though I have not done a survey. The shell "!" notation
refers to the text of typed in commands rather than variables, so is
more an aid to typing in shell programs interactively than making the
programs more terse.
I hope you find my response useful.
> [I can think of some examples. Lisp LET (typically implemented as
> an anonymous procedure) permits you to assign names to expressions
> for very limited scopes. Cobol lets you elide comparison operands,
> something like IF FOO-BAR LESS THAN 12 OR GREATER THAN 42 THEN
> ... -John]
I've also heard that some languages have experimented with permitting
n-ary comparisons (eg, "1 < x < 10" instead of "x > 1 && x < 10", but
they always conclude that its a mistake. Hard to understand code gets
produced, and I think there's a parsing problem, but I forget what.
Return to the
Search the comp.compilers archives again.