[28078] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 9442 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 10 03:05:37 2006

Date: Mon, 10 Jul 2006 00: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           Mon, 10 Jul 2006     Volume: 10 Number: 9442

Today's topics:
    Re: converting line input into columns vanagas99@yahoo.com
    Re: converting line input into columns <1usa@llenroc.ude.invalid>
    Re: converting line input into columns vanagas99@yahoo.com
        help: time series; forecast <thedwig@gmail.com>
    Re: help: time series; forecast <1usa@llenroc.ude.invalid>
    Re: help: time series; forecast <robert.dodier@gmail.com>
        new CPAN modules on Mon Jul 10 2006 (Randal Schwartz)
    Re: Spreadsheet::[Parse|Write]Excel - accessing the con <hawk007@flight.us>
    Re: Stupid Q: Read complete file into variable or strin <trwww@sbcglobal.net>
    Re: What is a type error? <gneuner2/@comcast.net>
    Re: What is a type error? <cdsmith@twu.net>
    Re: What is a type error? <marshall.spight@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 9 Jul 2006 19:01:42 -0700
From: vanagas99@yahoo.com
Subject: Re: converting line input into columns
Message-Id: <1152496902.511701.167670@p79g2000cwp.googlegroups.com>


Tad McClellan wrote:
> vanagas99@yahoo.com <vanagas99@yahoo.com> wrote:
>
> > sorry,
>
>
> Sorry for what?
>
> Please quote some context in followups like everybody else does.
>
>
> > a bit under preasure... been up til 3am trying to work on this.
>
>
> That does not give you the right to abuse us.
>
>
> > I am not a programmer.
>
>
> We know that.
>
> A programmer would have solved their problem given the information
> already posted earlier in this thread. They wouldn't be back for
> more hand holding.
>
>
> > A. Sinan Unur wrote:
>
> >> Oh, you are top-posting, please
> >> don't do that.
>
>
> Yet here you are top posting again.
>
>
> >> In my reply to your original post, I mentioned that you should read and
> >> follow the posting guidelines, and post what you have tried.
>
>
> Yet you have not posted what you have tried.
>
>
> >> You have received various solutions to your problem
>
>
> So why are you back here at all?
>
> It is pretty clear that your "sorry" is not at all sincere, else
> you wouldn't be repeating the same things that you are apologizing for.
>
>
> Welcome to perpetual invisi-land!
>
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas

Mr. McClellan, Thanks for the counseling session. Appreciate it.  Great
addition to my perl learning experience..... 

Thanks,
AV



------------------------------

Date: Mon, 10 Jul 2006 02:12:59 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: converting line input into columns
Message-Id: <Xns97FBE2179B661asu1cornelledu@127.0.0.1>

vanagas99@yahoo.com wrote in
news:1152496902.511701.167670@p79g2000cwp.googlegroups.com: 

> 
> Tad McClellan wrote:
>> vanagas99@yahoo.com <vanagas99@yahoo.com> wrote:
>>
>> > sorry,
>>
 ...

>> It is pretty clear that your "sorry" is not at all sincere,

 ...

> Mr. McClellan, Thanks for the counseling session. Appreciate it. 
> Great addition to my perl learning experience..... 

Sarcasm is not going to help you.

Bye.

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html



------------------------------

Date: 9 Jul 2006 21:48:08 -0700
From: vanagas99@yahoo.com
Subject: Re: converting line input into columns
Message-Id: <1152506888.217916.136870@s13g2000cwa.googlegroups.com>


A. Sinan Unur wrote:
> vanagas99@yahoo.com wrote in
> news:1152496902.511701.167670@p79g2000cwp.googlegroups.com:
>
> >
> > Tad McClellan wrote:
> >> vanagas99@yahoo.com <vanagas99@yahoo.com> wrote:
> >>
> >> > sorry,
> >>
> ...
>
> >> It is pretty clear that your "sorry" is not at all sincere,
>
> ...
>
> > Mr. McClellan, Thanks for the counseling session. Appreciate it.
> > Great addition to my perl learning experience.....
>
> Sarcasm is not going to help you.
>
> Bye.
>
> Sinan
>
> --
> A. Sinan Unur <1usa@llenroc.ude.invalid>
> (remove .invalid and reverse each component for email address)
>
> comp.lang.perl.misc guidelines on the WWW:
> http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html

