Why is Python popular, while Lisp and Scheme aren't?
Jay O'Connor
joconnor at cybermesa.com
Fri Nov 8 01:59:36 EST 2002
In article <uso6sqgn3fmcb0 at corp.supernews.com>, "Cameron Laird"
<claird at lairds.com> wrote:
> In article <20021108.121940.201305624.9010 at cybermesa.com>, Jay O'Connor
> <joconnor at cybermesa.com> wrote:
>>In article <uso37rcegqdpf6 at corp.supernews.com>, "Cameron Laird"
>><claird at lairds.com> wrote:
>>
>>> In article <20021108.115059.1034949299.9010 at cybermesa.com>, Jay
>>> O'Connor <joconnor at cybermesa.com> wrote:
>>> .
>>> .
>>> .
>>>>Yes, I was a Python advocate in a TCL shop for awhile and had a hard
>>>>time convincing
>>>>people that there was a qualitative difference between.
>>>>
>>>>set x [lindex [lindex $var 5] 5]
>>>>
>>>>and
>>>>
>>>>x = var[5][5]
>>> .
>>> .
>>> .
>>> Tcl has definite problems that are close to what this example
>>> expresses.
>>> Somebody's tilting the idiomatic playing field, though; the
>>> experienced
>>> Tcl-ers I know would write
>>> set x $var(5,5)
>>> rather than deal with the monstrosity above.
>>
>>Unfortunately the code I was dealing with was using lists of lists of
>>lists nested many, many levels deep with no documentation in the code as
>>to why '5' was a particular field.
>>
>>Try hundreds to thousands of lines of 'the monstrosity above'
> .
> .
> .
> You have my sympathy. Are you making a subtle point that Tcl invites
> bad coding?
No, I'm making the point that TCL is syntactically weaker at expressing
complex structures and this is a qualitative difference between the two
languages
Expanding beyond just getting a single value from a multidimensional list
is what happens when you start throwing in lrange for slicing and other
ways of unwrapping the structure. TCL's approach of using 'functionName
$var1 var2' leads quite easily and naturally to such 'monstrosities' as a
natural consequence of the stucture of the language. When you start
throwing in heterogenous structures, especially dealing with nested
arrays (dictionaries) , etc..the syntactical shortcut doesn't scale very
well to dealing with complex data. (incidentally, your example does not
do the same thing.
set l1 "1 2 3"
set l2 "4 5 6"
set l3 [list $l1 $l2]
set x [lindex [lindex $l3 1] 1]
puts $x
results in '5'
using 'set x(1,1)
results in an error
> What you describe sounds like the moral equivalent of a
> Pythoneer writing
> i = 0
> while 1:
> if i < 73:
> break
> i = i + 1
> ...
> rather than
> for i in range(limit):
If limit is a variable based on conditions within the loop, then your
first example is a valid way of expressing counting until a conditional
is reached. Or, under circumstances, the basic approach is valid and
would only be 'wrong' in the situation where the loop end was static.
--
Jay O'Connor
joconnor at cybermesa.com
http://www.r4h.org/r4hsoftware
More information about the Python-list
mailing list