[27964] in Perl-Users-Digest
Perl-Users Digest, Issue: 9328 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 20 21:05:35 2006
Date: Tue, 20 Jun 2006 18:05:05 -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 Tue, 20 Jun 2006 Volume: 10 Number: 9328
Today's topics:
Re: asyncrhronous system call <David.Squire@no.spam.from.here.au>
Re: asyncrhronous system call <tadmc@augustmail.com>
Re: File::Find - passing argument to &wanted <David.Squire@no.spam.from.here.au>
Re: Find repeating substring <David.Squire@no.spam.from.here.au>
How to select subroutine <janfure@gmail.com>
Re: How to select subroutine <benmorrow@tiscali.co.uk>
Re: How to select subroutine <janfure@gmail.com>
Re: How to select subroutine <hoosier45678@hotmail.com>
Re: How to select subroutine <simon.chao@gmail.com>
Re: How to select subroutine <tadmc@augustmail.com>
Re: How to select subroutine <tadmc@augustmail.com>
Re: How to select subroutine <tadmc@augustmail.com>
Looping through Class::Accessor accessors <dbasch@yahoo.com>
Re: noob asks: differences Activestate 5.8.x vs 5.6.x. noob@public.com
Re: noob asks: differences Activestate 5.8.x vs 5.6.x. <kevin@vaildc.net>
Re: problem in calling program in my perl script <David.Squire@no.spam.from.here.au>
Re: Spreadsheet::ParseExcel to find out if there is a S <jgibson@mail.arc.nasa.gov>
Re: What am I missing in perlre janfure@gmail.com
Re: What is Expressiveness in a Computer Language <jo@durchholz.org>
Re: What is Expressiveness in a Computer Language <jo@durchholz.org>
Re: What is Expressiveness in a Computer Language <jo@durchholz.org>
Re: What is Expressiveness in a Computer Language <find@my.address.elsewhere>
Re: What's ^$ mean? <tadmc@augustmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 20 Jun 2006 23:46:00 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: asyncrhronous system call
Message-Id: <e79tr8$e4m$3@news.ox.ac.uk>
Spin wrote:
> What I need to do is partway between the functionality of system and
> exec. My understanding of system() is that it runs the process and waits
> for completion before continuing the script. Also as I understand it
> exec() runs the process but abandons the script
Are you talking about perl? That's not what perl exec does. RTFM.
DS
------------------------------
Date: Tue, 20 Jun 2006 19:03:42 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: asyncrhronous system call
Message-Id: <slrne9h36u.qfm.tadmc@magna.augustmail.com>
David Squire <David.Squire@no.spam.from.here.au> wrote:
> Spin wrote:
>> as I understand it
>> exec() runs the process but abandons the script
>
> Are you talking about perl? That's not what perl exec does.
Yes it is.
>RTFM.
What part of what manual led you to say what you said?
I've said this to you before:
RTFM is less than helpful when it does not come with which FM to read.
but I guess it needs saying yet again...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 20 Jun 2006 23:48:12 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: File::Find - passing argument to &wanted
Message-Id: <e79tvc$e4m$4@news.ox.ac.uk>
Ted Zlatanov wrote:
[snip]
>
> This and other things you said are pretty unfair. I know Perl, I've
> used PHP, and they do different things well. Disdain for an entire
> community (PHP or others) is not productive. Emacs Lisp doesn't have
> namespaces, does that make it a kiddie language? Assembler doesn't
> have <insert feature here>, does that make it primitive?
Yes. Almost by definition.
That's not to say that there aren't times when it's the right choice.
But it's primative as F**K.
DS
------------------------------
Date: Tue, 20 Jun 2006 23:42:23 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: Find repeating substring
Message-Id: <e79tkf$e4m$2@news.ox.ac.uk>
Mike wrote:
[big snip]
>
> Sorry. My mistake. I ran the Perl script with your suggestion and no
> 37.33/2 (as you noted). As I am trying to also see if this will work
> in C# code (on demand) I ran it on Expresso as ^(.*).*\1 against the
> same string and it left the code. Different implementation? I only
> use regular expressions irregularly and so am merely dangerous with
> them.
What makes you think that REs in one language will function like those
in another? [1]
DS
[1] Deliberatively provocative.
------------------------------
Date: 20 Jun 2006 15:32:46 -0700
From: "Jan Fure" <janfure@gmail.com>
Subject: How to select subroutine
Message-Id: <1150842766.890956.70390@u72g2000cwu.googlegroups.com>
Hi;
I need to be able to select which subroutine to process a string with
based on the contents of the string.
I have written a code example of this, that uses a lookup table.
Is there a sensible way to do this without the lookup table, i.e., can
I let the parsed string value be the subroutine name?
Jan
#!/usr/local/bin/perl -w
use strict;
my @DATA = <DATA>;
foreach (@DATA) {
chomp;
my @ARGUMENTS = split / /;
my $output = subselect(@ARGUMENTS);
print "The chained output of 2 subroutines is $output\n";
}
sub subselect {
if ($_[0] eq 'sr2') {
my $return_value = sr2(@_);
return $return_value;
}
if ($_[0] eq 'sr3') {
my $return_value = sr3(@_);
return $return_value;
}
}
sub sr2 {
my $x2 = $_[1] ** 2;
return $x2;
}
sub sr3 {
my $x3 = $_[1] ** 3;
return $x3;
}
__DATA__
sr2 3.456
sr3 2
sr2 45
------------------------------
Date: Wed, 21 Jun 2006 00:22:23 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: How to select subroutine
Message-Id: <ficmm3-qds.ln1@osiris.mauzo.dyndns.org>
Quoth "Jan Fure" <janfure@gmail.com>:
>
> I need to be able to select which subroutine to process a string with
> based on the contents of the string.
>
> I have written a code example of this, that uses a lookup table.
>
> Is there a sensible way to do this without the lookup table, i.e., can
> I let the parsed string value be the subroutine name?
Yes, but it would be a bad idea. A better answer would be to use a
proper lookup table (in Perl, a hash).
>
> #!/usr/local/bin/perl -w
use warnings;
is the modern version on -w.
> use strict;
>
> my @DATA = <DATA>;
> foreach (@DATA) {
If you want the data line-by-line, then read it line-by line.
> chomp;
> my @ARGUMENTS = split / /;
> my $output = subselect(@ARGUMENTS);
> print "The chained output of 2 subroutines is $output\n";
> }
>
> sub subselect {
> if ($_[0] eq 'sr2') {
> my $return_value = sr2(@_);
> return $return_value;
> }
> if ($_[0] eq 'sr3') {
> my $return_value = sr3(@_);
> return $return_value;
> }
> }
>
> sub sr2 {
> my $x2 = $_[1] ** 2;
> return $x2;
> }
>
> sub sr3 {
> my $x3 = $_[1] ** 3;
> return $x3;
> }
>
> __DATA__
> sr2 3.456
> sr3 2
> sr2 45
I would do this like (untested):
my %dispatch = (
sr2 => sub { $_[1] ** 2 },
sr3 => sub { $_[1] ** 3 },
);
local $\ = "\n"; # saves printing them all the time
while (<DATA>) {
my @args = split; # this doesn't quite do what you did before,
# but it's likely more flexible and more use.
# And you don't need the chomp.
my $output = $dispatch{$args[0]}->(@args);
print "the output of a sub in a dispatch table is $output";
}
__DATA__
sr2 3.456
sr3 2
sr2 45
I presume 'sr2' and 'sr3' are just examples? If not, I'd extract the '2'
and use it as a parameter rather than writing two separate subs.
Ben
--
The Earth is degenerating these days. Bribery and corruption abound.
Children no longer mind their parents, every man wants to write a book,
and it is evident that the end of the world is fast approaching.
Assyrian stone tablet, c.2800 BC benmorrow@tiscali.co.uk
------------------------------
Date: 20 Jun 2006 17:03:32 -0700
From: "Jan Fure" <janfure@gmail.com>
Subject: Re: How to select subroutine
Message-Id: <1150848212.628732.132580@i40g2000cwc.googlegroups.com>
Ben Morrow wrote:
> Yes, but it would be a bad idea. A better answer would be to use a
> proper lookup table (in Perl, a hash).
>
>
> I would do this like (untested):
>
> my %dispatch = (
> sr2 => sub { $_[1] ** 2 },
> sr3 => sub { $_[1] ** 3 },
> );
>
> Ben
>
Thanks for replying!
If I understand you right, you are proposing a hash, with keys from my
data, and anonymous subroutines linked to the keys.
For my actual code, this would be quite ugly, as the subroutines are
20+ lines of code.
This was just the shortest code I could come up with, that illustrated
the constraints:
1. Sub routine aquired from data.
2. Ability to pass output to the original function/subroutne call.
I also need the program to exit with appropriate error message, if
there is no match between existing subroutine and requested subroutine,
but I omitted that from the example code to keep it from getting too
long.
Could you elaborate on why it is a bad idea to let the subroutine name
be contained in the data?
Is there a way to improve the structure of the code I wrote, while
keeping the subroutines around? In my production code, I expect there
might be 15+ different sub routines.
Jan
------------------------------
Date: Tue, 20 Jun 2006 19:17:00 -0500
From: James <hoosier45678@hotmail.com>
Subject: Re: How to select subroutine
Message-Id: <pan.2006.06.21.00.16.55.12165@hotmail.com>
On Tue, 20 Jun 2006 17:03:32 -0700, Jan Fure wrote:
> If I understand you right, you are proposing a hash, with keys from my
> data, and anonymous subroutines linked to the keys.
>
> For my actual code, this would be quite ugly, as the subroutines are
>> 20+
> lines of code.
>
they don't have to be anonymous, per se.
%handlers = (
sr2 => \&sr2,
sr3 => \&sr3,
);
while(<DATA>)
{
chomp;
my ($function, @ARGUMENTS) = split / /;
die "No handler for $function" unless defined $handler{$function};
my $output = handler{$function}->(@ARGUMENTS);
print "The chained output of 2 subroutines is $output\n";
}
sub sr2
{
$_[0] ** 2;
}
> This was just the shortest code I could come up with, that illustrated
> the constraints:
> 1. Sub routine aquired from data.
> 2. Ability to pass output to the original function/subroutne call. I
> also need the program to exit with appropriate error message, if there
> is no match between existing subroutine and requested subroutine, but I
> omitted that from the example code to keep it from getting too long.
>
> Could you elaborate on why it is a bad idea to let the subroutine name
> be contained in the data?
depends on the source of the data, but perldoc -f eval
------------------------------
Date: 20 Jun 2006 17:36:09 -0700
From: "it_says_BALLS_on_your_forehead" <simon.chao@gmail.com>
Subject: Re: How to select subroutine
Message-Id: <1150850169.401198.280300@i40g2000cwc.googlegroups.com>
Jan Fure wrote:
> Ben Morrow wrote:
> > Yes, but it would be a bad idea. A better answer would be to use a
> > proper lookup table (in Perl, a hash).
> >
> >
> > I would do this like (untested):
> >
> > my %dispatch = (
> > sr2 => sub { $_[1] ** 2 },
> > sr3 => sub { $_[1] ** 3 },
> > );
> >
> > Ben
> >
> Thanks for replying!
>
> If I understand you right, you are proposing a hash, with keys from my
> data, and anonymous subroutines linked to the keys.
>
> For my actual code, this would be quite ugly, as the subroutines are
> 20+ lines of code.
>
> This was just the shortest code I could come up with, that illustrated
> the constraints:
> 1. Sub routine aquired from data.
> 2. Ability to pass output to the original function/subroutne call.
> I also need the program to exit with appropriate error message, if
> there is no match between existing subroutine and requested subroutine,
> but I omitted that from the example code to keep it from getting too
> long.
this is called a dispatch table.
------------------------------
Date: Tue, 20 Jun 2006 19:35:08 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: How to select subroutine
Message-Id: <slrne9h51s.qfm.tadmc@magna.augustmail.com>
Jan Fure <janfure@gmail.com> wrote:
> I need to be able to select which subroutine to process a string with
> based on the contents of the string.
That is known in computer science as a "dispatch table".
> I have written a code example of this, that uses a lookup table.
>
> Is there a sensible way to do this without the lookup table,
No.
(but you can make a much nicer lookup table using a hash and coderefs.)
> i.e., can
> I let the parsed string value be the subroutine name?
Yes you can, but you don't want to.
That would be using Symbolic References, which should be avoided
when possible...
> #!/usr/local/bin/perl -w
> use strict;
... and use strict disallows using symrefs anyway.
> my @DATA = <DATA>;
> foreach (@DATA) {
Why read all of the lines when you are only going to process one
line at a time anyway?
while ( <DATA> ) {
> chomp;
> my @ARGUMENTS = split / /;
> my $output = subselect(@ARGUMENTS);
my %subs = ( sr2 => \&sr2, sr3 => \&sr3 ); # dispatch table
my $output = $subs{$ARGUMENTS[0]}->(@ARGUMENTS); # call the coderef
> sub subselect {
> if ($_[0] eq 'sr2') {
> my $return_value = sr2(@_);
And here we have the rare case where using an ampersand on a function
call _is_ what you want:
my $return_value = &sr2;
(but passing @_ explicitly is "better" IMO.)
> return $return_value;
> }
> if ($_[0] eq 'sr3') {
> my $return_value = sr3(@_);
> return $return_value;
> }
> }
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 20 Jun 2006 19:51:14 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: How to select subroutine
Message-Id: <slrne9h602.ql1.tadmc@magna.augustmail.com>
Jan Fure <janfure@gmail.com> wrote:
> Could you elaborate on why it is a bad idea to let the subroutine name
^^^^
> be contained in the data?
(because if a bad guy sprinkles the names of "bad" functions in
your data, you will happily execute it for him.
)
Your Question is Asked Frequently:
perldoc -q name
How can I use a variable as a variable name?
See also:
http://www.plover.com/~mjd/perl/varvarname.html
http://www.plover.com/~mjd/perl/varvarname2.html
http://www.plover.com/~mjd/perl/varvarname3.html
and:
http://perl.plover.com/FAQs/Namespaces.html
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 20 Jun 2006 19:54:49 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: How to select subroutine
Message-Id: <slrne9h66p.ql1.tadmc@magna.augustmail.com>
Jan Fure <janfure@gmail.com> wrote:
> I also need the program to exit with appropriate error message, if
> there is no match between existing subroutine and requested subroutine,
die "appropriate error message" unless exists $dispatch{$ARGUMENTS[0]};
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 20 Jun 2006 16:17:31 -0700
From: "Derek Basch" <dbasch@yahoo.com>
Subject: Looping through Class::Accessor accessors
Message-Id: <1150845451.282304.18990@y41g2000cwy.googlegroups.com>
Hi Everyone,
I began using Class::DBI and love it. However, there are situations
where I want to loop through the Class::Accessor accessors for an
object and also get the name of the accessor as I loop through.
For instance here is some psuedo-perl that I wrote to visualize what I
need:
# returns an array of objects
my @gpsaccounts = Database::Members::Gpsaccounts->search($user_id);
# loop through the array of objects
foreach my @row_class (@gpsaccounts) {
# loop through the objects accessors
foreach $class_accessor (@row_class) {
# print the accessors name and value
print "$class_accessor_name: $class_accessor_value\n"
}
}
Yes, I know that the above is syntactically unpossible but I don't know
how else to express it.
Here's how you would normally do it:
my @gpsaccounts =
Database::Members::Gpsaccounts->search_gpsaccounts($user_id);
foreach(@gpsaccounts) {
print $_->fullname . "\n";
print $_->user . "\n";
print $_->email . "\n";
print "------------------------" . "\n";
}
Any ideas? I am a newer Perl programmer so any help is appreciated.
Thanks,
Derek Basch
------------------------------
Date: Tue, 20 Jun 2006 15:39:24 -0700
From: noob@public.com
Subject: Re: noob asks: differences Activestate 5.8.x vs 5.6.x. pros vs cons of each?
Message-Id: <6utg92t02ie9hi1q0huj1ib1nrlg2q8d5i@4ax.com>
On Tue, 20 Jun 2006 21:58:29 +0200, "Peter J. Holzer"
<hjp-usenet2@hjp.at> wrote:
>
> Which is an excellent reason to upgrade to 5.8.x. Very few people will
> still test their modules with 5.6.x.
>
> However, on Windows you are probably better off using PPM instead of
> CPAN. Many CPAN modules need a C-compiler.
>
Thanx, I plan to update if I hear no serious reasons not to. If nmake
won't work, I'm reluctant to load a C-compiler just for a couple small
projects, and they need to be portable anyway. Getting a user
elsewhere to load & build that much isn't doable.
Is the reason that so few modules are available on PPM that they can't
be made to work on Windows, or just extreme lag-time?
------------------------------
Date: Tue, 20 Jun 2006 23:49:51 GMT
From: Kevin Michael Vail <kevin@vaildc.net>
Subject: Re: noob asks: differences Activestate 5.8.x vs 5.6.x. pros vs cons of each?
Message-Id: <kevin-CCA262.19495020062006@news.verizon.net>
In article <6utg92t02ie9hi1q0huj1ib1nrlg2q8d5i@4ax.com>,
noob@public.com wrote:
> Is the reason that so few modules are available on PPM that they can't
> be made to work on Windows, or just extreme lag-time?
Could be any number of reasons, and might depend on the module. But if
there is a particular module that you need, send an email to Activestate
and ask them to make it available. I've had to do this a couple of
times, and they were very quick to respond.
--
Bright eyes/burning like fire, | Kevin Michael Vail
Bright eyes/how can you close and fail? | kevin@vaildc.net
How can the light that shone so brightly | . . . . . . . . . .
Suddenly shine so pale?/Bright eyes | . . . . . . . . .
------------------------------
Date: Tue, 20 Jun 2006 23:38:36 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: problem in calling program in my perl script
Message-Id: <e79tdc$e4m$1@news.ox.ac.uk>
>>
>>
>>> exec ("p1.exe");
>> Does p1.exe even exist to execute?
> yes, it does exist. But it looks like not called by my perl program.
> Because I can't see welcome printed in my op.txt file. But if I run it
> in windows, it works good.
>
Your problem was already solved by an earlier poster. exec is not what
you think. RTFM.
DS
------------------------------
Date: Tue, 20 Jun 2006 16:02:06 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Spreadsheet::ParseExcel to find out if there is a Strikeout
Message-Id: <200620061602067732%jgibson@mail.arc.nasa.gov>
In article <1150830133.077687.34330@y41g2000cwy.googlegroups.com>,
Reshma <reshma.rr@gmail.com> wrote:
> I'm using Spreadsheet::ParseExcel to read an excel spreadsheet and
> generate an XML file out of it. I want to exclude the line items that
> are Struck out in the spreadsheet. Can some one tell me what would be
> the syntax for finding if a cell has "Strikeout"?
>
> Thanks for your help.
>
Have you read the documentation for Spreadsheet::ParseExcel?
Strikeout is a formatting attribute applied to the font assigned to the
cell. You have to fetch the format for the cell, fetch the font, then
see if the font has the Strikeout attribute set. Here is an example
(using version 0.2603):
#!/usr/local/bin/perl
use strict;
use warnings;
use Spreadsheet::ParseExcel;
my $file = 'xxx.xls';
my $wb = Spreadsheet::ParseExcel::Workbook->Parse($file);
my $sht = $wb->{Worksheet}[0];
for my $row ( 0..5 ) {
for my $col ( 0 .. 2 ) {
my $cell = $sht->Cell($row,$col);
if( $cell ) {
my $format = $cell->{Format};
my $font = $format->{Font};
my $val = $cell->Value() || '';
print "[$row][$col]: <$val> [",
$font->{Strikeout}, "]\n";
}
}
}
However, the documentation is confusing, using, as it does, the term
"properties" without explaining if that means a hash key or a method,
and referencing a "new interface". Trial and error may be required.
(Error checking is left as an exercise :)
--
Jim Gibson
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
------------------------------
Date: 20 Jun 2006 15:10:59 -0700
From: janfure@gmail.com
Subject: Re: What am I missing in perlre
Message-Id: <1150841459.352562.302060@p79g2000cwp.googlegroups.com>
Sherm Pendley wrote:
> m/[[:alpha:]]/;
>
> sherm--
>
-----------------------<SNIP>---------------------------
Thanks, that did the job.
Jan
------------------------------
Date: Wed, 21 Jun 2006 00:06:39 +0200
From: Joachim Durchholz <jo@durchholz.org>
Subject: Re: What is Expressiveness in a Computer Language
Message-Id: <e79rh0$e5k$1@online.de>
Torben Ęgidius Mogensen schrieb:
> That's not really the difference between static and dynamic typing.
> Static typing means that there exist a typing at compile-time that
> guarantess against run-time type violations. Dynamic typing means
> that such violations are detected at run-time.
Agreed.
> This is orthogonal to
> strong versus weak typing, which is about whether such violations are
> detected at all. The archetypal weakly typed language is machine code
> -- you can happily load a floating point value from memory, add it to
> a string pointer and jump to the resulting value.
I'd rather call machine code "untyped".
("Strong typing" and "weak typing" don't have a universally accepted
definition anyway, and I'm not sure that this terminology is helpful
anyway.)
> Anyway, type inference for statically typed langauges don't make them
> any more dynamically typed. It just moves the burden of assigning the
> types from the programmer to the compiler. And (for HM type systems)
> the compiler doesn't "guess" at a type -- it finds the unique most
> general type from which all other legal types (within the type system)
> can be found by instantiation.
Hmm... I think this distinction doesn't cover all cases.
Assume a language that
a) defines that a program is "type-correct" iff HM inference establishes
that there are no type errors
b) compiles a type-incorrect program anyway, with an establishes
rigorous semantics for such programs (e.g. by throwing exceptions as
appropriate).
The compiler might actually refuse to compile type-incorrect programs,
depending on compiler flags and/or declarations in the code.
Typed ("strongly typed") it is, but is it statically typed or
dynamically typed?
("Softly typed" doesn't capture it well enough - if it's declarations in
the code, then those part of the code are statically typed.)
> You miss some of the other benefits of static typing,
> though, such as a richer type system -- soft typing often lacks
> features like polymorphism (it will find a set of monomorphic
> instances rather than the most general type) and type classes.
That's not a property of soft typing per se, it's a consequence of
tacking on type inference on a dynamically-typed language that wasn't
designed for allowing strong type guarantees.
Regards,
Jo
------------------------------
Date: Wed, 21 Jun 2006 00:16:08 +0200
From: Joachim Durchholz <jo@durchholz.org>
Subject: Re: What is Expressiveness in a Computer Language
Message-Id: <e79s2q$f9t$1@online.de>
Matthias Blume schrieb:
> Perhaps better: A language is statically typed if its definition
> includes (or ever better: is based on) a static type system, i.e., a
> static semantics with typing judgments derivable by typing rules.
> Usually typing judgmets associate program phrases ("expressions") with
> types given a typing environment.
This is defining a single term ("statically typed") using three
undefined terms ("typing judgements", "typing rules", "typing environment").
Regards,
Jo
------------------------------
Date: Wed, 21 Jun 2006 00:27:29 +0200
From: Joachim Durchholz <jo@durchholz.org>
Subject: Re: What is Expressiveness in a Computer Language
Message-Id: <e79so3$ga2$1@online.de>
Chris F Clark schrieb:
> In that sense, a static type system is eliminating tags, because the
> information is pre-computed and not explicitly stored as a part of the
> computation. Now, you may not view the tag as being there, but in my
> mind if there exists a way of perfoming the computation that requires
> tags, the tag was there and that tag has been eliminated.
On a semantic level, the tag is always there - it's the type (and
definitely part of an axiomatic definition of the language).
Tag elimination is "just" an optimization.
> To put it another way, I consider the tags to be axiomatic. Most
> computations involve some decision logic that is driven by distinct
> values that have previously been computed. The separation of the
> values which drive the compuation one-way versus another is a tag.
> That tag can potentially be eliminated by some apriori computation.
Um... just as precomputing constants, I'd say.
Are the constants that went into a precomputed constant eliminated?
On the implementation level, yes. On the semantic/axiomatic level, no.
Or, well, maybe - since that's just an optimization, the compiler may
have decided to no precompute the constant at all.
(Agreeing with the snipped parts.)
Regards,
Jo
------------------------------
Date: Tue, 20 Jun 2006 17:30:29 -0500
From: Matthias Blume <find@my.address.elsewhere>
Subject: Re: What is Expressiveness in a Computer Language
Message-Id: <m11wtjh33u.fsf@hana.uchicago.edu>
Joachim Durchholz <jo@durchholz.org> writes:
> Matthias Blume schrieb:
>> Perhaps better: A language is statically typed if its definition
>> includes (or ever better: is based on) a static type system, i.e., a
>> static semantics with typing judgments derivable by typing rules.
>> Usually typing judgmets associate program phrases ("expressions") with
>> types given a typing environment.
>
> This is defining a single term ("statically typed") using three
> undefined terms ("typing judgements", "typing rules", "typing
> environment").
This was not meant to be a rigorous definition. Also, I'm not going
to repeat the textbook definitions for those three standard terms
here. Next thing you are going to ask me to define the meaning of the
word "is"...
------------------------------
Date: Tue, 20 Jun 2006 18:55:53 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: What's ^$ mean?
Message-Id: <slrne9h2o9.qfm.tadmc@magna.augustmail.com>
[Please learn the proper way to compose a followup.
Please do this before you make your next followup posting.
Text trimmed and rearranged into a sensible order, like is should
have been in the first place.
]
smarkham01@yahoo.com <smarkham01@yahoo.com> wrote:
> Tad McClellan wrote:
>> The original (poorly phrased) question was:
>>
>> Is ^$ mean a NULL line?
>>
> I don't disagree with your definition Tadd,
s/Tadd/Tad/;
> but I'm curious as to what
> meaning, other than "at the beginning of the (string | line) match the
> end of (string | line)" "^$" might have? Don't meta-characters remain
> remain meta-characters where ever they are,
No, they don't.
What the syntax means depends on what language the characters are in.
If you had instead said:
Is /^$/ mean a NULL line?
Then we would have known that the language the metacharacters appear
in is the regex language. (regex language)
But if you had said:
Is [^$] mean a NULL line?
Then the answer would have been: No, it matches any single character
that is not a dollar sign. (character class language)
And if you had said:
Is $vector^$mask mean a NULL line?
Then the answer would have been: No, it is a bitwise exclusive-or
and the sigil of a variable. (Perl language)
Taking just the caret (^) character, it has 3 meanings in 3
different languages:
Perl: bitwise exclusive-or
regex: beginning of string
char class: negates the class
Apart from that, even in the *same* language the same character
can have different meta-meanings. Take curly braces in Perl for
example: part of a hash slice, code block, anonymous hash
constructor, variable name delimiter, part of a hash access...
So, we cannot talk about Perl symbols without knowing a bit about
the context where the symbols appear, hence the encouragement to
post Real Perl Code in the Posting Guidelines.
Have you seen the Posting Guidelines that are posted here frequently?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
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 9328
***************************************