Sinan,

I understand that. There is no reason for Tad to give a speach, either.
I hate when people think they own the world. I didn't even know what
"posting on top" means... plus, blabing about the sincerity of my
"sorry"??? "Abuse us?? what kind of statement is that? I have been in
the professional world for a long time and I am very appreciate when
folks take their time and respond with guidance. So far, I was not able
to get to work any of the previous suggestions. I keep getting
"Malformed Record" error any way I try it.

  use strict;
  use warnings;


  use Data::Dumper;
  use English qw{ -no_match_vars };


  $INPUT_RECORD_SEPARATOR = '';


  RECORD:
  while (my $record = <DATA>) {
        my (%record) = $record =~ m{\A \s*
                                      (Severity)
:(.+?)
                                      (Status)
:(.+?)
                                      (PDI . ID)
:(.+?)
                                      (Finding . Details)
(.+?)
                                      (Vulnerability . Discussion)
(.+?)
                                      (Manual . Fix . recommendations)
    (.+?)
		      (References and additional information) (.+?)
                                    \z}xms;
        if (not %record) {
                warn "Malformed record";
                next RECORD;
        }
        else {
                # fix up spacing
                for my $entry ( values %record ) {
                        $entry =~ s/^\s+//gm;
                        $entry =~ s/\s+$//gm;
                        $entry =~ s/\n/ /g;
                }
                print Dumper \%record;
        }
  }

__DATA__

Physical Security
Severity : Cat II / Important
Status : Unknown
PDI ID     : 1836
Finding Details
This vulnerability could not be checked by the program, it must be
checked manually.
Vulnerability Discussion
Category: II Inadequate physical protection can undermine all other
security precautions utilized to protect the system. This can
jeopardize the confidentiality, availability, and integrity of the
system.  Physical security of the individual machine is the first line
protection of any system.
Manual Fix Procedures
Ensure the computer equipment is located in a protected controlled
access area.
References and additional information
FSO Checklist:  3.1 CJCSM 6510.01, C-D.3


Administrator Documentation
Severity : Cat II / Important
Status : Unknown
PDI ID     : 1788
Finding Details
This vulnerability could not be checked by the program, it must be
checked manually.
Vulnerability Discussion
Category: II Using a privileged account to perform routine functions
makes the computer vulnerable to attack by any virus or Trojan Horse
inadvertently introduced during a session that has been granted full
privileges. The rule of least privilege should always be enforced.
Manual Fix Procedures
Ensure administrative personnel have two accounts assigned, a standard
user account and an account with membership in the Administrators
group.  Personnel should be instructed to use the less privileged
account for day-to-day use. Each System Administrator will have a
unique userid dedicated for administering the system. Each System
Administrator will have a separate account for normal user tasks. The
built-in Administrator account will not used to administer the system.
Administrators will be properly trained. The IAO will maintain a list
of users belonging to the Administrators group.
References and additional information
FSO Checklist:  3.2 DODI 8200.2, E3.4.7 CJCSM 6510.01, A-A.3



------------------------------

Date: 9 Jul 2006 18:56:19 -0700
From: "thedwig@gmail.com" <thedwig@gmail.com>
Subject: help: time series; forecast
Message-Id: <1152496579.786703.171510@h48g2000cwc.googlegroups.com>

I want to forecast sales data using time series analysis such as
holt's winter exponential smoothing or moving average method.

I'm not sure this can be done using PERL!!!!! Help me please.

Any other module or source code?



------------------------------

Date: Mon, 10 Jul 2006 02:38:12 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: help: time series; forecast
Message-Id: <Xns97FBE65E91B9Fasu1cornelledu@127.0.0.1>

"thedwig@gmail.com" <thedwig@gmail.com> wrote in 
news:1152496579.786703.171510@h48g2000cwc.googlegroups.com:

> I want to forecast sales data using time series analysis such as
> holt's winter exponential smoothing or moving average method.
> 
> I'm not sure this can be done using PERL!!!!! Help me please.

Moving average methods are really not that hard. What have you tried?

