S
Steven D'Aprano
You don't have to buy my argument, I am not selling it.
It's a figure of speech. You are making an argument others have made
before, and I don't accept the validity of the argument.
You don't have to buy my argument, I am not selling it.
Yes it can. I *have* seen Python with broken indentation on web pages,
and good luck sorting it out. Blaming it on "broken tools" is just
another straw man.
It happens, and if you're learning Python and
interested in that code you have a problem.
Snipped the rest, because you start to sound like a zealot. I should've
know better.
Steven D'Aprano said:You're using that term wrong. It looks to me that you don't actually know
what a straw man argument is. A straw man argument is when somebody
responds to a deliberately weakened or invalid argument as if it had been
made by their opponent.
Jeez, Steve, you're beginning to sound like some kind of fallacy
zealot...
Yeah, what did the zealots ever do for us?Steven said:Death to all those who confuse agumentum ad populum with argumentum ad
verecundiam!!!
I'm not familiar with Ruby, but most languages are cleaner than Python
once you get beyond the "10-minute introduction" stage.
yuck! wrapping the arg list with parenthesis (python way) makes the
most sense. Its to easy to misread somthing like this
onetwothree four five six
onetwothree(four, five, six) #ahhh... plain english.
If it was common-place to use Curried functions and partial application in
Python, you'd probably prefer "f a b c" to "f(a)(b)(c)" as well.
In Lisp-ish languages, you have a list of stuff that represents a
function call:
 (a b c d)
means: Call "a" with values (b, c, d)
While this certainly doesn't agree with what you learned in Algebra,
it is a reasonable syntax that exposes the code-data duality of
programs. There is, however, one fatal flaw. Why is the first element
so different than the rest? This is inconsistent with what people who
are unfamiliar with the language would expect. Indeed, in teaching
Lisp, learners have to be reminded about how the evaluator looks at
lists and processes them.
I would expect a clear, simple language to have exactly one way to
call a function. This calling notation would clearly distinguish
between the function and its parameters. There are quite a few
options, and it turns out that "function(arg, arg, arg)" is a really
good compromise.
One of the bad things with languages like perl and Ruby that call
without parentheses is that getting a function ref is not obvious. You
need even more syntax to do so. In perl:
 foo();    # Call 'foo' with no args.
 $bar = foo;  # Call 'foo; with no args, assign to '$bar'
 $bar = &foo; # Don't call 'foo', but assign a pointer to it to '$bar'
       # By the way, this '&' is not the bitwise-and '&'!!!!
 $bar->()   # Call whatever '$bar' is pointing at with no args
Compare with python:
 foo()    # Call 'foo' with no args.
 bar = foo() # 'bar' is now pointing to whatever 'foo()' returned
 bar = foo  # 'bar' is now pointing to the same thing 'foo' points to
 bar()    # Call 'bar' with no args
