[28016] in Perl-Users-Digest
Perl-Users Digest, Issue: 9380 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 26 00:05:42 2006
Date: Sun, 25 Jun 2006 21:05:04 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 25 Jun 2006 Volume: 10 Number: 9380
Today's topics:
Another newbie question <qbert@comcast.net>
File::Find beginner question <none@nowhere.com>
Re: File::Find beginner question <benmorrow@tiscali.co.uk>
Re: Hash of Arrays <pradeep.bg@gmail.com>
Re: Hash of Arrays <mumia.w.18.spam+nospam.usenet@earthlink.net>
Re: languages with full unicode support <oliver@first.in-berlin.de>
Re: languages with full unicode support <xah@xahlee.org>
Re: languages with full unicode support <omouse@gmail.com>
Re: nl_langinfo - problem <tadmc@augustmail.com>
Re: nl_langinfo - problem <tadmc@augustmail.com>
Re: nl_langinfo - problem <tadmc@augustmail.com>
Re: Problem with Multi- threaded Server <janicehwang1325@yahoo.com>
Tuesday Sept 11th 2001 CRIME INVESTIGATION u2r2h@gmx.net
Re: Tuesday Sept 11th 2001 CRIME INVESTIGATION <phlip2005@gEEEmail.com>
Re: What is Expressiveness in a Computer Language <dnew@san.rr.com>
Re: What is Expressiveness in a Computer Language <cdsmith@twu.net>
Re: What is Expressiveness in a Computer Language <find@my.address.elsewhere>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 25 Jun 2006 21:03:20 -0400
From: "Jockser" <qbert@comcast.net>
Subject: Another newbie question
Message-Id: <mYudnRuMqZzRrwLZnZ2dnUVZ_tWdnZ2d@comcast.com>
Hello, I'm trying to set up template toolkit to process a xml file and
poplulate the data elements into a template.
I'm trying to understand the example in O'Reilly's Perl Template Toolkit
book. But I'm not doing something right.
Here is what I'm doing:
I have a file named report.tt
[% USE inventory = XML.Simple('products.xml') -%]
[% FOREACH product = inventory.product.keys.sort;
current = inventory.product.$product -%]
[% current.id %] [% product %]
[%- current.stock | format('%5d') %] units @
[%- current.price | format('%6.2f') -%] =
[%- current.stock * current.price | format('%10.2f') %]
[%- total = total + current.stock * current.price %]
[% END -%]
Total value: [% total | format('%10.2f')%]
I try running this at the command prompt by typing:
tpage report.tt
and I get back:
plugin error - XML.Simple: plugin not found
If I check PPM I do have this installed:
38. XML-Simple [2.14] Easy API to maintain XML (esp config
file~
I don't know if I'm running this correctly by using tpage, or if it all
needs to go into a perlscript some how.
Any help would be appreciated!!
Thanks,
------------------------------
Date: Mon, 26 Jun 2006 11:59:53 +1200
From: Warwick <none@nowhere.com>
Subject: File::Find beginner question
Message-Id: <1151279781.836165@ftpsrv1>
Hi,
I am trying to use file::find to generate a list of leaf directories.
I am teaching myself by hacking with code so I welcome any suggestions
on the approach.
Particular points that have confused me - usage of 'last'- I moved it
out of the if block and also behaviour made me wonder if 'last' were not
terminating the outer file::find loop.
Also the man page for file::find says that preprocess takes a list of
strings and is expected to return one. So I have return @_ statements
which look odd but seem to help.
I hope someone can help.
<script>
#use strict;
use warnings;
use File::Find;
#------------------------------------------------------------
my $rootDir = "C:/documents and settings/all users/";
my @allDirectories;
my @leafDirectories;
my $dirCount = 0;
my $leafCount = 0;
my $output = '>c:\Perl\my scripts\Duplicate_Directories.txt';
#-------------------------------------------------------------
open(FILE, $output) or die "can't open output file!";
print FILE "#Root: $rootDir.\n";
finddepth(
{
preprocess => \&Pre,
wanted => sub {return;},
postprocess => \&Post
}, $rootDir);
print FILE "#All directories: $dirCount\n";
foreach (@allDirectories) {
print FILE "\t$_\n";
}
print FILE "#Leaf directories: $leafCount\n";
foreach (@leafDirectories) {
print FILE "\t$_\n";
}
print "\n#done\n";
close FILE;
exit;
#-------------------------------------------------------------
sub Post
{
return @_ ;
}
#-------------------------------------------------------------
sub Pre
{
my $isLeaf = 1; #assume true
foreach (@_) {
if (-d) {$isLeaf = 0;}
#unless( $isLeaf ){last;} #exit loop if subdiretory found
}
push @allDirectories, $File::Find::dir;
++$dirCount;
if ($isLeaf){ #add to global array if true
push @leafDirectories, $File::Find::dir;
++$leafCount;
}
return @_;
}
#-------------------------------------------------------------
</script>
cheers
------------------------------
Date: Mon, 26 Jun 2006 03:11:18 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: File::Find beginner question
Message-Id: <6bs3n3-qvq.ln1@osiris.mauzo.dyndns.org>
Quoth Warwick <none@nowhere.com>:
> Hi,
> I am trying to use file::find to generate a list of leaf directories.
Case matters for Perl modules, so it is better to call it File::Find.
> I am teaching myself by hacking with code so I welcome any suggestions
> on the approach.
>
> Particular points that have confused me - usage of 'last'- I moved it
> out of the if block and also behaviour made me wonder if 'last' were not
> terminating the outer file::find loop.
last terminates the innermost loop. A sub *can* last out of a loop in
its caller: so calling last not inside a loop in a File::Find callback
will stop the find.
In your case, a last where you have it commented should do what you
expect...?
> Also the man page for file::find says that preprocess takes a list of
> strings and is expected to return one. So I have return @_ statements
> which look odd but seem to help.
I think you're misusing preprocess. The docs say it is to filter the
list of files by name alone, or sort them, before File::Find stats them:
something like
preprocess => sub { grep !/^CVS$/ @_ },
for filtering CVS directories is the intended use. I would use something
more like (untested)
my (@dirs, %branch);
finddepth {
wanted => sub {
-d or return;
push @dirs, $File::Find::name;
$branch{$File::Find::dir} = 1;
},
}, $rootDir;
my @leaves = grep { ! $branch{$_} } @dirs;
print "#Root: $rootDir";
print "#All directories: " . @dirs;
# in scalar context, an array returns its size
print "\t$_" for @dirs;
print "#Leaf directories: " . @leaves;
print "\t$_" for @leaves;
Further detailed comments follow.
> <script>
> #use strict;
You want this on, all the time. The rare occasions where it is not
helpful are better handled with a { no strict 'foo'; ... } block.
> use warnings;
> use File::Find;
> #------------------------------------------------------------
>
> my $rootDir = "C:/documents and settings/all users/";
> my @allDirectories;
> my @leafDirectories;
>
> my $dirCount = 0;
There's no need for these counts. Arrays know how big they are.
> my $leafCount = 0;
> my $output = '>c:\Perl\my scripts\Duplicate_Directories.txt';
>
> #-------------------------------------------------------------
> open(FILE, $output) or die "can't open output file!";
You would be better off using 3-arg open and lexical FHs here... that is
my $output = 'c:/Perl/my scripts/Duplicate_Directories.txt';
open my $FILE, '>', $output or die "can't write to '$output': $!";
Your print statements will then need to be print $FILE "..." of course.
> print FILE "#Root: $rootDir.\n";
All these "\n"s get really tedious: it's easier to say
$\ = "\n";
and get Perl to do them for you. Read about $\ in perldoc perlvar.
You can change the default output FH with select, then you don't need to
specify it all the time.
> finddepth(
> {
> preprocess => \&Pre,
> wanted => sub {return;},
> postprocess => \&Post
Since your &Post does nothing, you don't need to supply a postprocess
key at all.
> }, $rootDir);
>
> print FILE "#All directories: $dirCount\n";
> foreach (@allDirectories) {
> print FILE "\t$_\n";
> }
> print FILE "#Leaf directories: $leafCount\n";
>
> foreach (@leafDirectories) {
> print FILE "\t$_\n";
> }
> print "\n#done\n";
> close FILE;
With lexical FHs, they will close themselves when they are no longer
needed. Unless you are checking the return value of close (required for
robust programs, not needed for simple scripts like this) you don't need
to do it yourself.
> exit;
You don't need to exit. Falling off the end is a perfectly respectable
way to sucessfully complete a Perl program.
> #-------------------------------------------------------------
> sub Post
> {
> return @_ ;
> }
> #-------------------------------------------------------------
> sub Pre
> {
> my $isLeaf = 1; #assume true
> foreach (@_) {
> if (-d) {$isLeaf = 0;}
> #unless( $isLeaf ){last;} #exit loop if subdiretory found
> }
I would do this with List::MoreUtils::any, like
use List::MoreUtils qw/any/; # at the top
$isLeaf = not any { -d } @_;
or remove $isLeaf altogether and put the condition straight in the if.
Ben
--
We do not stop playing because we grow old;
we grow old because we stop playing.
benmorrow@tiscali.co.uk
------------------------------
Date: 25 Jun 2006 17:05:36 -0700
From: "Deepu" <pradeep.bg@gmail.com>
Subject: Re: Hash of Arrays
Message-Id: <1151280336.919094.288550@p79g2000cwp.googlegroups.com>
Hi John,
I was trying your code and had a question regarding that.
use warnings;
use strict;
@ARGV = qw/FILE1 FILE2/;
my ( $suspendCount, %transitions );
while ( <> ) {
push @{ $transitions{ $ARGV } }, [] if /STATEMAIN/;
if ( /STATEMAIN/ .. /RESET/ || eof ) {
push @{ $transitions{ $ARGV }[ -1 ] }, $_;
$suspendCount += /STATESUSPEND/;
}
}
__END__
I changed the file (input file):
STATE1 blk: 10 pg:10
STATE3 blk:11 pg:100
STATEMAIN #### blk: 100 pg: 20
STATESUSPEND
STATE1
STATE2
STATERESUME
RESET
STATE6
STATE8
STATEMAIN ####
STATE9
STATE10
and all the states will have blk and pg numbers.
But when i changed the script for just taking state names and blk
numbers. I get 'undef' in the output.
@ARGV = qw/FILE1 FILE2/;
my ( $suspendCount, %transitions );
while ( <> ) {
if ($_ =~ /^\s*(\S+\t+blk:\s+\S+)\s+pg:\s+(\S+)/) {
push @{ $transitions{ $ARGV } }, [] if /STATEMAIN/;
if ( /STATEMAIN/ .. /RESET/ || eof ) {
push @{ $transitions{ $ARGV }[ -1 ] }, $1; #### $_ changed to
$1
$suspendCount += /STATESUSPEND/;
}
}
}
__END__
Now i get the output:
$VAR1 = (
FILE1 => [
[
undef,
STATESUSPEND
STATE1,
STATE2,
STATERESUME,
undef
],
and so on.
In the array STATEMAIN and RESET is undef after the changes, why is
this?? Thanks for helping me on this.
------------------------------
Date: Mon, 26 Jun 2006 02:09:02 GMT
From: "Mumia W." <mumia.w.18.spam+nospam.usenet@earthlink.net>
Subject: Re: Hash of Arrays
Message-Id: <2lHng.1342$NP4.944@newsread1.news.pas.earthlink.net>
Deepu wrote:
> [...]
> if ($_ =~ /^\s*(\S+\t+blk:\s+\S+)\s+pg:\s+(\S+)/) { <--- Line 1
>
> push @{ $transitions{ $ARGV } }, [] if /STATEMAIN/;
>
>
> if ( /STATEMAIN/ .. /RESET/ || eof ) { <--- Line 2
>
>
> push @{ $transitions{ $ARGV }[ -1 ] }, $1; #### $_ changed to
> $1
> [...]
>
> In the array STATEMAIN and RESET is undef after the changes, why is
> this?? Thanks for helping me on this.
>
Whenever a successful match occurs, and no capturing was done, the match
variables are reset.
On line 2, when /STATEMAIN/ (or /RESET/) is successful, the match
variables $1 and $2 are reset. IOW (in other words), the data captured
from line 1 is lost at line 2, so you need to save the values in other
variables before you get to line 2.
------------------------------
Date: Mon, 26 Jun 2006 00:54:04 +0200
From: Oliver Bandel <oliver@first.in-berlin.de>
Subject: Re: languages with full unicode support
Message-Id: <1151276031.641318@elch.in-berlin.de>
こんいちわ Xah-Lee san ;-)
Xah Lee wrote:
> Languages with Full Unicode Support
>
> As far as i know, Java and JavaScript are languages with full, complete
> unicode support. That is, they allow names to be defined using unicode.
Can you explain what you mena with the names here?
> (the JavaScript engine used by FireFox support this)
>
> As far as i know, here's few other lang's status:
>
> C → No.
Well, is this (only) a language issue?
On Plan-9 all things seem to be UTF-8 based,
and when you use C for programming, I would think
that C can handle this also.
But I only have read some papers about Plan-9 and did not developed on
it....
Only a try to have a different view on it.
If someone knows more, please let us know :)
Ciao,
Oliver
------------------------------
Date: 25 Jun 2006 19:56:46 -0700
From: "Xah Lee" <xah@xahlee.org>
Subject: Re: languages with full unicode support
Message-Id: <1151290606.900787.262890@m73g2000cwd.googlegroups.com>
Mumia W. wrote:
[example of perl supporting unicode in var names]
oh shit, i was surprised but actually i knew it all along., just forgot
about it. :)
see
http://xahlee.org/perl-python/unicode.html
.=2E.
=C2=ABuse bytes; # Larry can take Unicode and shove it up his ass sideways.
# Perl 5.8.0 causes us to start getting incomprehensible
# errors about UTF-8 all over the place without this.=C2=BB
=E2=80=94from the source code of WebCollage (1998),
by Jamie W Zawinski (~1971-)
What's Jamie yabbing about there?
Xah
xah@xahlee.org
=E2=88=91 http://xahlee.org/
------------------------------
Date: 25 Jun 2006 20:56:46 -0700
From: "OMouse" <omouse@gmail.com>
Subject: Re: languages with full unicode support
Message-Id: <1151294206.255080.216880@m73g2000cwd.googlegroups.com>
> As far as i know, here's few other lang's status:
>
> C =E2=86=92 No.
I think C has the wchar type to handle larger values. And C++ has
std::wstring. So really, the support is there.
http://www.cl.cam.ac.uk/~mgk25/unicode.html#c
I think the problem is that most C/C++ coders don't care about unicode
support and so they stick to char and std::string.
------------------------------
Date: Sun, 25 Jun 2006 17:21:47 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: nl_langinfo - problem
Message-Id: <slrne9u33r.fvr.tadmc@magna.augustmail.com>
Adam Smith <adamsmith@econ.com> wrote:
> This is my last response to this issue: I have no intent to develop a
> 'tight pants' sitting on the pinnacle of nonsense and squirming with
> tortured delight.
If you insist on farting at the dinner table, then don't moan
when you are no longer invited for dinner.
If you insist on ignoring netiquette, then don't moan
when you get a "multitude" of responses.
You expect to treat people badly, and be treated nicely
in return? That seems an unreasonable expectation.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 25 Jun 2006 17:23:54 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: nl_langinfo - problem
Message-Id: <slrne9u37q.fvr.tadmc@magna.augustmail.com>
Ben Morrow <benmorrow@tiscali.co.uk> wrote:
> Quoth Adam Smith <adamsmith@econ.com>:
> Also, crossposting to alt.* is generally unwelcome here.
Also also, it is very likely to result in less people seeing
your question.
>> And from the "multitude" of responses received I have not been very
>> successful either. You were the only one responding so far after many days.
>
> Well, a lot of people here simply killfile large cross-posts.
That's why I never saw the thread.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 25 Jun 2006 17:26:08 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: nl_langinfo - problem
Message-Id: <slrne9u3c0.fvr.tadmc@magna.augustmail.com>
Adam Smith <adamsmith@econ.com> wrote:
> Merely, launching Perl produces the Undefined symbol condition.
> Suggestions sought
Try using Python instead.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 25 Jun 2006 20:21:01 -0700
From: "janicehwang1325@yahoo.com" <janicehwang1325@yahoo.com>
Subject: Re: Problem with Multi- threaded Server
Message-Id: <1151292061.508936.205490@r2g2000cwb.googlegroups.com>
Thanks for the debuggin guidelines. Here are some results for my
testing:
1. Threaded server works fine without SSL.
2. DBI doesn't cause a problem for threaded server (either enable or
disable DBI does not cause the problem with the condition WITHOUT SSL)
3. Threaded server fails when use with SSL.
4. Threaded server works without SSL and DBI.
I tried to debug by printing line after each process. I found out that,
when the second client(same host as the first client) trying to connect
to the server, the server is actually spawning a new thread to handle
it. The error occurs is after the server receiving the data from the
second client. Segmentation fault occurs either after receiving first
few lines of the data and after server spawns a new thread.
Nevertheless, I found out that the server actually detach the threads
after spawning the first thread. I have no idea what is actually going
on. Please advice.
Ted Zlatanov wrote:
> On 23 Jun 2006, janicehwang1325@yahoo.com wrote:
>
> > I post the program before, however, based on the response, i simplify
> > my server code in the following. I still got error when the clients on
> > the same LAN trying to connect to the server it gives me segmentation
> > fault error. What is the cause? For your information, the prefork
> > server runs perfectly well without any errors. However, due to
> > specification, i need to design my server handling multiple clients
> > using threads.
>
> Hello,
>
> thanks for posting complete code. Now you know:
>
> - the DBI+SSL server works without threads
>
> Next, find out if:
>
> - the threaded server works without SSL
> - the threaded server works without DBI
> - the threaded server works without SSL and DBI (trivial case, but needed)
>
> I would say at this point it's very likely you're hitting a bug, so
> find out where it is... Then you can try to avoid the bug and you can
> tell the developers about it.
>
> Ted
------------------------------
Date: 25 Jun 2006 19:29:44 -0700
From: u2r2h@gmx.net
Subject: Tuesday Sept 11th 2001 CRIME INVESTIGATION
Message-Id: <1151288983.985347.303810@r2g2000cwb.googlegroups.com>
Calling all US Americans
==================
please HELP find the culprit in the murder of 2897 people on 9/11.
It unbelievable that the attack on Afghanistan and Iraq
helped resolve the problem of 9/11... Be un-afraid.
People .. please watch the shocking videos with an open mind:
http://video.google.com/videoplay?docid=-5137581991288263801 Loose
Change
http://video.google.com/videoplay?docid=6757267008400743688 Everybody
gotta learn
http://video.google.com/videoplay?docid=6545313046180631815 EVIDENCE
http://video.google.com/videoplay?docid=964034652002408586 Prof Steven
E. Jones Lecture
http://video.google.com/videoplay?docid=-4429289437231286745
Compilation
http://video.google.com/videoplay?docid=6323427897709690102 Painful
Deceptions
Scientists, please read peeer-reviewed
essays:http://journalof911studies.com/
http://video.google.com/videoplay?docid=-3498980438587461603
Computer programmers: HOW can a 757 fly like that?
http://images.google.com/images?q=pentagon+impact
Home Repair: Janitor reports on BOMBS in the UNDERGROUND of WTC 1 & 2
http://www.reopen911.org/wrodriguez.php
http://www.thememoryhole.org/911/veliz-bombs.htm
Celebrity CHARLIE SHEEN
http://www.911truth.org/article.php?story=20060323162638376
Mathematicians, find the mistake:
http://worldtradecentertruth.com/W7Kuttler.pdf
please, please invest time in this important matter.
------------------------------
Date: Mon, 26 Jun 2006 03:38:29 GMT
From: Phlip <phlip2005@gEEEmail.com>
Subject: Re: Tuesday Sept 11th 2001 CRIME INVESTIGATION
Message-Id: <pan.2006.06.26.03.38.19.580778@gEEEmail.com>
u2r2h wrote:
> Home Repair: Janitor reports on BOMBS in the UNDERGROUND of WTC 1 & 2
> http://www.reopen911.org/wrodriguez.php
> http://www.thememoryhole.org/911/veliz-bombs.htm
I have heard that many of these "conspiracy" web sites are funded by
NeoCons, as a technique am the signal from more responsible conspiracy
theorists...
I personally believe the ultimate truth about the matter appears here:
http://flea.sourceforge.net/PiglegToo_1.html
--
Phlip
------------------------------
Date: Mon, 26 Jun 2006 00:08:25 GMT
From: Darren New <dnew@san.rr.com>
Subject: Re: What is Expressiveness in a Computer Language
Message-Id: <ZzFng.4215$MF6.3773@tornado.socal.rr.com>
Gabriel Dos Reis wrote:
> I would suggest you give more thoughts to the claims made in
> http://www.seas.upenn.edu/~sweirich/types/archive/1999-2003/msg00298.html
I'm not sure I understand this. Looking at "Example 2", where C is
claimed to be "C-safe", he makes two points that I disagree with.
First, he says Unix misimplements the operations semantics of C. It
seems more like Unix simply changes the transition system such that
programs which access unmapped memory are terminal.
Second, he says that he hasn't seen a formal definition of C which
provides precide operational semantics. However, the language standard
itself specified numerous "undefined" results from operations such as
accessing unallocated memory, or even pointing pointers to unallocated
memory. So unless he wants to modify the C standard to indicate what
should happen in such situations, I'm not sure why he thinks it's "safe"
by his definition. There is no one "q" that a "p" goes to based on the
language. He's confusing language with particular implementations. He
seems to be saying "C is safe, oh, except for all the parts of the
language that are undefined and therefore unsafe. But if you just
clearly defined every part of C, it would be safe." It would also seem
to be the case that one could not say that a program "p" is either
terminal or not, as that would rely on input, right? gets() is "safe" as
long as you don't read more than the buffer you allocated.
What's the difference between "safe" and "well-defined semantics"?
(Ignoring for the moment things like two threads modifying the same
memory at the same time and other such hard-to-define situations?)
--
Darren New / San Diego, CA, USA (PST)
Native Americans used every part
of the buffalo, including the wings.
------------------------------
Date: Sun, 25 Jun 2006 18:16:08 -0600
From: Chris Smith <cdsmith@twu.net>
Subject: Re: What is Expressiveness in a Computer Language
Message-Id: <MPG.1f08d526ff47053e989703@news.altopia.net>
Chris F Clark <cfc@shell01.TheWorld.com> wrote:
> These informal systems, which may not prove what they claim to prove
> are my concept of a "type system".
Okay, that works. I'm not sure where it gets us, though, except for
gaining you the right to use "type system" in a completely uninteresting
sense to describe your mental processes. You still need to be careful,
since most statements from type theory about type systems tend to
implicitly assume the property of being sound.
I'm not exactly convinced that it's possible to separate that set of
reasoning people do about programs into types and not-types, though. If
you want to stretch the definition like this, then I'm afraid that you
end up with the entire realm of human thought counting as a type system.
I seem to recall that there are epistemologists who would be happy with
that conclusion (I don't recall who, and I'm not actually interested
enough to seek them out), but it doesn't lead to a very helpful sort of
characterization.
> It is to the people who are reasoning informally about
> the program we wish to communicate that there is a type error. That
> is, we want someone who is dealing with the program informally to
> realize that there is an error, and that this error is somehow related
> to some input not being kept within proper bounds (inside the domain
> set) and that as a result the program will compute an unexpected and
> incorrect result.
I've lost the context for this part of the thread. We want this for
what purpose and in what situation?
I don't think we necessarily want this as the goal of a dynamic type
system, if that's what you mean. There is always a large (infinite? I
think so...) list of potential type systems under which the error would
not have been a type error. How does the dynamic type system know which
informally defined, potentially unsound, mental type system to check
against? If it doesn't know, then it can't possibly know that something
is a type error. If it does know, then the mental type system must be
formally defined (if nothing else, operationally by the type checker.)
> I also stress the informality, because beyond a certain nearly trivial
> level of complexity, people are not capable of dealing with truly
> formal systems.
I think (hope, anyway) that you overstate the case here. We can deal
with formal systems. We simply make errors. When those errors are
found, they are corrected. Nevertheless, I don't suspect that a large
part of the established base of theorems of modern mathematics are
false, simply because they are sometimes rather involved reasoning in a
complex system.
Specifications are another thing, because they are often developed under
time pressure and then extremely difficult to change. I agree that we
should write better specs, but I think the main challenges are political
and pragmatic, rather than fundamental to human understanding.
> Therefore, I do not want to exlcude from type systems, things wich are
> informal and unsound. They are simply artifacts of human creation.
Certainly, though, when it is realized that a type system is unsound, it
should be fixed as soon as possible. Otherwise, the type system doesn't
do much good. It's also true, I suppose, that as soon as a person
realizes that their mental thought process of types is unsound, they
would want to fix it. The difference, though, is that there is then no
formal definition to fix.
--
Chris Smith - Lead Software Developer / Technical Trainer
MindIQ Corporation
------------------------------
Date: Sun, 25 Jun 2006 21:43:23 -0500
From: Matthias Blume <find@my.address.elsewhere>
Subject: Re: What is Expressiveness in a Computer Language
Message-Id: <m2r71c7i2c.fsf@hanabi.local>
Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
> rossberg@ps.uni-sb.de writes:
>
> | think that it is too relevant for the discussion at hand. Moreover,
> | Harper talks about a relative concept of "C-safety".
>
> Then, I believe you missed the entire point.
>
> First point: "safety" is a *per-language* property. Each language
> comes with its own notion of safety. ML is ML-safe; C is C-safe;
> etc. I'm not being facetious; I think this is the core of the
> confusion.
>
> Safety is an internal consistency check on the formal definition of
> a language. In a sense it is not interesting that a language is
> safe, precisely because if it weren't, we'd change the language to
> make sure it is! I regard safety as a tool for the language
> designer, rather than a criterion with which we can compare
> languages.
I agree with Bob Harper about safety being language-specific and all
that. But, with all due respect, I think his characterization of C is
not accurate. In particular, the semantics of C (as specified by the
standard) is *not* just a mapping from memories to memories. Instead,
there are lots of situations that are quite clearly marked in C's
definition as "undefined" (or whatever the technical term may be). In
other words, C's specified transition system (to the extend that we
can actually call it "specified") has lots of places where programs
can "get stuck", i.e., where there is no transition to take. Most
actual implementations of C (including "Unix") are actually quite
generous by filling in some of the transitions, so that programs that
are officially "legal C" will run anyway.
Example:
The following program (IIRC) is not legal C, even though I expect it
to run without problem on almost any machine/OS, printing 0 to stdout:
#include <stdio.h>
int a[] = { 0, 1, 2 };
int main (void)
{
int *p, *q;
p = a;
q = p-1; /** illegal **/
printf("%d\n", q[1]);
return 0;
}
Nevertheless, the line marked with the comment is illegal because it
creates a pointer that is not pointing into a memory object. Still, a
C compiler is not required to reject this program. It is allowed,
though, to make the program behave in unexpected ways. In particular,
you can't really blame the compiler if the program does not print 0,
or if it even crashes.
AFAIC, C is C-unsafe by Bob's reasoning.
---
Of course, C can be made safe quite easily:
Define a state "undefined" that is considered "safe" and add a
transition to "undefined" wherever necessary.
Kind regards,
Matthias
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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.
#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 V10 Issue 9380
***************************************