> Any other module or source code?

Other than what?

A few recommendations:

* Read the posting guidelines for this group.
* Exclamation points are hardly ever needed. Doubly so for multiple
  exclamation points.
* The language is Perl.

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html



------------------------------

Date: 9 Jul 2006 21:14:03 -0700
From: "Robert Dodier" <robert.dodier@gmail.com>
Subject: Re: help: time series; forecast
Message-Id: <1152504843.679029.147340@75g2000cwc.googlegroups.com>

thedwig@gmail.com wrote:

> I want to forecast sales data using time series analysis such as
> holt's winter exponential smoothing or moving average method.
>
> I'm not sure this can be done using PERL!!!!! Help me please.

Perl has a lot going for it but if you have any kind of statistical
problem, use the R system (http://www.r-project.org).
R is a programming language, suitable for writing scripts which
can handle very large data sources, and an interactive environment.
There are dozens of user-contributed add-on packages and
the user community is active and friendly. Look for mailing
lists on the web site. R totally rocks.

The tricky part of statistical problem solving is not in the
computation,
it's in the conceptual stuff. I'm guessing that you're not in a good
position to reinvent wheels here.

HTH
Robert Dodier



------------------------------

Date: Mon, 10 Jul 2006 04:42:07 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Mon Jul 10 2006
Message-Id: <J267q7.16Ir@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.

Alien-wxWidgets-0.18
http://search.cpan.org/~mbarbon/Alien-wxWidgets-0.18/
building, finding and using wxWidgets binaries
----
Audio-M4P-0.33
http://search.cpan.org/~billh/Audio-M4P-0.33/
M4P/MP4/M4A QuickTime audio music format modules
----
Biblio-Isis-0.21
http://search.cpan.org/~dpavlin/Biblio-Isis-0.21/
Read CDS/ISIS, WinISIS and IsisMarc database
----
Bot-BasicBot-Pluggable-Module-RD-0.01
http://search.cpan.org/~ivorw/Bot-BasicBot-Pluggable-Module-RD-0.01/
RecDescent grammar adaptor plugin
----
Catalyst-Plugin-Authentication-Credential-HTTP-0.04
http://search.cpan.org/~esskar/Catalyst-Plugin-Authentication-Credential-HTTP-0.04/
HTTP Basic and Digest authentication for Catlayst.
----
Class-DBI-Pg-0.09
http://search.cpan.org/~dmaki/Class-DBI-Pg-0.09/
Class::DBI extension for Postgres
----
Danga-Socket-1.52
http://search.cpan.org/~bradfitz/Danga-Socket-1.52/
Event loop and event-driven async socket base class
----
EekBoek-0.62
http://search.cpan.org/~jv/EekBoek-0.62/
Bookkeeping software for small and medium-size businesses
----
File-CreationTime-2.03
http://search.cpan.org/~jrockway/File-CreationTime-2.03/
Keeps track of file creation times
----
FlatFile-0.11
http://search.cpan.org/~mjd/FlatFile-0.11/
Manipulate flat-file databases
----
Gearman-1.02
http://search.cpan.org/~bradfitz/Gearman-1.02/
----
Gearman-Client-Async-0.90
http://search.cpan.org/~bradfitz/Gearman-Client-Async-0.90/
Asynchronous client module for Gearman for Danga::Socket applications
----
Gearman-Client-Async-0.91
http://search.cpan.org/~bradfitz/Gearman-Client-Async-0.91/
Asynchronous client module for Gearman for Danga::Socket applications
----
IPC-Mmap-SimpleShare-0.02
http://search.cpan.org/~aduitsis/IPC-Mmap-SimpleShare-0.02/
Safely share structures among processes using anonymous mmap.
----
POE-XS-Queue-Array-0.002
http://search.cpan.org/~tonyc/POE-XS-Queue-Array-0.002/
an XS implementation of POE::Queue::Array.
----
Perl-Dist-0.000001
http://search.cpan.org/~dagolden/Perl-Dist-0.000001/
Create binary Perl distributions
----
Perl-Dist-Strawberry-0.000001
http://search.cpan.org/~dagolden/Perl-Dist-Strawberry-0.000001/
Strawberry Perl for win32
----
Perl-Dist-Vanilla-6
http://search.cpan.org/~dagolden/Perl-Dist-Vanilla-6/
Vanilla Perl for win32
----
Pod-MultiLang-0.09
http://search.cpan.org/~hio/Pod-MultiLang-0.09/
multi languages in Pod
----
Qtk-QuickTk-0.90
http://search.cpan.org/~jnk/Qtk-QuickTk-0.90/
A Simpler Syntax for Perl-Tk GUI Building
----
REST-Application-0.91
http://search.cpan.org/~moconnor/REST-Application-0.91/
A framework for building RESTful web-applications.
----
TL-0.10_05
http://search.cpan.org/~mikage/TL-0.10_05/
Tripletail, Framework for Japanese Web Application
----
Task-Smoke-0.13
http://search.cpan.org/~gaal/Task-Smoke-0.13/
Install modules required for Pugs-like smoke system
----
Test-Simple-0.63
http://search.cpan.org/~mschwern/Test-Simple-0.63/
Basic utilities for writing tests.
----
Wx-0.53
http://search.cpan.org/~mbarbon/Wx-0.53/
interface to the wxWidgets cross-platform GUI toolkit
----
YAML-AppConfig-0.16
http://search.cpan.org/~moconnor/YAML-AppConfig-0.16/
Manage configuration files with YAML and variable reference.


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: 9 Jul 2006 18:05:04 -0700
From: "Andrew" <hawk007@flight.us>
Subject: Re: Spreadsheet::[Parse|Write]Excel - accessing the contents of a cell
Message-Id: <1152493503.951172.207970@p79g2000cwp.googlegroups.com>

Justin C wrote:
> On 2006-07-07, Jim Gibson <jgibson@mail.arc.nasa.gov> wrote:
> > In article <slrneaqtt1.3cm.justin.0607@moonlight.purestblue.com>,
> > Justin C <justin.0607@purestblue.com> wrote:
> >
> >> I've been trying to follow the examples given in the
> >> Spreadsheet::ParseExcel module and appear to have become stuck. I have a
> >> spreadsheet, most of which I need to copy to a new spreadsheet...
> >> A6 to J6084 (well, that last number changes each time the sheet is
> >> updated but I can extract that info from the sheet).
> >>
> >> What I have so far is:
> >>
> >> ---- START ----
> >
> > [start of program snipped]
> >
> >> while ( $r <= $lastrow ) {
> >>     my $c = 0 ;
> >>     while ( $c < 10 ) {
> >
> > Perl has 'for' loops, you know.
>
> Yes, should I have used a for loop instead? Why is it better?
>
>
> >>         my $nsr = $r - $srow ; # new sheet row number
> >>         my $cell = $oldsheet->{Cells}[$r][$c] ;
> >>         $newsheet->write($nsr , $c , $cell->Value) if ( $cell->Value ) ;
> >
> > I would delete the if part of this statement. You don't know if
>
> My concern was, if the cell contained nothing then, $cell->Value would be
> undef and I'd either get something unwanted in the new worksheet or the
> program wouldn't run.
>
>
> >>         $newsheet->write($nsr , $c , $cell->Format) if ( $cell->Format ) ;
> >
> > This line is not correct. The format instance should be the fourth
> > (optional) argument of write.
>
> I knew that! I just wasn't paying attention :)
>
>
> > Here is a program that copies a spreasheet and sets the color of the
> > copied cells. Maybe you can start with this. It uses the Cell() method
> > instead of Cells() (might be more efficient) and the add_format()
> > method of the Workbook. I leave the offset methods of moving cells to
> > you:
>
> OK, let me try it and see what happens.
>
> Parse: 0.2603
> Write: 2.17
> Can't call method "Value" on an undefined value at bin/web_new/a2z2.pl line 22.
>
> Maybe the spreadsheets you've used this on have no empty cells? I think
> I'm going to compare our two attempts, read the documentation to see
> what yours is doing, and then have another go.
>

Also, (this might be completely unrelated to your particular case, but
it does concern Spreadsheet::ParseExcel -- last time I checked, a
couple of months ago), if you are generating or resaving your Excel
sheets with OpenOffice (in *.xls format), you may end up with some
strange hidden "defects"(?) that undermine ParseExcel.pm, making it
produce unexpected results.  IIRC, in particular, this has/had to do
with blank/undefined cells, but there could be other problems as well.
I gave up trying to fix it and circumvented it by (re)saving the
spreadsheet in MS Excel.

Andrew



------------------------------

Date: Mon, 10 Jul 2006 01:44:39 GMT
From: "Todd W" <trwww@sbcglobal.net>
Subject: Re: Stupid Q: Read complete file into variable or string
Message-Id: <biisg.63399$fb2.42352@newssvr27.news.prodigy.net>


"Franzl Wisseworst" <franzl.wisseworst@mailinator.net> wrote in message 
news:e8ravq$3dc$00$1@news.t-online.com...
> Thanks for the various replies. Below is my initial crap code.
>
<snip />
>
> -------- start of crap code ------------
>
> use CGI qw (:standard);
>
> print header;
>
> $mytext = param('mytext');
>
> $myfile = "bla.txt";
>
> open (BLA,$myfile);
> my @lines = <BLA>;
> close(BLA);
>
> print start_form, 'notes',br,
> textarea('mytext',"@lines"),br,
> submit, end_form;
>
> if ($mytext ne ""){
> open(BLA, ">$myfile");
> print BLA $mytext;
> close(BLA);
> }
>
> ------------ end of crap code ------------
>
> Any quick tips how to improve, expand and correct otherwise crap code
> would be much appreciated.
>

Here is how I would write that program:

#!/usr/bin/perl
use warnings;
use strict;
use CGI qw(:standard);
use IO::File;

my $myfile = '/home/trwww/bla.txt';

if ( my $mytext = param( 'mytext' ) ) {
  IO::File->new( "> $myfile" )->print( $mytext );
}

my $fh = IO::File->new( $myfile );

print(
  header( -expires=> '-1d' ),
  start_html(),
  'notes',
  br(),
  start_form(),
  textarea( mytext => join('', $fh->getlines ) ),
  br(),
  submit(),
  end_form(),
  end_html()
);

Todd W.




------------------------------

Date: Mon, 10 Jul 2006 00:46:31 -0400
From: George Neuner <gneuner2/@comcast.net>
Subject: Re: What is a type error?
Message-Id: <8vl3b2tu42if639eaak4i79cbqrqig7tch@4ax.com>

On Mon, 26 Jun 2006 11:49:51 -0600, Chris Smith <cdsmith@twu.net>
wrote:

>Pascal Costanza <pc@p-cos.net> wrote:
>
>> This is maybe better understandable in user-level code. Consider the 
>> following class definition:
>> 
>> class Person {
>>    String name;
>>    int age;
>> 
>>    void buyPorn() {
>>     if (< this.age 18) throw new AgeRestrictionException();
>>     ...
>>    }
>> }
>> 
>> The message p.buyPorn() is a perfectly valid message send and will pass 
>> both static and dynamic type tests (given p is of type Person in the 
>> static case).
>
>It appears you've written the code above to assume that the type system 
>can't cerify that age >= 18... otherwise, the if statement would not 
>make sense.  It also looks like Java, in which the type system is indeed 
>not powerfule enough to do that check statically.  However, it sounds as 
>if you're claiming that it wouldn't be possible for the type system to 
>do this?  If so, that's not correct.  If such a thing were checked at 
>compile-time by a static type check, then failing to actually provide 
>that guarantee would be a type error, and the compiler would tell you 
>so.

Now this is getting ridiculous.  Regardless of implementation
language, Pascal's example is of a data dependent, runtime constraint.
Is the compiler to forbid a person object from aging?  If not, then
how does this person object suddenly become a different type when it
becomes 18?  Is this conversion to be automatic or manual?  

The programmer could forget to make a manual conversion, in which case
the program's behavior is wrong.  If your marvelous static type
checker does the conversion automatically, then obviously types are
not static and can be changed at runtime.  

Either way you've failed to prevent a runtime problem using a purely
static analysis.


George
--
for email reply remove "/" from address


------------------------------

Date: Sun, 9 Jul 2006 23:44:41 -0600
From: Chris Smith <cdsmith@twu.net>
Subject: Re: What is a type error?
Message-Id: <MPG.1f1b973841b328b998976b@news.altopia.net>

George Neuner <gneuner2/@comcast.net> wrote:
> Now this is getting ridiculous.

It's not at all ridiculous.  The fact that it seems ridiculous is a good 
reason to educate people about what static typing does (and doesn't) 
mean, and specifically that it doesn't imply any constraints on the kind 
of behavioral property that's being checked; but only on the way that 
the check occurs.

(As a subtle point here, we're assuming that this really is an error; 
i.e., it shouldn't happen in a correct program.  If this is validation 
against a user mistake, then that's a different matter; obviously, that 
would typically be done with a conditional statement like if, and 
wouldn't count as a type error in any context.)

> Regardless of implementation
> language, Pascal's example is of a data dependent, runtime constraint.

99% of program errors (excluding only syntax errors and the like) are 
data-dependent runtime errors.  Types are a way of classifying that data 
until such errors become obvious at compile time.

> Is the compiler to forbid a person object from aging?  If not, then
> how does this person object suddenly become a different type when it
> becomes 18?  Is this conversion to be automatic or manual?  

The object doesn't have a type (this is static typing, remember?), but 
expressions do.  The expressions have types, and those types are 
probably inferred in such a circumstance (at least, this one would even 
more of a pain without type inference).

> If your marvelous static type
> checker does the conversion automatically, then obviously types are
> not static and can be changed at runtime.  

There really is no conversion, but it does infer the correct types 
automatically.  It does so by having more complex rules regarding how to 
determine the type of an expression.  Java's current type system, of 
course, is considerably less powerful.  In particular, Java mostly 
assures that a variable name has a certain type when used as an 
expression, regardless of the context of that expression.  Only with 
some of the Java 5 features (capture conversion, generic method type 
inference, etc) did this cease to be the case.  It would be necessary to 
drop this entirely to make the feature above work.  For example, 
consider the following in a hypothetical Java language augmented with 
integer type ranges:

    int{17..26} a;
    int{14..22} b;

    ...

    if (a < b)
    {
        // Inside this block, a has type int{17..21} and b has type
        // int{18..22}

        signContract(a); // error, because a might be 17
        signContract(b); // no error, because even though the declared
                         // type of b is int{14..22}, it has a local
                         // type of int{18..22}.
    }

(By the way, I hate this example... hence I've changed buyPorn to 
signContract, which at least in the U.S. also requires a minimum age of 
18.  Hopefully, you'll agree this doesn't change the sunstantive 
content. :)

Note that when a programmer is validating input from a user, they will 
probably write precisely the kind of conditional expression that allows 
the compiler to deduce a sufficiently restrictive type and thus allows 
the type checker to succeed.  Or if they don't do so -- say, for 
example, the programmer produces a fencepost error by accidentally 
entering "if (age >= 17)" instead of "if (age > 17)" -- then the 
compiler will produce a type error as a result.  If the programmer 
stores the value into a variable of general type int (assuming such a 
thing still exists in our augmented Java-esque language), then the 
additional type information is forgotten, just like type information is 
forgotten when a reference of type String is assigned to a reference of 
type Object.  In both cases, a runtime-checked cast will be required to 
restore the lost type information.

Incidentally, I'm not saying that such a feature would be a good idea.  
It generally isn't provided in languages specifically because it gets to 
be a big pain to maintain all of the type specifications for this kind 
of stuff.  However, it is possible, and it is a static type system, 
because expressions are assigned typed syntactically, rather than values 
being checked for correctness at runtime.

-- 
Chris Smith - Lead Software Developer / Technical Trainer
MindIQ Corporation


------------------------------

Date: 9 Jul 2006 23:20:17 -0700
From: "Marshall" <marshall.spight@gmail.com>
Subject: Re: What is a type error?
Message-Id: <1152512416.981345.232330@h48g2000cwc.googlegroups.com>

Chris Smith wrote:
>
> [...] static typing does ... doesn't imply any constraints on the kind
> of behavioral property that's being checked; but only on the way that
> the check occurs.

Nice post.


Marshall



------------------------------

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 9442
***************************************


home help back first fref pref prev next nref lref last post