One is simple, consistent, and easy to explain. The other one requires
the introduction of advanced syntax and an entirely new syntax to make
function calls with references.
Jonathan Gardner said:I judge a language's simplicity by how long it takes to explain the
complete language. That is, what minimal set of documentation do you
need to describe all of the language? With a handful of statements,
and a very short list of operators, Python beats out every language in
the Algol family that I know of.
That's just the point. It isn't common to play with curried functions
or monads or anything like that in computer science today. Yes,
Haskell exists, and is a great experiment in how such a language could
actually work. But at the same time, you have to have a brain the size
of the titanic to contain all the little details about the language
before you could write any large-scale application.
Jonathan Gardner said:One of the bad things with languages like perl
without parentheses is that getting a function ref is not obvious. You
need even more syntax to do so. In perl:
foo(); # Call 'foo' with no args.
$bar = foo; # Call 'foo; with no args, assign to '$bar'
$bar = &foo; # Don't call 'foo', but assign a pointer to it to '$bar'
# By the way, this '&' is not the bitwise-and '&'!!!!
One is simple, consistent, and easy to explain. The other one requires
the introduction of advanced syntax and an entirely new syntax to make
function calls with references.
I judge a language's simplicity by how long it takes to explain the
complete language. That is, what minimal set of documentation do you
need to describe all of the language?
With a handful of statements,
and a very short list of operators, Python beats out every language in
the Algol family that I know of.
Nobody said:No, not really. Haskell (and previously ML) are often used as introductory
languages in Comp.Sci. courses (at least in the UK).
Nobody said:A better metric is whether using N features has O(N) complexity, or O(N^2)
(where you have to understand how each feature relates to each other
feature) or even O(2^N) (where you have to understand every possible
combination of interactions).
Steven said:]
The very idea of using a number of blanks to identify your block level
is as insane as it gets.
Not at all. People do it all the time. The very idea of expecting people
to count nested braces to identify block level is what is crazy, which is
why in languages with braces people still indent the blocks.
In any case, if your IDE mixes tabs and spaces, your IDE is broken and
you should fix your tools rather than blame the language.
Nonsense. For the compiler, both are equally reliable, and for the human
reader, indents beat braces easily.
Really? So a "sane compiler" sees no difference between:
for x in mylist:
and
forxinmylist:
I'm glad I don't have to program using a compiler you consider "sane".
Jonathan said:One of the bad things with languages like perl and Ruby that call
without parentheses is that getting a function ref is not obvious. You
need even more syntax to do so. In perl:
foo(); # Call 'foo' with no args.
$bar = foo; # Call 'foo; with no args, assign to '$bar'
$bar = &foo; # Don't call 'foo', but assign a pointer to it to '$bar'
# By the way, this '&' is not the bitwise-and '&'!!!!
$bar->() # Call whatever '$bar' is pointing at with no args
Compare with python:
foo() # Call 'foo' with no args.
bar = foo() # 'bar' is now pointing to whatever 'foo()' returned
bar = foo # 'bar' is now pointing to the same thing 'foo' points to
bar() # Call 'bar' with no args
One is simple, consistent, and easy to explain. The other one requires
the introduction of advanced syntax and an entirely new syntax to make
function calls with references.
One of the bad things with languages like perl and Ruby that call
without parentheses is that getting a function ref is not obvious.
for writing new code, it's not necessarily that helpful to be *forced*
to keep with strict indenting rules. in early development phases,
code is often experimental, and parts of it may need to be blocked or
unblocked as the codebase grows, and for experimentation, the need to
carefully and consistently indent and de-indent large chunks of code
can easily lead to a mess (blame it on the programmer, not the
language, but still). yes, there are editors that help you indent
chunks of code, but see below.
there are languages where indentation can be either enforced and allow
one to omit some syntactic nuissance like braces or begin-end clauses,
or made optional, requiring other syntactic means for delimiting
blocks etc. (consider f# with its #light declaration, for example.)
as long as you are limited to your own code, sure. but if many work
on the same bit, and use different editors and indentation policies,
blanks-tabs indentation issues are not unlikely. you can have blanks
converted to tabs and vice versa automatically, but that's clearly a
nuisance.
You don't need to know the entire language before you can use any of it
(if you did, Python would be deader than a certain parrot; Python's dark
corners are *really* dark).
FYI: the language is called Perl, the program that executes a Perl
program is called perl.
It should be $bar = \&foo
Your example actually calls foo...
One is simple, consistent, and easy to explain. The other one requires
the introduction of advanced syntax and an entirely new syntax to make
function calls with references.
The syntax follows that of referencing and dereferencing:
$bar = \@array; # bar contains now a reference to array
$bar->[ 0 ]; # first element of array referenced by bar
$bar = \%hash; # bar contains now a reference to a hash
$bar->{ key }; # value associated with key of hash ref. by bar
$bar = \&foo; # bar contains now a reference to a sub
$bar->( 45 ); # call sub ref. by bar with 45 as an argument
Consistent: yes. New syntax? No.
Also, it helps to think of
$ as a thing
@ as thingies indexed by numbers
% as thingies indexed by keys
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.