[7890] in Perl-Users-Digest
Perl-Users Digest, Issue: 1515 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Dec 20 21:08:20 1997
Date: Sat, 20 Dec 97 18:00:23 -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 Sat, 20 Dec 1997 Volume: 8 Number: 1515
Today's topics:
_SUBROUTINE_NAME_ variable? <Tim.Maher@seaslug.org>
Re: Advanced Perl Programming book (Peter J. Schoenster)
Announce: Monolith::DynDNS maurice@hevanet.com
Beginner HELP needed :) <terrymcc@buffnet.net>
Re: Binaries of Perl for Win95 where (not Activestate) <jvradelis@mediaone.net>
can somebody help me? <tayatech@ms14.hinet.net>
Re: Check User ID <paineta@edp.net>
CORE DUMPS in PERL 5.00404 <matt@monmouth.com>
Re: Help with calculating Gunning (reading level) index <bowlin@sirius.com>
Re: hey guyz! plz help me out! (brian d foy)
Re: History of regexp <#@qz.to>
Re: How get which day is in the week? (Peter J. Schoenster)
PERL > DOS / WIN95 <office_vienna@yahoo.com>
Re: Perl editor needed (Jim Michael)
Questions regarding subroutines & perl symbol tables (Joe Guderjohn)
Re: references to globalise locally generatied filehand <tchrist@mox.perl.com>
Re: Regular Expression Question - non greedy match <#@qz.to>
Script calling another script <paineta@edp.net>
Re: sending email (Net::SMTP).. problem <gbarr@pobox.com>
Re: split bug in perl5.004? (brian d foy)
Re: Statistics for comp.lang.perl.misc (brian d foy)
Still need HELP (INA) <terrymcc@buffnet.net>
Re: Which language pays most 17457 -- C++ vs. Java? <Bill_Leary@msn.com>
Re: Which language pays most 17457 -- C++ vs. Java? <Bill_Leary@msn.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 20 Dec 1997 15:34:35 +0000
From: Tim Maher <Tim.Maher@seaslug.org>
Subject: _SUBROUTINE_NAME_ variable?
Message-Id: <349BE58B.E48E74D5@seaslug.org>
To facilitate the printing of error messages from user-defined subs, I'm
wondering
if there's a built-in variable that knows the name of its local
subroutine.
Judging from camel, lama, panther, and FAQ, I guess the answer's no,
unless
somebody out there knows more about this!
--
====================================================================
| Tim Maher, Ph.D. Tel/Fax: (206)781-UNIX |
| Head UNIX Guru, CONSULTIX Email: tim@consultix.wa.com |
| *The UNIX Training Experts* http://www.consultix.wa.com/yumpy/ |
====================================================================
------------------------------
Date: Sun, 21 Dec 1997 00:04:46 GMT
From: pschon@baste.magibox.net (Peter J. Schoenster)
Subject: Re: Advanced Perl Programming book
Message-Id: <349c5b66.87297677@news.magibox.net>
[ cc to author ]
Allen Choy <achoy@us.oracle.com> wrote:
>Hi.
>
>Does anyone have any opinions, good and bad, re: the Advanced Perl
>Programming book?
>I'm considering purchasing it, but don't know much about it.
I bought it. It sort of reminds me of "Who's Afraid of C++" which
starts with some basics before "hello world".
I have no formal programming background. Just a stubborn guy with a
brain and imagination.
The advanced perl book shows what is going on behind the scenes. What
is the symbol table and how does it work and how knowledge of that can
affect your programming choices. More on the difference between my
and local. Referencing and derefrencing. And much more than all of
this.
It is one of the few books that has really made me read and re-read
and ponder as opposed to oh yeah and just do it.
It doesn't come shrink wrapped. Open the book, look at the toc and
read a few pages and if you know everything that he is talking about
then why buy it. But if you were like me and you recognized the
concepts but really didn't know them then I say buy the book and
learn.
Peter
------------------------------
Date: Sat, 20 Dec 1997 15:51:08 -0600
From: maurice@hevanet.com
Subject: Announce: Monolith::DynDNS
Message-Id: <882654132.1182466057@dejanews.com>
DESCRIPTION
This module provides an object-oriented interface to the Monolith
DynDNS server. The DynDNS project, a free service of Monolith
Internet Services, Intl., allows those with dynamically
assigned IP addresses (the great majority of PPP and SLIP users), to
have a single, unchanging domain name. For more information, please
see:
http://www.ml.org/ml/dyndns/
PREREQUISITES
This module requires perl 5.004 or later. You must also
have the LWP library installed. See http://www.perl.com/
for information on obtaining the LWP library.
COPYRIGHT
Copyright (C) 1997, Maurice Aubrey <maurice@hevanet.com>. All rights
reserved.
This module is free software; you may redistribute it and/or
modify it under the same terms as Perl itself.
AVAILABILITY
http://olympia2.adhost.com/~maurice/Monolith-DynDNS-1.01.tar.gz
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Sat, 20 Dec 1997 17:08:24 -0800
From: Terry McC <terrymcc@buffnet.net>
Subject: Beginner HELP needed :)
Message-Id: <349C6C08.5825@buffnet.net>
-
Hi,
I have a cool "writing on the wall" program that I can not
get to work on my NT Server :(
I keep on getting the error telling me
"contained no blank line separating the header and data
most likely a broken CGI program"
I have looked at the wall.pl and there is a blank line there.
I have spent several hours on this SIMPLE problem and looked through all
my book and I still can NOT figure it out :(
I'm sure anyone can fix this simple error... Please help me.
Thanks in advance,
Terry
PS: Please reply in email if you are willing to help me
mailto:terrymcc@buffnet.net
------------------------------
Date: Sat, 20 Dec 1997 16:15:11 -0500
From: "James T. Vradelis" <jvradelis@mediaone.net>
To: Edward Betts <edward@hairnet.demon.co.uk>
Subject: Re: Binaries of Perl for Win95 where (not Activestate)
Message-Id: <349C355E.FDBA3B1@mediaone.net>
There are binaries for another port to Win32 on CPAN. Look for the port
by Gurusamy Sarathy.
Jim Vradelis
Legal Computer Solutions, Inc.
http://www.lcsweb.com
------------------------------
Date: Sun, 21 Dec 1997 08:35:04 +0800
From: "D.C.M" <tayatech@ms14.hinet.net>
Subject: can somebody help me?
Message-Id: <349C6437.1573BE8F@ms14.hinet.net>
how can I change timezone in perl ?
I live in taiwan.But the server is in other country.
Exp: My date : 1997/12/21 08:00 am
The server date: 1997/12/20 18:00 pm
Plz tell me!
Thanks for your help!!
------------------------------
Date: 18 Dec 1997 20:16:59 GMT
From: "Thomas Paine" <paineta@edp.net>
Subject: Re: Check User ID
Message-Id: <01bd0bf2$306d42e0$f0d2f3cd@www2.edp.net>
Just create another file named "visited.log" and just read the file into a
scalar.
Then just use an "if" statement against a matching statement. Maybe like
the following.
if ($userlist =~ m/$username/){
print("You have already participated in this survey.");
}
and if not, append the user's survey information to your existing file and
also append their username to the visited.log.
Let me know if this helped you out. Good Luck!
Thanks,
Thomas Paine - System Administrator
paineta@edp.net
ICQ# 5929945
------------------------------
Date: Sat, 20 Dec 1997 15:56:04 -0500
From: "Matthew Feinberg" <matt@monmouth.com>
Subject: CORE DUMPS in PERL 5.00404
Message-Id: <67hb81$2od$1@news.monmouth.com>
Has enyone else seen Core Dumps on new builds of Perl 5.00404 under BSDI 2.1
and 3.0?
The Perl 5.00302 that came with BSDI 3.0 still works fine and my 'make test'
for Perl 5.00404 checked out 100% Okay.
Any Ideas?
Matthew Feinberg
matt@monmouth.com
------------------------------
Date: Sat, 20 Dec 1997 15:03:12 -0800
From: Jim Bowlin <bowlin@sirius.com>
To: fenderbass@evang.com
Subject: Re: Help with calculating Gunning (reading level) index for documents
Message-Id: <349C4EB0.E1414E54@sirius.com>
I remember that Donald Knuth put some automatic hyphenation stuff into
his TeX program. Since hyphenation is supposed to happen only at
syllable boundaries, this might be the best place to start looking.
I remember that he used an algorithm that covered 99.99% of all words
correctly and a very short dictionary that covered exceptions.
HTH - Jim Bowlin
------------------------------
Date: Sat, 20 Dec 1997 16:00:22 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: hey guyz! plz help me out!
Message-Id: <67hb89$gov@bgtnsc02.worldnet.att.net>
In article <349badf6.11665191@news.tornado.be>, bart.mediamind@tornado.be
(Bart Lateur) wrote:
> comdog@computerdog.com (brian d foy) wrote:
>
> >Michael Budash wrote:
> >>you might try selena sol's form processor script
> >that's a very old and somewhat monstrous way to accomplish such a
> >simple task.
> You could say something similar of CGI.pm (not old, but monstrous
> anyway. 160k of source!).
i always thought that the HTML and browser specific stuff belonged
somewhere else (that's why my hacked version of CGI.pm is not so large).
--
brian d foy <http://computerdog.com>
#!/usr/bin/perl
$_=q|osyrNewkecnaYhe.mlorsePptMskurj|;s;[NY.PM]; ;g;local$\=
qq$\n$;@pm=split//;while($NY=pop @pm){$pm.=$NY;$ny.=pop @pm}
$pm=join'',reverse($ny,$pm);open(NY,'>&STDOUT');print NY $pm
------------------------------
Date: 21 Dec 1997 00:59:54 GMT
From: Eli the Bearded <#@qz.to>
Subject: Re: History of regexp
Message-Id: <eli$9712201949@qz.little-neck.ny.us>
Xah <xah@best.com> wrote:
> Is there anywhere on the web that discuss the history of regular expression?
Quite possibly. This does not sound at all perl related. Maybe you
want to use a search engine? Altavista is a very good one:
<URL:http://www.atlavista.digital.com/>
> The idea, research, implementation, theory etc.?
You want a history of mathematics for that. Most of the original work
was done by and for mathematicians, I'd wager. Look for stuff about
automata.
> I know that the O'Reilly's _Regular Expressions_ (owl book) covers it a bit.
> I'm looking for texts that I can read free on-line.
Can't help you there. Your local library may have stuff you can read
for free. Talk to your librarian.
Elijah
------
just went looking for his college text on automata but could not find it
------------------------------
Date: Sat, 20 Dec 1997 23:56:14 GMT
From: pschon@baste.magibox.net (Peter J. Schoenster)
Subject: Re: How get which day is in the week?
Message-Id: <349c5a65.87040848@news.magibox.net>
"Fejes Peter" <peter.fejes@sysdata.siemens.at> wrote:
>My beginner question is:
>
>I have tree parameter: year, month and day, I want to know how can I get
>which day is in the week (Sun, Mon, ...)?
>
Search CPAN. There is a module for this. I found one - DateManip-5.10.
Works good.
Peter
------------------------------
Date: Sun, 21 Dec 1997 01:56:29 +0100
From: "Ing.Heinz Riemer" <office_vienna@yahoo.com>
Subject: PERL > DOS / WIN95
Message-Id: <349C693D.1ADB@yahoo.com>
I want to write PERL 4. I have a WINDOWS 95 and want to test my CGI-pgm
when I write. How can I do? Is there a PERL for DOS or WIN95 for easy
install? Who can help?
------------------------------
Date: Sat, 20 Dec 1997 22:16:24 GMT
From: genepool@netcom.com (Jim Michael)
Subject: Re: Perl editor needed
Message-Id: <genepoolELIDvD.Lz@netcom.com>
Would those familiar with Emacs, etc. please describe the color syntax
highlighing and brace/bracket/paren matching functions? Does the paren
matching work by generating a close paren when an open paren is entered,
or provide a different text color for each paren nesting level or ??? TIA.
Cheers,
Jim
Don Groves (see@my.sig) wrote:
: In article <x6yb1gvudb.fsf@stone.america.net>, jstone@america.net says...
: > Benefits like color syntax-highlighting, automated indentation (with
: > selectable style), brace/bracket/paren matching, tags support, class
: Win95/NT programmers looking for a programmers editor should give
: UltraEdit a try. It is cheap, very fast, and supports color syntax-
: highlighting for up to 6 languages of your choice (including Perl),
: and has a very nice tabbed-panel interface for switching between
: buffers with a single click. You can run Perl from within the editor
: and capture the output to a buffer. Highly recommended.
------------------------------
Date: Sat, 20 Dec 1997 16:34:13 -0500
From: guderjoj@erols.com (Joe Guderjohn)
Subject: Questions regarding subroutines & perl symbol tables
Message-Id: <guderjoj-2012971634140001@rcm-as9s34.erols.com>
Is it possible to access the %sub array, or an equivalent structure, if
the -d switch is not used?
Also, is there a way to learn the name of the currently executing
subroutine, as you can get the name of the calling routine from "caller".
Any help would be greatly appreciated.
TIA.
Joe
--
Joe Guderjohn
guderjoj@erols.com
------------------------------
Date: 20 Dec 1997 22:14:21 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: references to globalise locally generatied filehandles
Message-Id: <67hfvt$5v7$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, jdvf@concentric.net writes:
:That works for me! However, what I really want is to
:assign the returned filehandle to a hash value like this:
:
:$myFHs{$afile}= newopen($afile);
:
:However, this seems to not work when I try to read from
:<$myFHs{$afile}>
Yes, it's Perl's kludgy old filehandle stuff. You have to
put it in a temporary scalar:
$fh = $myFHs{$afile};
$line = <$fh>;
or else if you've got one of the handle mods loaded, you should
be able to call
$line = $myFHs{$afile}->getline();
--tom
PS: Note that it was only due to a bug in my killfile that I've
seen your article. I kill on "spam" anywhere in the headers.
--
Tom Christiansen tchrist@jhereg.perl.com
Q. Why is this so clumsy?
A. The trick is to use Perl's strengths rather than its weaknesses.
--Larry Wall in <8225@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: 21 Dec 1997 01:34:54 GMT
From: Eli the Bearded <#@qz.to>
Subject: Re: Regular Expression Question - non greedy match
Message-Id: <eli$9712202003@qz.little-neck.ny.us>
Keywords: just another new york perl hacker
John Moreno <phenix@interpath.com> wrote:
> Honza Pazdziora <adelton@fi.muni.cz> wrote:
> > phenix@interpath.com (John Moreno) writes:
> > > $count = s/(#! rnews )(\d+\n)(.+?)/$1.(length $3).("\n").$3/gse;
> > > Which gives 1 char for the (length $3), I would have thought that it
> > > would go until it hit the next #! rnews.
> > Why should it? You said .+? which means at least one any character and
> > the least possible count. Which gives us nice 1.
> I understand what it was doing, I'm just not sure why the ? wasn't more
> greedy - I would have thought that when using the /g that a ? at the end
The DWIM operator has not yet become part of the standard perl regular
expression functionality. In the meantime, we have normal greedy repetion
operators such as + and *, and we have non-greedy versions, such as +?
and *?. The greedy ones always try to grab as much as possible, the non-
greedy ones always try to grab as little as possible.
It is my opinion that non-greedy repetition is very subtle and tends to
expose a large number of programmer bugs. I almost always recommend doing
without it.
I'd do something like this myself:
$r='#! rnews ';
$count = s/$r\d+\n((?:(?!$r)#|[^#]+)+)/$r.(length $1)."\n$1"/gse;
Or maybe even this (for added security against false positives from
#! rnews appearing somewhere besides the start of a line):
$r='#! rnews ';
$count = s/^$r\d+\n((?:(?!\n$r)\n|.+)+)/$r.(length $1)."\n$1"/gem;
Elijah
------
#!/usr/bin/perl -- -*- my ny.pm sig -*-
$_=$^ ;s;s;sss;;s^.^ju^&&s&P&,\n&&&(s(_..)(ers)||s|^|^^|)&&s(T)(q(st%eg))eg;
s<.(o).><$& new 1$$>i+s+\dst.+$a--||reverse(q(rep k))+ge;s*%.+u* so+*i;s=\++
="me"=mex&&s%ege%l$"hke%;$a||s/^\S+ /\/\//;s;\d+;yor;;s[KE]<ac$&>i;print $_;
------------------------------
Date: 18 Dec 1997 20:21:02 GMT
From: "Thomas Paine" <paineta@edp.net>
Subject: Script calling another script
Message-Id: <01bd0bf2$bf9ef9e0$f0d2f3cd@www2.edp.net>
I have a web page that has a simple form on it with four options. It works
fine execpt I need to be able to make the first script call a second one.
Can't I use the system() and /or exec() functions for this?
--
Thanks,
Thomas Paine - System Administrator
paineta@edp.net
ICQ# 5929945
------------------------------
Date: Sat, 20 Dec 1997 18:47:01 -0600
From: Graham Barr <gbarr@pobox.com>
To: avies@penny-empire.com
Subject: Re: sending email (Net::SMTP).. problem
Message-Id: <349C6705.E77F6D56@pobox.com>
Chris Thornton wrote:
>
> Hi all.. I've got a problem.. I use Net::SMTP to send some mail out in
> a perl prog... my problem is this... several times, i've seen that the
> mail server I had in there wasn't up, or had a problem for whatever
> reason, and none of the mail was sent.... I send similar to this:
>
> $mailhost = 'my.mail.server';
> $smtp = Net::SMTP->new($mailhost);
If $mailhost is not up, then Net::SMTP->new($mailhost) will return undef,
so you sould simple try
foreach $host (@mailhost) {
$smtp = Net::SMTP->new($host) && last;
}
die "Cannot connect to any host" unless $smtp;
> $smtp->mail('me@myaddress.com');
> $smtp->to($emailer);
> $smtp->data();
>
> $smtp->datasend("$senders","From: $from (ME)\n","Reply-To: $from\n
>
> $smtp->dataend();
> $smtp->quit;
>
> and it all works fine if the mail server is up... the problem is, I
> need this to send mail out ALL THE TIME it's very important that it
> doesn't skip an Email... does anyone know a way how I can either send
> to a different mail server if it cannot connect to the first one, or
> even record the error, and variables (IE which Email wasn't sent) to a
> file so the mail can be sent later. I'd rather be able to have it go
> to another mail server if it can't connect to the primary one (I've
> got access to several) anyways... any help would be appreciated.
> Please If you can, please email reply to avies@penny-empire.com as
> well as to the group.. thanks
>
> Chris
------------------------------
Date: Sat, 20 Dec 1997 16:19:53 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: split bug in perl5.004?
Message-Id: <67hccr$gov@bgtnsc02.worldnet.att.net>
In article <882647607.1009975299@dejanews.com>, bryl@medicine.wustl.edu wrote:
[as i recall, Tom C. answer this same question last week. i think it
even had a very similar subject line.]
> We run a number of CGI script on our site (SunOS 5.6/ Apache 1.3) -
> information is parsed in the usual manner with a line:
>
> %rqp = &url_decode(split(/[&=]/,$request));
this is the usual manner? i can break that in all sorts of fun
ways :)
> Odd number of elements in hash list at /home/user/lib/perl.library line 23
> (line 23 as above).
>
> This *only* seems to happen when the last field held in $request is blank,
> so it looks like name=value&name2=value2&last_one=
this is a likely situation and your code has to handle it ...
> though, adding white space at the end doesn't fix the problem
> i.e $request = "$request " if($request =~ /=$/);
...without changing the data. whitespace is different than no data. this
might be significant in some applications.
> Right now I get around it by doing a long-winded approach of
> &url_decode($key,$val);
> $rqp{$key} = $val;
kinda curious what is hapening there. you pass to scalars which are
not references to a subroutine. you don't store the results of the
subroutine call, then you use the same to scalars to build a hash.
so what is your subroutine doing? just curious...
btw, you can skip the longwinded approaches by putting
use CGI;
use URI::Escape;
good luck :)
--
brian d foy <http://computerdog.com>
#!/usr/bin/perl
$_=q|osyrNewkecnaYhe.mlorsePptMskurj|;s;[NY.PM]; ;g;local$\=
qq$\n$;@pm=split//;while($NY=pop @pm){$pm.=$NY;$ny.=pop @pm}
$pm=join'',reverse($ny,$pm);open(NY,'>&STDOUT');print NY $pm
------------------------------
Date: Sat, 20 Dec 1997 16:09:08 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <67hbom$gov@bgtnsc02.worldnet.att.net>
In article <349caecf.11881705@news.tornado.be>, bart.mediamind@tornado.be
(Bart Lateur) wrote:
> 0.532 ( 5.7 / 10.8) 19 comdog@computerdog.com (brian d foy)
> And it's not just me: it looks like the statistics only included 13
> posters... Anthony David is both number 4 and number 10th from the
> bottom up.
must not have had a full newsfeed that week. i think there were two
days during that period where i posted 19 articles on each day.
it came up in conversation the other night that Original Content
Ratio is a misnomer though. some of us like cutting and pasting
certain response (me too), so they really aren't original are they?
not that i'm arguing anything that would lower my apparent signal
any lower :)
--
brian d foy <http://computerdog.com>
#!/usr/bin/perl
$_=q|osyrNewkecnaYhe.mlorsePptMskurj|;s;[NY.PM]; ;g;local$\=
qq$\n$;@pm=split//;while($NY=pop @pm){$pm.=$NY;$ny.=pop @pm}
$pm=join'',reverse($ny,$pm);open(NY,'>&STDOUT');print NY $pm
------------------------------
Date: Sat, 20 Dec 1997 18:08:51 -0800
From: Terry McC <terrymcc@buffnet.net>
Subject: Still need HELP (INA)
Message-Id: <349C7A33.405C@buffnet.net>
-
Need help with a simple perl program.
Someone named Ina replied to me but I can NOT get on your site:(
There is a problem with my email address?? Ina Please send me email so
I can reply back to you (not the auto responder :-)
Thanks
--
Terry McC. SysAdmin
mailto:terrymcc@buffnet.net
mailto:terry@olsbuff.com
------------------------------
Date: Sat, 20 Dec 1997 16:29:15 -0500
From: "William J. Leary Jr." <Bill_Leary@msn.com>
Subject: Re: Which language pays most 17457 -- C++ vs. Java?
Message-Id: <ObfZp4YD9GA.296@upnetnews02.moswest.msn.net>
Kaz Kylheku wrote in message <67gvpa$m3t$1@brie.direct.ca>...
>The library is part of the language, you buffoon, the same way that basic
>words like 'air' and 'water' are part of English.
Not that I've ever noticed. I frequently use C compilers to target embedded
systems. We pretty much always discard the standard library and bring up
our own basic library for the features we actually need. The standard
library pretty much is always hooked into the OS (or OS's) the compiler is
targeting. Since we're usually either on the iron, or on an RTOS the
standard stuff the standard library want's isn't usuall there.
>In C, the standard library functions have special status.
> First of all, their names are reserved external symbols.
Not usually. Their "special status" comes from the fact that they get put
into the symbol table because you always include "stdio.h" or "stdlib.h" or
whatever. In some cases a compiler will pay special attention to some of
the routines (like strcpy) so it can inline them
automagically. In all cases where I've seen this there's been a compiler
switch to turn it off.
I've dumped the standard library lots of times and written new routines for
some of the standard features and never had a compiler or linker complain
about them.
> If any C program contains an external definition of an identifier that is
an external name
> reserved by the standard library, the behavior is undefined.
If you link in the standard library, you usually get a linker error, unless
the linker isn't too bright. If you don't link in the library, it usually
just works as expected. That is, your routine which replaced, say, fputc,
just gets linked in.
>Secondly, if you include a standard header, you may not redeclare any
symbol
>in that standard header, not even in a nested scope.
Done it several times. Program started in DOS, so I needed the standard
libs for progress messages. Switched to protected mode in high memory and
zapped DOS in low RAM for buffers. Used my own fputc and so forth after
that.
> I'm not talking about optimization. I'm talking about recognition of
standard
> functions as thought they where primitives. The C standard permits an
> implementation to do that.
Yep, some compilers will do that. Metaware, for example, will catch memcpy
and optimize it for the 80x86 REPT modifier. It can be turned off with a
compile time switch, because it's NOT part of the C langauge but rather is
the compiler maker noticing a chance to get you better executing code by
implementing one of the standard library functions as if it were a language
primitave.
> ((.. omitted..))
> In C, it's like this: a strictly conforming program may not define its own
> strcmp() function with external linkage. If you want to write your own
strcmp,
> you would have to give it internal linkage using the static keyword:
static
> int strcmp(...) { ... }. You are then forbidden from including the
<string.h>
> header in that translation unit. The compiler is then required to
recognize
> that you have defined your own strcmp and no longer treat it as a built-in
> primitive.
>
>It works just fine in GCC, for instance.
I just realized here that you guys may be discussing two different things.
It sounds like one of you is arguing about the C language itself, and the
other is arguing about what makes up a standard C program. The library
isn't part of the language. Look at the syntax diagrams for the language.
There's no library features in there. On the other hand, a standard C
program, one which is in compliance with the specs, does include that
library stuff.
- Bill
------------------------------
Date: Sat, 20 Dec 1997 20:14:36 -0500
From: "William J. Leary Jr." <Bill_Leary@msn.com>
Subject: Re: Which language pays most 17457 -- C++ vs. Java?
Message-Id: <#vJ8k2aD9GA.169@upnetnews03>
>Kurt Watzka wrote in message <67hg7m$g9f$1@sparcserver.lrz-muenchen.de>...
>>"William J. Leary Jr." <Bill_Leary@msn.com> writes:
>>> Kaz Kylheku wrote in message <67gvpa$m3t$1@brie.direct.ca>...
--- ((..omitted..))
>What Kaz Kylheku is missing is the word "hosted environement".
Yes, very good. THAT makes a lot of sense, and I've seen that myself.
Still, that's the environment, not the langauge specification for C.
--- ((..omitted..))
>>Not usually. Their "special status" comes from the fact that they get put
>>into the symbol table because you always include "stdio.h" or "stdlib.h"
or
>>whatever.
>
> Not so. The names are reserved in a hosted environment no matter what
> headers are included.
Again, I agree. The environment might well require that. The language
spec. doesn't.
> This is what Kaz was trying to tell you.
Not me. he was writing to someone else.
> "All identifiers with external linkage in any of the following (i.e
> the library) subclauses including the future library directions
> are always reserved for use as identifiers with external linkage"
> cannot be interpreted in a way that restricts the reservation to
> compilation units that include certain standard headers.
Yep, no disagreement. But we seem to be getting rather far afield of the
argument I was commenting on, which *appeared* to be that the C language
_itself_ included the standard library.
>> In some cases a compiler will pay special attention to some of
>>the routines (like strcpy) so it can inline them
>>automagically.
>
>I doubt that it is allowed to do so in a freestanding environenment
>without explicitly stating that fact in its documentation.
Yes. The one I used (Metaware) and reviewed (Orin? Ordin? I'm not sure...
years ago) both had notes in their compiler switches section about these
features. Metaware also included it in the debugging section, since it was
impossible to set a breakpoint on, say, strcpy if it was inlined.
>> In all cases where I've seen this there's been a compiler
>> switch to turn it off.
>
>Again, the point is the difference between a freestanding environement
>and a hosted environment.
I absolutely agree with you. However, the thread of conversation I reviewed
didn't seem to be talking about operation under an environment. It seemed
to be a discussion about the basic C language and it's supposed inclusion of
the standard library as part of that language.
> In a freestanding environment, the name and type of the function called at
program
> startup are implementation defined. It may well be "void
ToasterStart(float
> TimerSetting)". There are otherwise no reserved external identifiers in a
freestanding
> environment. This means that you are indeed free to use names in your
toaster control
> program that would be reserved identifiers in a program targeting a
hosted
> environment.
Agreed again.
>> I've dumped the standard library lots of times and written new routines
for
>> some of the standard features and never had a compiler or linker complain
>> about them.
>
>>> If any C program contains an external definition of an identifier that
is
>>> an external name reserved by the standard library, the behavior is
undefined.
>
> This means that neither the compiler nor the linker is obliged in any
> way to complain about the redefinition of functions from the standard
> library, but the behaviour of such a program is still undefined. "It
> worked so far" is a _very_ weak proof of correctness, given that
> undefined behaviour may well be limited to Thursdays before Friday
> the 13th in odd years.
No disagreement here either.
>> If you link in the standard library, you usually get a linker error,
unless
>> the linker isn't too bright. If you don't link in the library, it
usually
>> just works as expected. That is, your routine which replaced, say,
fputc,
>> just gets linked in.
>
>This need not be true in a hosted environment. The compiler may well
>inline calls to fputc(), or generate calls to __libc_term_FPUTC instead.
It might well inline the function, but inlining is a performance issue.
It's not supposed to break the integrity of the program in doing so. On the
other hand, I don't disagree with you or him here. If the compiler writer
has chosen to make such things primative AND doesn't pass on the symbols for
the inlined to the linker, so they can be caught if re-used incorrectly,
then of course it's undefined.
>>> Secondly, if you include a standard header, you may not redeclare any
>>> symbol in that standard header, not even in a nested scope.
>
>>Done it several times. Program started in DOS, so I needed the standard
>>libs for progress messages. Switched to protected mode in high memory and
>>zapped DOS in low RAM for buffers. Used my own fputc and so forth after
>>that.
>
>You wouldn't mind telling us which companies use or sell your products,
>would you?
The Bytex Series 7700 Token Ring / Ethernet Programmable Hub.
Long before the product got to market we'd eliminated the DOS stage and
booted directly into protected mode from a modified BIOS, but the initial
system did indeed work this way.
The other I'm not at liberty to discuss due to non-disclosure agreements.
>>> I'm not talking about optimization. I'm talking about recognition of
standard
>>> functions as thought they where primitives. The C standard permits an
>>> implementation to do that.
>
>> Yep, some compilers will do that. Metaware, for example, will catch
memcpy
>> and optimize it for the 80x86 REPT modifier. It can be turned off with a
>> compile time switch, because it's NOT part of the C langauge but rather
is
>> the compiler maker noticing a chance to get you better executing code by
>> implementing one of the standard library functions as if it were a
language
>> primitave.
>
> The possibility that the definition of the C programming language indeed
> does permit what Kaz claims it to permit does obviously escape you.
Not at all. I've read the ANSI C spec and it clearly leave a lot of leeway
about how things are implemented. I agreed.
> An implementation of the C programming language is free to recognize calls
> to functions from the standard C library as special cases and treat them
in a
> special way.
Yep. I agreed with that. No argument at all. In fact, I provided an
example of an compiler I'd used which did just that.
> If you think that this is not so, don't try to prove your point with
statements like "I tried
> it once and it looked as if it worked on the implementation I was using at
that time".
I didn't. I pointed out how one specific implementation (Metaware) had both
done the optimization route AND complied with the language spec by providing
a switch to turn off the inlines.
> Try to find some text in the language definition that supports your point
of view.
Supports it how?
My point of view is that the C _language_ does not include the C
_standard_library_ functions as part of the _language_. A particular C
programming environment may well do something other than this, and that's
their option.
I don't see what it is I'm supposed to use to support my point of view,
unless you'd like me to quote the entire language and end up saying "no
standard library primitives found herein."
For that matter, whether you'd like me to do that or not, perhaps you can
point me to a place on the net where the ANSI C spec is available. I've
just done a search and I've found the ANSI C++ spec, but can't find the ANSI
C spec. The one I had belonged to my former employer and I had to leave it
there when I left the company.
- Bill
------------------------------
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 1515
**************************************