[27945] in Perl-Users-Digest
Perl-Users Digest, Issue: 9309 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 17 03:06:02 2006
Date: Sat, 17 Jun 2006 00:05:06 -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 Sat, 17 Jun 2006 Volume: 10 Number: 9309
Today's topics:
Assign reference to hash returned from a function <hobosalesman@gmail.com>
Re: Assign reference to hash returned from a function <noreply@gunnar.cc>
Re: Assign reference to hash returned from a function xhoster@gmail.com
Re: Assign reference to hash returned from a function <hobosalesman@gmail.com>
Re: Assign reference to hash returned from a function <tadmc@augustmail.com>
Re: Assign reference to hash returned from a function <noreply@gunnar.cc>
Re: Assign reference to hash returned from a function <someone@example.com>
Re: Assign reference to hash returned from a function <hobosalesman@gmail.com>
Re: Assign reference to hash returned from a function <hobosalesman@gmail.com>
Re: Binding array to pattern <tadmc@augustmail.com>
File::Find - passing argument to &wanted <hobosalesman@gmail.com>
Re: File::Find - passing argument to &wanted <john@castleamber.com>
Re: File::Find - passing argument to &wanted <hobosalesman@gmail.com>
Re: File::Find - passing argument to &wanted <mumia.w.18.spam+nospam.usenet@earthlink.net>
Re: File::Find - passing argument to &wanted <uri@stemsystems.com>
Re: Flat file missing <tadmc@augustmail.com>
new CPAN modules on Sat Jun 17 2006 (Randal Schwartz)
Perl - MultiUser Webserver Environment Help lunardragoon@gmail.com
Re: Perl Web Developer Wanted! <tadmc@augustmail.com>
Re: reference to object method <hobosalesman@gmail.com>
Re: What is Expressiveness in a Computer Language <jo@durchholz.org>
Re: What is Expressiveness in a Computer Language <raffaelcavallaro@pas-d'espam-s'il-vous-plait-mac.com>
windows mozilla perl helper app scripts <no_one@nowhere.net>
Re: windows mozilla perl helper app scripts <mumia.w.18.spam+nospam.usenet@earthlink.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 16 Jun 2006 15:42:24 -0700
From: "Hobo Salesman" <hobosalesman@gmail.com>
Subject: Assign reference to hash returned from a function
Message-Id: <1150497744.647211.54750@h76g2000cwa.googlegroups.com>
I'm using Config::General, the getall method returns a hash. I want to
store this hash in a reference, and I'm curious about what exactly is
going on and couldn't find clarification reading docs.
#This assigns '6/8'... why do I get a string like that when assigning a
hash to a scalar?
$conf = $confGen->getall;
#This seems to make a code reference that contains a hash...?
$conf = \($confGen->getall);
#This assigns a ref to an empty hash
$conf = \%{$confGen->getall};
#This is a little ugly
my %conf = $confGen->getall;
$conf = \%conf;
undef %conf;
Please shed some light on this for me!
HS
------------------------------
Date: Sat, 17 Jun 2006 01:00:20 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Assign reference to hash returned from a function
Message-Id: <4fgrcdF1hp00mU1@individual.net>
Hobo Salesman wrote:
> I'm using Config::General, the getall method returns a hash. I want to
> store this hash in a reference, and I'm curious about what exactly is
> going on and couldn't find clarification reading docs.
>
> #This assigns '6/8'... why do I get a string like that when assigning a
> hash to a scalar?
> $conf = $confGen->getall;
Because that's what you get when evaluating a hash in scalar context.
Try this:
my $conf = { $confGen->getall };
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 16 Jun 2006 23:05:38 GMT
From: xhoster@gmail.com
Subject: Re: Assign reference to hash returned from a function
Message-Id: <20060616190606.860$Qx@newsreader.com>
"Hobo Salesman" <hobosalesman@gmail.com> wrote:
> I'm using Config::General, the getall method returns a hash.
Apparently it returns whatever a hash evaluates to in the context
in which getall is called. In neither case is that a hash, it is either
a string, or a flattened list of alternating key-value pairs.
> I want to
> store this hash in a reference, and I'm curious about what exactly is
> going on and couldn't find clarification reading docs.
>
> #This assigns '6/8'... why do I get a string like that when assigning a
> hash to a scalar?
> $conf = $confGen->getall;
from perldata:
If you evaluate a hash in scalar context, it returns false
if the hash is empty. If there are any key/value pairs,
it returns true; more precisely, the value returned is a
string consisting of the number of used buckets and the
number of allocated buckets, separated by a slash.
So you now know that the hash inside the function had 8 buckets, of
which 6 were occupied.
You need to use the construct which one uses to make a hashref out of
a list of key value pairs. That is the curlies:
$conf = {$confGen->getall}
> #This seems to make a code reference that contains a hash...?
> $conf = \($confGen->getall);
>
> #This assigns a ref to an empty hash
> $conf = \%{$confGen->getall};
You probably aren't using strict. Shame on you.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 16 Jun 2006 16:24:25 -0700
From: "Hobo Salesman" <hobosalesman@gmail.com>
Subject: Re: Assign reference to hash returned from a function
Message-Id: <1150498860.341406.19190@i40g2000cwc.googlegroups.com>
Gunnar Hjalmarsson wrote:
> Because that's what you get when evaluating a hash in scalar context.
Do the numbers mean something or have some purpose? First one seems
like it could be the number of elements?
> Try this:
>
> my $conf = { $confGen->getall };
Thanks.
------------------------------
Date: Fri, 16 Jun 2006 18:23:45 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Assign reference to hash returned from a function
Message-Id: <slrne96fc0.7ts.tadmc@magna.augustmail.com>
Hobo Salesman <hobosalesman@gmail.com> wrote:
> I'm using Config::General, the getall method returns a hash.
That is not possible in Perl.
The getall method returns a *list* (as do all Perl subroutines).
> I want to
> store this hash in a reference,
You don't have access to the hash, only to a list (derived from
the hash).
You can _copy_ the list into a hash reference by using the
anonymous hash constructor (curly braces):
$conf = { $confGen->getall };
> and I'm curious about what exactly is
> going on and couldn't find clarification reading docs.
>
> #This assigns '6/8'... why do I get a string like that when assigning a
> hash to a scalar?
> $conf = $confGen->getall;
Because that is what a hash in scalar context is supposed to do.
A hash used in a scalar context returns info that is not
generally useful to a Perl programmer (you), it is only useful to a
perl programmer (who are actually C programmers, the p5p).
It returns info about the underlying hashing that is builtin to perl.
From the "Scalar values" section in perldata.pod:
"the number of used buckets and the number of allocated buckets,
separated by a slash."
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 17 Jun 2006 02:27:55 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Assign reference to hash returned from a function
Message-Id: <4fh0gkF1itf86U1@individual.net>
Tad McClellan wrote:
> Hobo Salesman <hobosalesman@gmail.com> wrote:
>>I'm using Config::General, the getall method returns a hash.
>
> That is not possible in Perl.
>
> The getall method returns a *list* (as do all Perl subroutines).
C:\home>type test.pl
sub rethash { my %hash = (one => 1, two => 2); %hash }
print scalar rethash(), "\n";
C:\home>perl test.pl
2/8
C:\home>
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sat, 17 Jun 2006 03:43:33 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Assign reference to hash returned from a function
Message-Id: <FTKkg.64836$S61.50108@edtnps90>
Gunnar Hjalmarsson wrote:
> Tad McClellan wrote:
>> Hobo Salesman <hobosalesman@gmail.com> wrote:
>>> I'm using Config::General, the getall method returns a hash.
>>
>> That is not possible in Perl.
>>
>> The getall method returns a *list* (as do all Perl subroutines).
>
> C:\home>type test.pl
> sub rethash { my %hash = (one => 1, two => 2); %hash }
> print scalar rethash(), "\n";
>
> C:\home>perl test.pl
> 2/8
>
> C:\home>
That is still returning a list, a list with one element, but a list nonetheless.
John
--
use Perl;
program
fulfillment
------------------------------
Date: 16 Jun 2006 21:59:09 -0700
From: "Hobo Salesman" <hobosalesman@gmail.com>
Subject: Re: Assign reference to hash returned from a function
Message-Id: <1150520349.592052.153200@h76g2000cwa.googlegroups.com>
xhoster@gmail.com wrote:
> You probably aren't using strict. Shame on you.
Actually I am using strict, and going to lengths to use proper OOP
techniques too, but I think maybe while testing stuff out interactively
in teh debugger 'use strict' wasn't in place.
------------------------------
Date: 16 Jun 2006 22:01:02 -0700
From: "Hobo Salesman" <hobosalesman@gmail.com>
Subject: Re: Assign reference to hash returned from a function
Message-Id: <1150520462.799358.104740@y41g2000cwy.googlegroups.com>
Tad McClellan wrote:
> You don't have access to the hash, only to a list (derived from
> the hash).
Sorry, I meant that it returns what's meant to be interpreted as a
hash. I'll try to be a little clearer in any future posts.
------------------------------
Date: Fri, 16 Jun 2006 17:07:22 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Binding array to pattern
Message-Id: <slrne96asq.7n8.tadmc@magna.augustmail.com>
Shmuel (Seymour J.) Metz <spamtrap@library.lspace.org.invalid> wrote:
> In <slrne937sq.3uc.tadmc@magna.augustmail.com>, on 06/15/2006
> at 12:57 PM, Tad McClellan <tadmc@augustmail.com> said:
>
>>You flipped the lines from what you posted before,
>
> I edited the text of the article instead of clipping from my code,
Yes, I could tell.
Please follow the posting guidelines to avoid launching such
red herrings in the future.
> my $scalarContacts="@{$email_contact}";
> push @abuseContacts, @{$email_contact}
> if (/abuse/ or $scalarContacts =~ /abuse/);
>
>> if grep /abuse/, $_, @$emails;
>
> How is that better than scanning the derived scalar?
1) you don't have do the deriving of any scalar (save a few cycles,
both in silicon and in grey matter)
2) it is not vulnerable to the bug that I pointed out earlier
(That would be reason enough for me to not get used to doing
it that way. Inserting bugs is bad.)
3) you don't end up having the regex engine compile the same
regex multiple times (save more than a few cycles)
When I suggested using grep() in my very first followup, you
dismissed it because it would "complicate the logic".
push @abuseContacts, @{$email_contact}
if grep /abuse/, $_, @{$email_contact};
Those 2 lines are less complicated than your 3 lines quoted above.
Using grep() in this situation *simplifies* the logic (and avoids
the potential bug).
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 16 Jun 2006 22:12:36 -0700
From: "Hobo Salesman" <hobosalesman@gmail.com>
Subject: File::Find - passing argument to &wanted
Message-Id: <1150521156.068791.322190@g10g2000cwb.googlegroups.com>
Quoted from File::Find POD:
> use File::Find;
> find(\&wanted, @directories_to_search);
> The wanted function takes no arguments but rather does its work through a collection of variables.
"processFile()" is "The wanted function". Some code from my program:
find( {
wanted => \&processFile,
preprocess => \&processDirectory,
no_chdir => 1,
}, $self->{"rootPath"});
I have what's above in a "site" object, and I want to pass that object
to processFile(), which is called by File::Find. "processFile()" needs
to create a "file" object that has to know a few things from the "site"
object, most importantly which site it's part of. I'm a little stumped
as to the best way to make that data accessable to the file object.
This doesn't work:
wanted => \&processFile($self->{"siteName"}),
Or rather, it does pass the data I need, but in the process it makes
the data File::Find provides ($File::Find::name, etc) innaccesable. Any
suggestions would be appreciated. Thanks,
HS
------------------------------
Date: 17 Jun 2006 05:50:08 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: File::Find - passing argument to &wanted
Message-Id: <Xns97E587EE4B99castleamber@130.133.1.4>
"Hobo Salesman" <hobosalesman@gmail.com> wrote:
> wanted => \&processFile($self->{"siteName"}),
>
> Or rather, it does pass the data I need, but in the process it makes
> the data File::Find provides ($File::Find::name, etc) innaccesable.
> Any suggestions would be appreciated. Thanks,
closure?
wanted => sub { processFile( $self->{ siteName } },
(btw: processFile is quite uncommon in Perl (camel case), you probably
will see: process_file more often).
--
John Bokma Freelance software developer
&
Experienced Perl programmer: http://castleamber.com/
------------------------------
Date: 16 Jun 2006 23:25:04 -0700
From: "Hobo Salesman" <hobosalesman@gmail.com>
Subject: Re: File::Find - passing argument to &wanted
Message-Id: <1150525504.529293.229920@h76g2000cwa.googlegroups.com>
John Bokma wrote:
> closure?
>
> wanted => sub { processFile( $self->{ siteName } },
Thank ya, 'closure' is a new concept to me, after some googling I feel
like a better programmer.
> (btw: processFile is quite uncommon in Perl (camel case), you probably
> will see: process_file more often).
I tried forcing myself to use that convention but because of my
background with actionscript/lingo I'd find odd variableNames sneaking
in and ruining everything, now I admit defeat and use it all the time.
Besides that I plan on concentrating more on PHP in the future, a
language for which naming conventions are apparently completely unheard
of... I can't imagine what happened in the development of that language
that caused them to choose function names like that.
------------------------------
Date: Sat, 17 Jun 2006 06:43:22 GMT
From: "Mumia W." <mumia.w.18.spam+nospam.usenet@earthlink.net>
Subject: Re: File::Find - passing argument to &wanted
Message-Id: <ewNkg.6866$lf4.6832@newsread1.news.pas.earthlink.net>
Hobo Salesman wrote:
> [...]
>
> find( {
> wanted => \&processFile,
> preprocess => \&processDirectory,
> no_chdir => 1,
> }, $self->{"rootPath"});
>
> I have what's above in a "site" object, and I want to pass that object
> to processFile(), [...]
Use a localized package variable.
You could also use a closure: perldoc -q closure.
------------------------------
Date: Sat, 17 Jun 2006 02:59:34 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: File::Find - passing argument to &wanted
Message-Id: <x7u06kqnc9.fsf@mail.sysarch.com>
>>>>> "HS" == Hobo Salesman <hobosalesman@gmail.com> writes:
HS> Besides that I plan on concentrating more on PHP in the future, a
HS> language for which naming conventions are apparently completely
HS> unheard of... I can't imagine what happened in the development of
HS> that language that caused them to choose function names like that.
it is called inbreeding. php was first written in perl but the
designers have/had no experience in language development and they all
just poured in their genes into a bucket and watched what
devolved. every recessive and degenerate trait was expressed in the
phenotype. think of the british royals developing a web language. sorry
for the imagery.
perl is so good because it had one designer and his background was
lingustics and computers which make for a solid background for a
computer language designer.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Fri, 16 Jun 2006 17:13:55 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Flat file missing
Message-Id: <slrne96b93.7n8.tadmc@magna.augustmail.com>
asg <ahqmed@hotmail.com> wrote:
> open(COUNT,"$counterFile");
open(COUNT, $counterFile) or die "could not open '$counterFile' $!";
> print (COUNT "$ergsege");
print (COUNT $ergsege);
See:
perldoc -q vars
What's wrong with always quoting "$vars"?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 17 Jun 2006 04:42:06 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sat Jun 17 2006
Message-Id: <J0zME6.1qyq@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
Bio-DasLite-1.38
http://search.cpan.org/~rpettett/Bio-DasLite-1.38/
Perl extension for the DAS (HTTP+XML) Protocol (http://biodas.org/)
----
CGI-Application-Plugin-Authorization-0.05
http://search.cpan.org/~ceeshek/CGI-Application-Plugin-Authorization-0.05/
Authorization framework for CGI::Application
----
Data-Constraint-1.06
http://search.cpan.org/~bdfoy/Data-Constraint-1.06/
prototypical value checking
----
Email-Valid-0.173
http://search.cpan.org/~rjbs/Email-Valid-0.173/
Check validity of Internet email addresses
----
FEAR-API-0.487.6
http://search.cpan.org/~xern/FEAR-API-0.487.6/
Web Scraping Zen
----
File-Append-TempFile-0.04
http://search.cpan.org/~roam/File-Append-TempFile-0.04/
Perl extension for appending data to files
----
Image-Imlib2-1.09
http://search.cpan.org/~lbrocard/Image-Imlib2-1.09/
Interface to the Imlib2 image library
----
Java-JCR-0.04
http://search.cpan.org/~hanenkamp/Java-JCR-0.04/
Use JSR 170 (JCR) repositories from Perl
----
Jifty-0.60616
http://search.cpan.org/~jesse/Jifty-0.60616/
an application framework
----
Net-IPMessenger-0.01
http://search.cpan.org/~masanorih/Net-IPMessenger-0.01/
Interface to the IP Messenger Protocol
----
Net-IPMessenger-0.02
http://search.cpan.org/~masanorih/Net-IPMessenger-0.02/
Interface to the IP Messenger Protocol
----
PDF-API2-Simple-1.0.2
http://search.cpan.org/~redtree/PDF-API2-Simple-1.0.2/
Simplistic wrapper for the excellent PDF::API2 modules
----
PDF-API2-Simple-1.0.3
http://search.cpan.org/~redtree/PDF-API2-Simple-1.0.3/
Simplistic wrapper for the excellent PDF::API2 modules
----
POE-0.3502
http://search.cpan.org/~rcaputo/POE-0.3502/
portable multitasking and networking framework for Perl
----
POE-Component-SNMP-1.05
http://search.cpan.org/~rdb/POE-Component-SNMP-1.05/
POE interface to Net::SNMP
----
POE-Wheel-UDP-0.01
http://search.cpan.org/~hachi/POE-Wheel-UDP-0.01/
POE Wheel for UDP handling.
----
Petal-2.19
http://search.cpan.org/~bpostle/Petal-2.19/
Perl Template Attribute Language - TAL for Perl!
----
RDF-Helper-0.21
http://search.cpan.org/~khampton/RDF-Helper-0.21/
Perl extension for blah blah blah
----
Regexp-Compare-0.05
http://search.cpan.org/~vbar/Regexp-Compare-0.05/
partial ordering for regular expressions
----
SVN-Notify-2.60
http://search.cpan.org/~dwheeler/SVN-Notify-2.60/
Subversion activity notification
----
Template-Iterator-AlzaboWrapperCursor-0.01
http://search.cpan.org/~drolsky/Template-Iterator-AlzaboWrapperCursor-0.01/
Turns a Class::AlzaboWrapper::Cursor object into a TT2 iterator
----
Template-Plugin-XML-Escape-0.02
http://search.cpan.org/~tjc/Template-Plugin-XML-Escape-0.02/
Escape variables to suit being placed into XML
----
Test-Base-0.51
http://search.cpan.org/~ingy/Test-Base-0.51/
A Data Driven Testing Framework
----
Test-C2FIT-0.07
http://search.cpan.org/~tjbyrne/Test-C2FIT-0.07/
A direct Perl port of Ward Cunningham's FIT acceptance test framework for Java.
----
WWW-Myspace-0.48
http://search.cpan.org/~grantg/WWW-Myspace-0.48/
Access MySpace.com profile information from Perl
----
WebService-FreeDB-0.76
http://search.cpan.org/~hmersch/WebService-FreeDB-0.76/
retrieving entries from FreeDB by searching for keywords (artist,track,album,rest)
----
Win32-IEFavorites-0.03
http://search.cpan.org/~ishigaki/Win32-IEFavorites-0.03/
handles Internet Explorer's Favorites
----
XML-DOM-Lite-0.09
http://search.cpan.org/~rhundt/XML-DOM-Lite-0.09/
Lite Pure Perl XML DOM Parser Kit
----
XML-FeedLite-1.3
http://search.cpan.org/~rpettett/XML-FeedLite-1.3/
Perl extension for fetching Atom and RSS feeds with minimal outlay
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
print "Just another Perl hacker," # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 16 Jun 2006 18:34:23 -0700
From: lunardragoon@gmail.com
Subject: Perl - MultiUser Webserver Environment Help
Message-Id: <1150508063.446308.32140@c74g2000cwc.googlegroups.com>
:\ My appologies. I thought that this may be a Perl centered problem,
but I guess not >.> Thanks for pointing me in the right direction ^.^
Sorry for the problem I caused in this group.
-Travis Duncan
------------------------------
Date: Fri, 16 Jun 2006 16:19:07 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Perl Web Developer Wanted!
Message-Id: <slrne9682b.7n8.tadmc@magna.augustmail.com>
Uri Guttman <uri@stemsystems.com> wrote:
>>>>>> "TM" == Tad McClellan <tadmc@augustmail.com> writes:
>
> TM> Mirco Wahab <peace.is.our.profession@gmx.de> wrote:
> >> Thus spoke Randal L. Schwartz (on 2006-06-16 04:49):
> >>
> >>> ... Do you want to work for an idiot? ...
> >>
> >> Isn't this what almost all people do almost every day ;-)
>
> TM> _I_ do not work for an idiot. [1]
>
> in russia, the idiot works for you! :)
>
> TM> [1] Shameless kissing up, since my boss reads this newsgroup. :-) :-)
>
> be careful of who you kiss! :)
s/who/what/;
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 16 Jun 2006 22:18:41 -0700
From: "Hobo Salesman" <hobosalesman@gmail.com>
Subject: Re: reference to object method
Message-Id: <1150521521.206092.289480@p79g2000cwp.googlegroups.com>
Uri Guttman wrote:
> yeah, the OP's original issue is long lost in my skull. and i bet he
> isn't reading this thread anymore!
Actually I am, but lurking. I don't think my skills are the level of a
lot of people here and I'm still getting familiar with the group so I'm
doing more reading than posting.
------------------------------
Date: Sat, 17 Jun 2006 00:09:26 +0200
From: Joachim Durchholz <jo@durchholz.org>
Subject: Re: What is Expressiveness in a Computer Language
Message-Id: <e6va6a$ql0$1@online.de>
Darren New schrieb:
> Joachim Durchholz wrote:
>> Give a heterogenous list that would to too awkward to live in a
>> statically-typed language.
>
> Write a function that takes an arbitrary set of arguments and stores
> them into a structure allocated on the heap.
If the set of arguments is really arbitrary, then the software can't do
anything with it. In that case, the type is simply "opaque data block",
and storing it in the heap requires nothing more specific than that of
"opaque data block".
There's more in this. If we see a function with a parameter type of
"opaque data block", and there's no function available except copying
that data and comparing it for equality, then from simply looking at the
function's signature, we'll know that it won't inspect the data. More
interestingly, we'll know that funny stuff in the data might trigger
bugs in the code - in the context of a security audit, that's actually a
pretty strong guarantee, since the analysis can stop at the function't
interface and doesn't have to dig into the function's implementation.
>> Give a case of calling nonexistent functions that's useful.
>
> See the Tcl "unknown" proc, used for interactive command expansion,
> dynamic loading of code on demand, etc.
Not related to dynamic typing, I fear - I can easily envision
alternatives to that in a statically-typed context.
Of course, you can't eliminate *all* run-time type checking. I already
mentioned unmarshalling data from an untyped source; another possibility
is run-time code compilation (highly dubious in a production system but
of value in a development system).
However, that's some very specialized applications, easily catered for
by doing a dynamic type check plus a thrown exception in case the types
don't match. I still don't see a convincing argument for making dynamic
typing the standard policy.
Regards,
Jo
------------------------------
Date: Fri, 16 Jun 2006 18:25:09 -0400
From: Raffael Cavallaro <raffaelcavallaro@pas-d'espam-s'il-vous-plait-mac.com>
Subject: Re: What is Expressiveness in a Computer Language
Message-Id: <2006061618250975249-raffaelcavallaro@pasdespamsilvousplaitmaccom>
On 2006-06-16 17:59:07 -0400, Joachim Durchholz <jo@durchholz.org> said:
> I think it's easier to start with a good (!) statically-typed language
> and relax the checking, than to start with a dynamically-typed one and
> add static checks.
> With the right restrictions, a language can make all kinds of strong
> guarantees, and it can make it easy to construct software where static
> guarantees abound. If the mechanisms are cleverly chosen, they
> interfere just minimally with the programming process. (A classical
> example it Hindley-Milner type inference systems. Typical reports from
> languages with HM systems say that you can have it verify thousand-line
> programs without a single type annotation in the code. That's actually
> far better than you'd need - you'd *want* to document the types at
> least on the major internal interfaces after all *grin*.)
> With a dynamically-typed language, programming style tends to evolve in
> directions that make it harder to give static guarantees.
This is purely a matter of programming style. For explorative
programming it is easier to start with dynamic typing and add static
guarantees later rather than having to make decisions about
representation and have stubs for everything right from the start. The
lisp programming style is arguably all about using heterogenous lists
and forward references in the repl for everything until you know what
it is that you are doing, then choosing a more appropriate
representation and filling in forward references once the program gels.
Having to choose representation right from the start and needing
working versions (even if only stubs) of *every* function you call may
ensure type correctness, but many programmers find that it also ensures
that you never find the right program to code in the first place. This
is because you don't have the freedom to explore possible solutions
without having to break your concentration to satisfy the nagging of a
static type checker.
------------------------------
Date: Sat, 17 Jun 2006 02:00:21 GMT
From: Philip <no_one@nowhere.net>
Subject: windows mozilla perl helper app scripts
Message-Id: <VmJkg.98093$H71.58617@newssvr13.news.prodigy.com>
I was trying to get a perl based helper app to work with a mozilla
browser on windows.
I have installed activeperl on my XP PC and I can run the helper script
from the MS-DOS window. ie
helper.pl download_file.suffix.
I then set helper.pl as the helper app for a my chosen file type within
the browser preference set up dialog. However, when I try to handle the
download through the browser I get the following error dialog:
"<temporary download.suffix file> could not be opened because an unknown
error occurred.
Sorry about that, try saving to disk first and then opening the file"
I suspect that it is because windows perl scripts are not executed and
handed arguments as transparently as real executable helper apps.
Is there a way around this problem? Have I incorrectly set up perl?
------------------------------
Date: Sat, 17 Jun 2006 06:16:41 GMT
From: "Mumia W." <mumia.w.18.spam+nospam.usenet@earthlink.net>
Subject: Re: windows mozilla perl helper app scripts
Message-Id: <d7Nkg.13954$921.48@newsread4.news.pas.earthlink.net>
Philip wrote:
> I was trying to get a perl based helper app to work with a mozilla
> browser on windows.
>
> I have installed activeperl on my XP PC and I can run the helper script
> from the MS-DOS window. ie
>
> helper.pl download_file.suffix.
>
> I then set helper.pl as the helper app for a my chosen file type within
> the browser preference set up dialog. However, when I try to handle the
> download through the browser I get the following error dialog:
>
> "<temporary download.suffix file> could not be opened because an unknown
> error occurred.
>
> Sorry about that, try saving to disk first and then opening the file"
>
> I suspect that it is because windows perl scripts are not executed and
> handed arguments as transparently as real executable helper apps.
>
> Is there a way around this problem? Have I incorrectly set up perl?
Perhaps you could create a batch file (.BAT) that would invoke perl like so:
c:\path\to\perl.exe helper.pl download_file.suffix
------------------------------
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 9309
***************************************