[7924] in Perl-Users-Digest
Perl-Users Digest, Issue: 1549 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Dec 29 23:07:23 1997
Date: Mon, 29 Dec 97 20:00:20 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 29 Dec 1997 Volume: 8 Number: 1549
Today's topics:
Re: Bug: 30 chars of perl uses 269MB! (Ben Coleman)
Re: Bug: 30 chars of perl uses 269MB! (Ben Coleman)
Re: Bug: 30 chars of perl uses 269MB! (Jonathan Stowe)
Re: CGI: system "cat... (Jason Costomiris)
checking and sorting data members <bugaj@bell-labs.com>
chomp ($&) to remove specific \n <joema @nospam.microsoft.com>
Re: creating subclasses / HTML::Parser (Tad McClellan)
nntpd (Benji Spencer)
Perl Resource Kit - UNIX Edition or wait for WIN 32 Edi (Faust Gertz)
Re: Perl Resource Kit - UNIX Edition or wait for WIN 32 <pjhousto@cse.dnd.ca>
Re: PERL URL-Encoding (Mike Stok)
Re: problem with strict <tycage@infi.net>
Re: problem with strict (Jonathan Stowe)
Re: Shortcut(s) to perl scripts bomb (Jonathan Stowe)
Re: Size in KB <bugaj@bell-labs.com>
Re: Which language pays most? Smalltalk, not C++ nor Ja <carla@ici.net>
Re: Which language pays most? Smalltalk, not C++ nor Ja (Lawrence Kirby)
Re: Which language pays most? Smalltalk, not C++ nor Ja (Robert Dewar)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 30 Dec 1997 01:08:27 GMT
From: tnguru@termnetinc.com (Ben Coleman)
Subject: Re: Bug: 30 chars of perl uses 269MB!
Message-Id: <34a8455d.885234559@news.mindspring.com>
On 30 Dec 1997 10:02:48 +1100, nick@zeta.org.au (Nick Andrew) wrote:
>G'day,
>
>While playing with embedding quotes in strings I hit a combination which
>causes Pel 5.003 to run out of memory. In fact an strace showed it trying
>to mmap() 1.2 gigs.
>
>I shortened my program to 30 characters. It only tries to mmap 269 megs
>now, but at least it is instructive:
>
>#!/usr/bin/perl
>$i='(\\'x\\''
>
>Perhaps somebody can explain what Perl thinks it is doing; perhaps somebody
>can fix whatever the bug is (probably a perplexing parser problem).
Perl appears to be doing exactly what you told it to do(which may be at
variance with what you think you told it to do).
The insertion of a little white space might make it easier to understand:
$i = '(\\' x \ \ ''
Basically, you've told Perl to create a reference to an anonymous scalar
containing the empty string, then to create a reference to _that_
reference. The result is then interpreted in a numeric context, which
results in the address of the first reference being converted to a number.
Perl then creates a string of that many repetitions of the string '(\\' and
assigns it to $i.
On my system, that number is roughly 8963352, which means that a string 27
MB long is assigned to $i.
Ben
--
Ben Coleman ben@termnetinc.com |
Senior Systems Analyst |
TermNet Merchant Services, Inc. |
Atlanta, GA |
------------------------------
Date: Tue, 30 Dec 1997 01:25:00 GMT
From: tnguru@termnetinc.com (Ben Coleman)
Subject: Re: Bug: 30 chars of perl uses 269MB!
Message-Id: <34a84c9e.887091580@news.mindspring.com>
On Tue, 30 Dec 1997 01:08:27 GMT, tnguru@termnetinc.com (Ben Coleman)
wrote:
>Perl appears to be doing exactly what you told it to do(which may be at
>variance with what you think you told it to do).
>
>The insertion of a little white space might make it easier to understand:
>
>$i = '(\\' x \ \ ''
>
>Basically, you've told Perl to create a reference to an anonymous scalar
>containing the empty string, then to create a reference to _that_
>reference. The result is then interpreted in a numeric context, which
>results in the address of the first reference being converted to a number.
>Perl then creates a string of that many repetitions of the string '(\\' and
>assigns it to $i.
A slight correction, the string consists of the two characters (\.
>On my system, that number is roughly 8963352, which means that a string 27
>MB long is assigned to $i.
Which means that on my system, $i ends up about 18MB long.
Basically, your problem is that you're doubling the \ when you don't want
to( a \\ becomes a literal \ in the string). To insert a literal ', use
\'. thus what you originally wanted to do was:
$i='(\'x\'';
Ben
--
Ben Coleman ben@termnetinc.com |
Senior Systems Analyst |
TermNet Merchant Services, Inc. |
Atlanta, GA |
------------------------------
Date: 30 Dec 1997 01:59:38 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Bug: 30 chars of perl uses 269MB!
Message-Id: <689kia$m9o$6@mendelevium.btinternet.com>
In article <689a6o$ros$1@gidora.kralizec.net.au>, nick@zeta.org.au says...
>
>G'day,
>
>While playing with embedding quotes in strings I hit a combination which
>causes Pel 5.003 to run out of memory. In fact an strace showed it trying
>to mmap() 1.2 gigs.
>
>I shortened my program to 30 characters. It only tries to mmap 269 megs
>now, but at least it is instructive:
>
>#!/usr/bin/perl
>$i='(\\'x\\''
>
>Perhaps somebody can explain what Perl thinks it is doing; perhaps somebody
>can fix whatever the bug is (probably a perplexing parser problem).
>
Hmm, not a bug that. If you try:
#!/usr/bin/perl
$i='(\\'x\\'';
print $i;
I think you will see what is happening here. It does appear to be a rather
arcane (undocumented ?) behaviour of the x operator though. Someone wiser
than myself will no doubt explain that.
Toodlepip
/J\
------------------------------
Date: 30 Dec 1997 02:16:10 GMT
From: jcostom@madcow.jasons.org (Jason Costomiris)
Subject: Re: CGI: system "cat...
Message-Id: <slrn6agmba.89h.jcostom@madcow.jasons.org>
On Mon, 29 Dec 1997 15:49:00 -0800, B. Bell <maximill@u.washington.edu> wrote:
: i want to include a file in my cgi output. I'm trying to use the system
: function call to just 'cat' the file.
: I suspect there's a far simpler solution?, but can anybody tell me why
: this doesn't work:
Save yourself a system call.
open(F,$myfile) or die "Can\'t open $myfile";
while(<F>){ print; }
close(F);
--
Jason Costomiris <>< | "VMS is about as secure as a poodle
jcostom@jasons.org | encased in a block of lucite....
http://www.jasons.org/~jcostom/ | .... about as useful, too."
#include <disclaimer.h> | --some guy I read on Usenet
------------------------------
Date: Mon, 29 Dec 1997 22:49:22 -0500
From: Stephan Vladimir Bugaj <bugaj@bell-labs.com>
Subject: checking and sorting data members
Message-Id: <34A86F42.167E@bell-labs.com>
if I have
package Foo;
#setup stuff
sub new
{ #my this and that
$this->{foo} = param{foo};
#etc, bless...
}
...
which of these will properly do_stuff iff some param
foo was passed to the constructor?
if(exists $this->{foo}) {do_stuff}
if(defined $this->{foo}) {do_stuff}
I was using defined, then I discovered that undef is
a legitimate hash value so I am assuming exists is the
proper test... but I figured I'd ask anyway...
Also... what's the much better and more efficient way of
doing this?
foreach my $key1 (@{$keysref1}) {
foreach my $key2 (@{$keysref2})
{
if($object->{foo} =~m^$pkey^oi and $object->{bar}=~m^$skey^oi)
{
( exists ${$sums{"$key1"}}{"$key2"} and
${$sums{"$key1"}}{"$key2"} +=1 )
or (${$sums{"$key1"}}{"$key2"} =1);
push(@{${$hits{"$key1"}}{"$key2"}}, $line);
}
}
}
or just the summation of numbers of occurances, retaining the
information of how many of each bar occurred for each foo?
foreach $object (@arrayofobjects)
{
(exists ${$sums{"$object->{foo}"}}{"$object->{bar}"} and
${$sums{"$object->{foo}"}}{"$object->{bar}"}+=1 )
or ${$sums{"$object->{foo}"}}{"$object->{bar}"} =1 );
}
Is there an easy way to arbitrarily nest this? (Getting a
relational database and working from that would presumably
be a good plan, but it would need to be freeware-
redistributable... erm, and I'd have to learn SQL, which
I've heard is bizarre but not too difficult.)
Thanks.
LL+P,
Stephan
ps. please cc me in email with any suggestions. thanks.
--
"Do computers think?"
---------------------------------------------------------------
Stephan Vladimir Bugaj, Multimedia Communication Research Dept.
Departmental Website: http://www.multimedia.bell-labs.com
PGPkey from http://www.pgp.net/wwwkeys.html or other keyservers
Non-Lucent website: http://www.cthulhu-dynamics.com/stephan
FAQs: http://www.cthulhu-dynamics.com/tech/metametafaq.html
---------------------------------------------------------------
STANDARD DISCLAIMER:My opinions are NOT those of LUCENT
---------------------------------------------------------------
"Do submarines swim?" - E.W. Dijkstra
------------------------------
Date: Mon, 29 Dec 1997 18:50:53 -0800
From: "Joe Marler" <joema @nospam.microsoft.com>
Subject: chomp ($&) to remove specific \n
Message-Id: <689ni5$ocu@news.microsoft.com>
I'm using Perl 5.001 on Win32. I need to strip out selected \n
characters from a text file using inplace editing, where the \n is
preceded by a specific match pattern.
I tried this:
s/matchpattern.*\n/chomp($&)/egi
However chomp() returns the no. of characters removed, not
the string minus \n, so that won't work. I tried chop(), but
got an error saying "modification of a read-only value attempted".
I ultimately used something like this, which worked but seems
unwieldy:
m/matchpattern.*\n/i;
$matchedstring = $&;
chomp($matchedstring);
s/matchpattern.*\n/$matchedstring/gi;
print;
This works OK, but I spent a lot of time looking for a syntactically
simpler method. I've checked the FAQ, various books, dejanews, etc.,
and was curious if I missed something obvious?
-- Joe Marler (Remove nospam to reply)
------------------------------
Date: Mon, 29 Dec 1997 19:43:08 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: creating subclasses / HTML::Parser
Message-Id: <cjj986.9o3.ln@localhost>
jsd@bud.com wrote:
: I'm trying to use HTML::Parser to spit out HTML comments. The perldoc
: for it says:
: In order to make the parser do anything interesting, you
: must make a subclass where you override one or more of the
: following methods as appropriate
: and then:
: $self->comment($comment)
: This method is called as comments are recognized. The
: leading and trailing "--" sequences have been stripped
: off the comment text.
: so i wrote this script:
[snip]
: but it doesn't do anything. it never prints "hi there i'm alive" so i'm
: guessing that i'm not properly creating the subclass.
Good guess ;-)
You make a new package for your derived class (myParser), and
put the name of the superclass in the package's @ISA:
---------------------
#!/usr/bin/perl -w
require HTML::Parser;
######################################
package myParser;
@ISA = qw/HTML::Parser/; # myParser is a subclass of HTML::Parser
sub comment {
my $this = shift; # uninteresting, don't want to print this ;-)
print "hi there i'm alive\n";
print @_, "\n"; # I added a newline too
}
######################################
package main;
$html=<<ENDHTML;
<HTML>
<BODY>
<!-- leave me alone. I'm a comment -->
</BODY>
</HTML>
ENDHTML
$p = myParser->new; # call my own class with comment() overridden
$p->parse($html);
---------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 30 Dec 1997 03:06:00 GMT
From: spunge@ripco.com (Benji Spencer)
Subject: nntpd
Message-Id: <34a8646f.110074285@news.enteract.com>
I would like to have a local nntpd type of setup on my LAN. The news
servers I have looked at, do a lot more then what I want. I want to be
able to use 'suck' on my Linux box, to retrieve the groups/articals I
want, then use a news client on my win95 box to read the news from the
Linux box. Are there any simple perl news servers that would work for
this? I have looked, and maybe found a couple, but I am not sure if
they will work at this moment.
Benji
(:------------------------Benji Spencer----------------------------:)
spunge@enteract.com http://www.enteract.com/~spunge
spunge@ripco.com http://www.ripco.com/~spunge
ben@anduin.eldar.org http://anduin.eldar.org/~ben
PGP public key can be retrieved by fingering ben@anduin.eldar.org
------------------------------
Date: Tue, 30 Dec 1997 00:21:58 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Perl Resource Kit - UNIX Edition or wait for WIN 32 Edition?
Message-Id: <34a83958.17253910@news.wwa.com>
Should I buy the Perl Resource Kit UNIX Edition or wait for the WIN 32
Edition?
Here is my situation. I use to play a round with my ISP's version of
Perl, which was running under Solaris. Yesterday, I broke down and
bought one of those Windows 95 machines. So, I decided it might be
wise to enter the world of Perl for WIN 32. That way I could save on
connect charges when I play with non-CGI and libwww stuff by doing it
on my own machine. My fear is that the WIN 32 Edition will be filled
with all kinds of WIN 32 specific information and that I will lose out
on lots of useful documentation by not buying the UNIX Edition. Can
anyone verify or falsify my fear and give me some advice on the
purchase?
TIA
Faust Gertz
Philosopher at Large
------------------------------
Date: Tue, 30 Dec 1997 01:29:02 GMT
From: Phil Houstoun <pjhousto@cse.dnd.ca>
Subject: Re: Perl Resource Kit - UNIX Edition or wait for WIN 32 Edition?
Message-Id: <34A84CF2.22DB00D7@cse.dnd.ca>
Faust Gertz wrote:
>
> Should I buy the Perl Resource Kit UNIX Edition or wait for the WIN 32
> Edition?
>
> Here is my situation. I use to play a round with my ISP's version of
> Perl, which was running under Solaris. Yesterday, I broke down and
> bought one of those Windows 95 machines. So, I decided it might be
> wise to enter the world of Perl for WIN 32. That way I could save on
> connect charges when I play with non-CGI and libwww stuff by doing it
> on my own machine. My fear is that the WIN 32 Edition will be filled
> with all kinds of WIN 32 specific information and that I will lose out
> on lots of useful documentation by not buying the UNIX Edition. Can
> anyone verify or falsify my fear and give me some advice on the
> purchase?
>
> TIA
>
> Faust Gertz
> Philosopher at Large
IMHO, break down one more time and install Linux on your box, you can
then get the Unix version AND be able to do the CGI and libwww stuff.
The paying for Perl thing is a joke.... right?
--
Phil Houstoun Voice: (613) 991-7173
Email: remove the 'j' in pjhousto@cse.dnd.ca
-----------------------------------------------------------------------
------------------------------
Date: 29 Dec 1997 22:04:12 -0500
From: mike@stok.co.uk (Mike Stok)
Subject: Re: PERL URL-Encoding
Message-Id: <689obc$qg$1@stok.co.uk>
In article <34A80745.14F83A7@hub.ofthe.net>,
Dustin Arnold <dustin@hub.ofthe.net> wrote:
>Could anyone email me the line(s) of PERL that would re-URLencode a
>string
>of text (do the opposite of this):
>
>$value =~ tr/+/ /;
>$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
If you're using perl 5.xxx then the URI::Escape module may have what you
need:
NAME
uri_escape - Escape unsafe characters
uri_unescape - Unescape escaped characters
SYNOPSIS
use URI::Escape;
$safe = uri_escape("10% is enough\n");
$verysafe = uri_escape("foo", "\0-\377");
$str = uri_unescape($safe);
URI::Escape is part of the libwww-perl module set whcih can be found on
CPAN (point a browser at http://www.perl.com/ and follow the CPAN links,
or ftp to ftp.funet.fi and look under /pub/languages/perl/CPAN - there
should be a list of mirror sites there.)
In the debugger:
DB<1> use URI::Escape
DB<2> print uri_escape 'Mike Stok <mike@stok.co.uk>'
Mike%20Stok%20%3Cmike@stok.co.uk%3E
There are several other useful modules in the distribution, so even if I
haven't given you the right answer you may well find it.
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: Mon, 29 Dec 1997 17:17:03 -0500
From: Ty Cage Warren <tycage@infi.net>
Subject: Re: problem with strict
Message-Id: <34A8215F.34680FD7@infi.net>
Tomas wrote:
>
> I am going nuts...I cannot understand why the following scripts
> returns the following error:
>
> Bareword "FILE" not allowed while "strict subs" in use at
> company_upload.cgi line 8.
> company_upload.cgi had compilation errors.
>
> --------------------------------------
> #!/usr/local/bin/perl -w
>
> use strict;
> use CGI;
>
> my $filename = "setup.dat";
> open (FILE, ">" . "$filename");
> my $query->save(FILE);
Try this
$query->save(*FILE);
to pass a typeglob instead. That should hush up use strict since FILE
is no longer a bare word then.
Oh, btw, you haven't created a CGI object yet in your code.
You need to say
my $query = new CGI;
at some point before the save to create the CGI object.
> close (FILE);
> ---------------------------------------
>
> Any help is greatly appreciated.
>
> Tomas
Hope this helps,
Ty
--
+---+
Ty Cage Warren tycage@infi.net
Systems Engineer InfiNet
Homepage: http://www.wsol.net/~tycage
PGP Public Key: http://www.wsol.net/~tycage/pgpkey.html
PGP Fingerprint: FF C1 28 CA 80 B5 31 78 B1 24 2E 8C AB DA FB D2
------------->Never invoke anything bigger than your head.<-------------
------------------------------
Date: 30 Dec 1997 01:13:11 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: problem with strict
Message-Id: <689hr7$m9o$2@mendelevium.btinternet.com>
In article <68955l$djq$1@gte1.gte.net>, tomas@iimagers.com says...
>#!/usr/local/bin/perl -w
>
>use strict;
>use CGI;
>
>my $filename = "setup.dat";
>open (FILE, ">" . "$filename");
>my $query->save(FILE);
>close (FILE);
Nearly there, this works for me:
---
#!/usr/local/bin/perl -w
use strict;
use CGI;
my $query = new CGI; # Need to create instance of CGI object
my $filename = "setup.dat";
open (FILE, ">" . "$filename");
$query->save(*FILE); # Pass typeglob
close (FILE);
Hope this helps
/J\
------------------------------
Date: 30 Dec 1997 00:59:32 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Shortcut(s) to perl scripts bomb
Message-Id: <689h1k$m9o$1@mendelevium.btinternet.com>
In article <34A7EBCF.4C70@isc.mds.lmco.com>, sjenifer@isc.mds.lmco.com
says...
<cut>
> so, as a test,
>i deleted ../Scripts/test.pl, then i went to the directory where the
>other test.pl was, created a shortcut to it, and moved that shortcut to
>'Scripts'. after renaming the shortcut to 'test.pl', i thought i
>would get the same results. however, when i submitted the comment,
>i got an error stating that http://.../Scripts/test.pl could not be
>found.
>
This is really a question for comp.infosystems.www.servers.ms-windows
but as you asked here first I would suggest that the problem is that the
shortcut you created in your /Scripts directory is not *really* called
test.pl but <some name>.lnk (or something like this). The NT4.0 (Win95) user
environment knows about this stuff but IIS does not care about such things.
Hope that helps.
/J\
------------------------------
Date: Mon, 29 Dec 1997 22:15:31 -0500
From: Stephan Vladimir Bugaj <bugaj@bell-labs.com>
Subject: Re: Size in KB
Message-Id: <34A86753.41C6@bell-labs.com>
> How exactly do i use the length()? Say may variable is $stuff Also you
> said multiply it by the number of bytes per character but how many bytes
> are there per charater? Also then i divide by 1024 right?
>
"
length EXPR
This function returns the length in bytes of the scalar value EXPR.
"
$numK = (length $stuff) / 1024;
Casting to an int, if you want to, is left as an exercise for
the reader.
LL+P,
Stephan
--
"Do computers think?"
---------------------------------------------------------------
Stephan Vladimir Bugaj, Multimedia Communication Research Dept.
Departmental Website: http://www.multimedia.bell-labs.com
PGPkey from http://www.pgp.net/wwwkeys.html or other keyservers
Non-Lucent website: http://www.cthulhu-dynamics.com/stephan
FAQs: http://www.cthulhu-dynamics.com/tech/metametafaq.html
---------------------------------------------------------------
STANDARD DISCLAIMER:My opinions are NOT those of LUCENT
---------------------------------------------------------------
"Do submarines swim?" - E.W. Dijkstra
------------------------------
Date: 29 Dec 1997 23:50:26 GMT
From: "Alicia Carla Longstreet" <carla@ici.net>
Subject: Re: Which language pays most? Smalltalk, not C++ nor Java.
Message-Id: <01bd14b4$dc6f6a80$6428b4cf@carla.ici.net>
Robert Dewar wrote:
: John says
: <<So now a "language" is not defined by the compiler -- or even by the
: preprocessor+compiler+linker+etc, as some have it...
: I am forbidden by a piece of paper from calling a function 'memfoo'!
: Of course the answer is that the language is defined by the standard.
What
: is surprising is your exclamation mark at the end of a statement that
should
: be common understanding for any programmer.
Only programmers who have no concept of what a language, any language is.
Even if the Standard does define the language, it only did so on the day
the standard was finalized. Languages, even programming language, evolve
and change over time. A Standards document can never be a current
definition of a language, only the definition of the language at some point
in the past. Even so, the ANSI/ISO Standards defining C only define the
common core of the C language. When C9X is finalized, at that moment it
will define the core of the C programming language. By the time it is
actually published and distributed the language will have changed to a
small extent.
: Of course the language is not defined by the compiler, or any combination
: of tools. This is nothing new, languages have been defined by standards
: for a very long time. C came rather late to the standards business, but
: even before the ANSI C standard was approved, C was defined by pieces
: of paper, including for example the reference manual at the back of K&R.
Keep on dreaming. No language, ever, can be defined by a piece of paper.
Unless it is a dead language that is no longer used and therefore no longer
changes. This concept is simply impossible.
: For anyone to think that a language is usefully defined by a compiler is
: to me evidence of poor training. No one should be able to get out of any
: CS degree program with this kind of misconception.
This is true. The language is defined by usage (*All* languages are
defined by usage).
: However, as I said in my earlier message, I am afraid that this confusion
: is a very common one and is responsible for a huge percentage of the
problems
: in porting code, regardless of the language.
Yes it is important to understand the each compiler may represent a
different dialect of the C language, one that may or may not be compatible
with any other specific compiler.
: If your only knowledge of the definition of a language comes from what
you
: find is accepted by your compiler, you can be sure that your code is
unlikely
: to be anywhere as near portable as it should be.
True. Too many programmers learn from BASIC where there is almost no
cross-platform or even cross-compiler/interpreter compatibility. It is
difficult to impress students with the need to write portably with a
language that is not portable. About as effective as your father telling
you not to smoke in between drags on his cigarette. Just another reason
not to use BASIC as a teaching tool (unless you are teaching how to make
spagetti).
--
If at first you don't succeed -- give up! No use being a damn fool.
No job is so simple that is can't be done wrong.
You can only be young once, but you can be immature forever.
==========================================================
Alicia Carla Longstreet carla@ici.net
Web Page http://www.ici.net/cust_pages/carla/index.html
==========================================================
READ THE FAQ for more information:
C-FAQ ftp sites: ftp://ftp.eskimo.com or ftp://rtfm.mit.edu
Hypertext C-FAQ: http://www.eskimo.com/~scs/C-faq/top.html
Remember: Those who think they know it all...
Are very annoying to those of us who do.
------------------------------
Date: Tue, 30 Dec 97 00:22:52 GMT
From: fred@genesis.demon.co.uk (Lawrence Kirby)
Subject: Re: Which language pays most? Smalltalk, not C++ nor Java.
Message-Id: <883441372snz@genesis.demon.co.uk>
In article <34A812F9.C169A703@its.cl> gschwarz@its.cl "Guillermo Schwarz" writes:
>Kurt Watzka wrote:
>
>> Guillermo Schwarz <gschwarz@netup.cl> writes:
>>
>> >Kaz Kylheku wrote:
>> >> Although 'memcpy' is not a reserved keyword by any means,
>> >> it is a reserved 'external name'.
>> >It is the first time I see reserved external.
>>
>> Well, looks as if there still is something to learn about C for you.
>> The exact wording is "are reserved as identifiers with external
>> linkage", but "reserved external name" looks close enough to me.
>>
>
>It's nice to know C advances so fast I can't keep up to date with its
>definition."Reserved as identifiers" is something meaningful to you?
No, it doesn't out of context. Actually the wording above doesn't appear to
be exact. The full sentence is (in 7.1.3)
"- All identifiers with external linkage in any of the following subclauses
(including the future library directions) are always reserved for use
as identifiers with external linkage"
That means that if any of the following subclauses define an identifier
(or name if you like) as having external linkage then you can't declare
that identifier/name yourself with external linkage. If you do you get
undefined behaviour which means anything can happen. It could be that the
code compiles and does what you expected it to, that the code fails to
compile, that the code compiles and does something completely different
possibly even crashing during execution.
This is reiterated to an extent in subclause 7.13 (Future library durections):
"All external names described below are reserved no matter what headers
are included by the program"
One of the sections "below" is:
"7.13.8 String handling <string.h>
Function names that begin with str, mem, or wcs and a lowercase letter
(followed by any combination of digits, letters, and inderscore) may be
added to the declarations in the <string.h> header."
>Can you reserve a name as a non indentifier?
No, but that's not what it said. You're trying to take this out of context.
>"with external linkage"? Those are too many words just to mean an extrernal
>name.
>The point is, at least when I studied the good and old K&R, it didn't mention
>
>"reserved as identifiers with external linkage", that for me means "don't
>touch this,
>or trick"...
K&R2 doesn't define the language. It is an excellent book but there do seem to
be a few things it doesn't cover properly. The index lists "reserved words"
but that just seems to refer to keywords. Even though it was revised after
the standard was released it seems to be based mainly on a draft standard.
>The C guys modify their language each 3 months just when they
>realize
>something is missing. If you think it is funny, I think it is pretty messy.
I don't know where you got that idea. The text I quoted was directly from
the 1990 ISO standard. The text in the original 1989 ANSI standard is
almost certainly the same - the only major thing that changed between the
two was the section numbering. There have been 2 or maybe 3 changes to the
standard since then but the scope of them is minor, mostly fixing errors
and areas of confusion in the original.
>In Smalltalk, there is USUALLY no need to change the language, but just the
>need
>to add new classes and methods to achieve what's needed.
If you take K&R1 as a revision the C language seems to get revised in a
significant way roughly every 10 years. That's not dissimilar to other
languages (e.g. Ada-83,95 and Fortran 66,77,90)
>> If memcpy is not defined as a function with external linkage, and
>> if <string.h> is not included, an implementation that does not
>> sucessfully translate the program in question is at error. Did
>> you actually _try_ it, and if yes, which implementation did
>> "point out two different implementations"?
>
>You are right! I'm amazed. GNU gcc does implement memcpy directly (what is to
>say thatmemcpy is inlined into the resulting exe, independently from how it
>is defined
>in the program).
It is an optimisation choice the compiler is free to make for itself. This
is possible because the language allows it to do anything it likes if you
break the rules such as try to define your own memcpy() with external
linkage. The compiler is allowed to "know" how standard library functions
behave.
>I would like to follow the only faith: smallTalk, so that my flesh doesn't
>get rotten.
>
>How can somebody have a life, if the ANSI is changing the language so fast?
It isn't. (As an aside ISO has controlled the C standard since 1990).
>They think that by changing minor things they can keep C alive?
>(I'm not meaning C is dead, but let Electronic Engineers do the drivers for
>their
>HW in C, but don't tell the rest of the world C is the right language because
>it
>is well implemented or something else wrong like that).
No, the one thing that standardisation did was to effectively halt the
development of the C language. This is a good thing for the reasons you
imply. However C does still need to be allowed to develop occasionally.
The 1989 language is showing its age in some areas e.g. lack of guaranteed
support for 64 bit (or larger) integers. Being a lower level language
than many it does have greater pressure on it to adapt to changing
hardare capabilities. Still, the change rate is hardly excessive.
>Maybe not too much people write their dirvers in Smalltalk because the
>drivers
>are very simple pieces of code. Drivers have no complex algorithms, they just
>
>need sti(), cli(). That's why drivers are made in C. That's why drivers were
>made
>in assembly.
>
>> The object model and design ideas behind C++ are completely different
>> from Smalltalk.
>
>Objects have behavior and state in both languages.C doesn't have objects, nor
>behavior, nor state.
C has objects but it doesn't have all the OO paraphernalia that goes with
them in a language like C++ (you could say it lacks the behaviour part).
The purpose of an object in C is to store state. Maybe the OOP'ers have a
more abstract view of what an object is.
>C++ is backward compatible with C.
It might be fair to say that C++ is mostly backwards compatible with C.
However there is enough incompatibility to make it a bad idea to try to
compile natural C code with a C++ compiler.
--
-----------------------------------------
Lawrence Kirby | fred@genesis.demon.co.uk
Wilts, England | 70734.126@compuserve.com
-----------------------------------------
------------------------------
Date: 29 Dec 1997 20:41:50 -0500
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: Which language pays most? Smalltalk, not C++ nor Java.
Message-Id: <dewar.883445953@merv>
<<Keep on dreaming. No language, ever, can be defined by a piece of paper.
Unless it is a dead language that is no longer used and therefore no longer
changes. This concept is simply impossible.
>>
This is complete nonsense. It does not correspond to the real situation
with many standardized languages. Many programmers know the C standard
well, carefully adhere to it, and succeed in writing portable code, and
the same thing can be said of Fortran, COBOL and Ada programmers (
particularly in the latter case, Ada programmers tend to know the standard
well).
The idea that a language wanders around ill-defined, and programmers follow
it may seem familiar to undisciplined hackers, but it does not required
dreamers to correct this totally unacceptable behavior!
<<Only programmers who have no concept of what a language, any language is.
Even if the Standard does define the language, it only did so on the day
the standard was finalized. Languages, even programming language, evolve
and change over time. A Standards document can never be a current
definition of a language, only the definition of the language at some point
in the past. Even so, the ANSI/ISO Standards defining C only define the
common core of the C language. When C9X is finalized, at that moment it
will define the core of the C programming language. By the time it is
actually published and distributed the language will have changed to a
small extent.
>>
Sounds like you have very little direct experience with language
standardization efforts, your account above bares no relation to reality.
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 1549
**************************************