At 10:16 +0100 2001.02.27, Detlef Lindenthal wrote:
>Hi Chris,
>
>the
>        #!perl -l
>or
>        $\ = "\n";
>options are not what I want, because they do not provide
>the possibility of a simple "print" without "\n".

Both do, depending on what your uses.  You can do, for example:

        #!perl -l
        for (0..9) {
                print $i++;
        }
        {       local $\;
                print "this does not have a newline.";
        }

Or even better yet, you could use printf, which ignored the value of $\.
As long as you don't use % in the string, you're fine (and if you do, just
escape it with anotyher %).


>And: These are extra lines that have to be remembered,
>to be typed, to be viewed by and to be explained to pupils.

Ah, well, something for students is possibly very different than something
for a regular programmer.


>That is also true with the (funcional correct) solution
>       sub printl { print @_, "\n" }   .
>
>As soon as I have to print more than 1 line I have to express
>"\n" and I need one of those possibilities!

I don't understand.  You want printll for printing two lines?


>A scripting language has to "make the easy jobs easy",
>and printing is the very-very easiest job, and the job
>most often needed, especially by beginners.

>All these
>        #!perl -l
>        $\ = "\n";
>        sub printl { print @_, "\n" }     .
>        print ........, "\n"
>are too complicated.

I don't think so, but to each his own.  I can understand how -l and $\ are
confusing.  However, I do not see how sub printl {} or print $foo, "\n" are
complicated or complex.  If a student cannot understand "\n", then how
could they understand the difference between print and printl?

Well, I don't want to get into a discussion of this kind of thing here,
that's just my simple thoughts as a non-teacher.  :)  But I do suggest you
check out the perl-trainers mailing list.  Maybe they cna help.

        http://lists.perl.org/showlist.cgi?name=perl-trainers


>Why could Pascal afford that "writeln",
>and Perl can not?

Why do lots of languages do lots of things?  Beats me.  I do know that Java
has a println, and I believe it is because in large part it does not have a
sane notion of \n.  IIRC in Java, \n is always LF, so you can't reasonably
do print $foo, "\n" and expect it to Do The Right Thing.  In Perl, you can
almost always expect it to Do The Right Thing, when printing to a file on a
native filesystem (and in Java, println will sometimes do the Wrong Thing
when printing to a non-native filesystem, so it is a bit deceptive).  When
printing to a socket, that's another story.  You need to know what kind of
record separator is needed for the socket you are writing to; I am not sure
if println could possibly be adapted to always Do The Right Thing here
anyway.  So maybe the answer is simply that the function is too deceptive
to be desirable.  I don't know.

I never really found much use for it personally.   But one thing is for
sure: it ain't gonna change in MacPerl.  We will not add it, as we do not
make such core changes in MacPerl.  However, you are more than welcome to
suggest it to the perl5-porters mailing list to see if it will be included
in core perl.  If it is included there, then it would end up in MacPerl.  I
won't say I have confidence they will be receptive to the idea.  You might
even want to look in the list archives for discussions of this in the past.

        http://lists.perl.org/showlist.cgi?name=perl5-porters

-- 
Chris Nandor                      [EMAIL PROTECTED]    http://pudge.net/
Open Source Development Network    [EMAIL PROTECTED]     http://osdn.com/

Reply via email to